Skip to content

Commit bcd1ec0

Browse files
author
Michelle Sintov
committed
VIC-11969 Add "create wall" tutorial (#79)
1 parent b9bf6c3 commit bcd1ec0

2 files changed

Lines changed: 58 additions & 3 deletions

File tree

anki_vector/opengl/opengl_vector.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,15 @@ def __init__(self, custom_object, is_fixed: bool):
551551
super().__init__(custom_object)
552552

553553
self.is_fixed = is_fixed
554-
self.x_size_mm = custom_object.archetype.x_size_mm
555-
self.y_size_mm = custom_object.archetype.y_size_mm
556-
self.z_size_mm = custom_object.archetype.z_size_mm
554+
555+
if self.is_fixed:
556+
self.x_size_mm = custom_object.x_size_mm
557+
self.y_size_mm = custom_object.y_size_mm
558+
self.z_size_mm = custom_object.z_size_mm
559+
else:
560+
self.x_size_mm = custom_object.archetype.x_size_mm
561+
self.y_size_mm = custom_object.archetype.y_size_mm
562+
self.z_size_mm = custom_object.archetype.z_size_mm
557563

558564

559565
class RobotRenderFrame(): # pylint: disable=too-few-public-methods
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright (c) 2018 Anki, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License in the file LICENSE.txt or at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""Use custom objects to create a wall in front of Vector.
18+
19+
This example demonstrates how you can create custom objects in the world, and
20+
automatically have Vector path around them as if they are real obstacles.
21+
22+
It creates a wall in front of Vector and tells him to drive around it.
23+
He will plan a path to drive 200mm in front of himself after these objects are created.
24+
25+
The `show_3d_viewer=True` argument causes the 3D visualizer to open in a new
26+
window - this shows where Vector believes this imaginary object is.
27+
"""
28+
29+
import anki_vector
30+
from anki_vector.util import Pose, degrees
31+
32+
33+
def main():
34+
args = anki_vector.util.parse_command_args()
35+
with anki_vector.Robot(args.serial,
36+
show_3d_viewer=True,
37+
enable_nav_map_feed=True) as robot:
38+
robot.behavior.drive_off_charger()
39+
40+
fixed_object = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)),
41+
10, 100, 100, relative_to_robot=True)
42+
if fixed_object:
43+
print("fixed custom object created successfully")
44+
45+
robot.behavior.go_to_pose(Pose(200, 0, 0, angle_z=degrees(0)), relative_to_robot=True)
46+
robot.world.delete_custom_objects()
47+
48+
if __name__ == "__main__":
49+
main()

0 commit comments

Comments
 (0)