|
1 | 1 | import setup_path |
2 | 2 | import airsim |
3 | | -from airsim import Vector3r |
| 3 | +from airsim import Vector3r, Quaternionr, Pose |
| 4 | +from airsim.utils import to_quaternion |
4 | 5 | import numpy as np |
| 6 | +import time |
5 | 7 |
|
6 | 8 | client = airsim.VehicleClient() |
7 | 9 | client.confirmConnection() |
8 | 10 |
|
9 | | -# plot 2 red arrows for 3 seconds |
10 | | -arrow_1_start, arrow_2_start = Vector3r(0,0,-1), Vector3r(0,0,-3) |
11 | | -arrow_1_end, arrow_2_end = Vector3r(1,1,-1), Vector3r(2,2,-3) |
12 | | -client.simPlotArrowList(points_start = [arrow_1_start, arrow_2_start], points_end = [arrow_1_end, arrow_2_end], |
13 | | - color_rgba = [1.0, 0.0, 1.0, 1.0], duration = 3.0, arrow_size = 20, thickness = 4) |
| 11 | +# plot red arrows for 30 seconds |
| 12 | +client.simPlotArrowList(points_start = [Vector3r(x,y,0) for x, y in zip(np.linspace(0,10,20), np.linspace(0,0,20))], |
| 13 | + points_end = [Vector3r(x,y,0) for x, y in zip(np.linspace(0,10,20), np.linspace(10,10,20))], |
| 14 | + color_rgba = [1.0, 0.0, 1.0, 1.0], duration = 30.0, arrow_size = 10, thickness = 1) |
14 | 15 |
|
15 | | -# plot 2 yellow arrows for 4 seconds |
16 | | -arrow_1_start, arrow_2_start = Vector3r(0,1,-1), Vector3r(0,1,-3) |
17 | | -arrow_1_end, arrow_2_end = Vector3r(4,5,-1), Vector3r(2,3,-3) |
18 | | -client.simPlotArrowList(points_start = [arrow_1_start, arrow_2_start], points_end = [arrow_1_end, arrow_2_end], |
19 | | - color_rgba = [1.0, 1.0, 0.0, 1.0], duration = 4.0, arrow_size = 20, thickness = 3) |
| 16 | +# plot magenta arrows for 15 seconds |
| 17 | +client.simPlotArrowList(points_start = [Vector3r(x,y,-3) for x, y in zip(np.linspace(0,10,20), np.linspace(0,0,20))], |
| 18 | + points_end = [Vector3r(x,y,-5) for x, y in zip(np.linspace(0,10,20), np.linspace(10,20,20))], |
| 19 | + color_rgba = [1.0, 1.0, 0.0, 1.0], duration = 15.0, arrow_size = 20, thickness = 3) |
20 | 20 |
|
21 | | -# plot 2 red arrows for 5 seconds |
22 | | -arrow_1_start, arrow_2_start = Vector3r(1,1,-2), Vector3r(1,1,-4) |
23 | | -arrow_1_end, arrow_2_end = Vector3r(-4,-4,-2), Vector3r(-2,-2,-4) |
24 | | -client.simPlotArrowList(points_start = [arrow_1_start, arrow_2_start], points_end = [arrow_1_end, arrow_2_end], |
25 | | - color_rgba = [1.0, 0.0, 0.0, 1.0], duration = 5.0, arrow_size = 20, thickness = 2) |
| 21 | +# plot red arrows for 10 seconds |
| 22 | +client.simPlotArrowList(points_start = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,10,20), np.linspace(0,0,20), np.linspace(-3,-10, 20))], |
| 23 | + points_end = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,10,20), np.linspace(10,20,20), np.linspace(-5,-8, 20))], |
| 24 | + color_rgba = [1.0, 0.0, 0.0, 1.0], duration = 10.0, arrow_size = 100, thickness = 5) |
26 | 25 |
|
27 | 26 | # plot 2 white arrows which are persistent |
28 | | -arrow_1_start, arrow_2_start = Vector3r(2,2,-2), Vector3r(0,1,-4) |
29 | | -arrow_1_end, arrow_2_end = Vector3r(2,3,-2), Vector3r(2,4,-4) |
30 | | -client.simPlotArrowList(points_start = [arrow_1_start, arrow_2_start], points_end = [arrow_1_end, arrow_2_end], |
31 | | - color_rgba = [1.0, 1.0, 1.0, 1.0], duration = 5.0, arrow_size = 20, thickness = 10, is_persistent = True) |
| 27 | +client.simPlotArrowList(points_start = [Vector3r(x,y,-2) for x, y in zip(np.linspace(0,10,20), np.linspace(0,20,20))], |
| 28 | + points_end = [Vector3r(x,y,-5) for x, y in zip(np.linspace(3,17,20), np.linspace(5,28,20))], |
| 29 | + color_rgba = [1.0, 1.0, 1.0, 1.0], duration = 5.0, arrow_size = 100, thickness = 1, is_persistent = True) |
32 | 30 |
|
33 | 31 | # plot points |
34 | | -client.simPlotPoints(points = [Vector3r(x,y,-2) for x, y in zip(np.linspace(0,10,20), np.linspace(0,20,20))], color_rgba=[1.0, 0.0, 0.0, 1.0], size = 20, duration = 20.0, is_persistent = False) |
35 | | -client.simPlotPoints(points = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,-10,20), np.linspace(0,-20,20), np.linspace(0,-5,20))], color_rgba=[0.0, 0.0, 1.0, 1.0], size = 10, duration = 20.0, is_persistent = False) |
36 | | -client.simPlotPoints(points = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,10,20), np.linspace(0,-20,20), np.linspace(0,-7,20))], color_rgba=[1.0, 0.0, 1.0, 1.0], size = 15, duration = 20.0, is_persistent = False) |
| 32 | +client.simPlotPoints(points = [Vector3r(x,y,-5) for x, y in zip(np.linspace(0,-10,20), np.linspace(0,-20,20))], color_rgba=[1.0, 0.0, 0.0, 1.0], size = 25, duration = 20.0, is_persistent = False) |
| 33 | +client.simPlotPoints(points = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,-10,20), np.linspace(0,-20,20), np.linspace(0,-5,20))], color_rgba=[0.0, 0.0, 1.0, 1.0], size = 10, duration = 20.0, is_persistent = False) |
| 34 | +client.simPlotPoints(points = [Vector3r(x,y,z) for x, y, z in zip(np.linspace(0,10,20), np.linspace(0,-20,20), np.linspace(0,-7,20))], color_rgba=[1.0, 0.0, 1.0, 1.0], size = 15, duration = 20.0, is_persistent = False) |
| 35 | + |
| 36 | +# plot line strip. 0-1, 1-2, 2-3 |
| 37 | +client.simPlotLineStrip(points = [Vector3r(x,y,-5) for x, y in zip(np.linspace(0,-10,10), np.linspace(0,-20,10))], color_rgba=[1.0, 0.0, 0.0, 1.0], thickness = 5, duration = 30.0, is_persistent = False) |
| 38 | + |
| 39 | +# plot line list. 0-1, 2-3, 4-5. Must be even. |
| 40 | +client.simPlotLineList(points = [Vector3r(x,y,-7) for x, y in zip(np.linspace(0,-10,10), np.linspace(0,-20,10))], color_rgba=[1.0, 0.0, 0.0, 1.0], thickness = 5, duration = 30.0, is_persistent = False) |
| 41 | + |
| 42 | +# plot transforms |
| 43 | +client.simPlotTransform(poses = [Pose(position_val=Vector3r(x,y,-7), orientation_val=to_quaternion(pitch=0.0, roll=0.0, yaw=np.pi/2)) for x, y in zip(np.linspace(0,-10,10), np.linspace(0,-20,10))], |
| 44 | + scale = 35, thickness = 5, duration = 10.0, is_persistent = False) |
| 45 | + |
| 46 | +client.simPlotTransform(poses = [Pose(position_val=Vector3r(x,y,-5), orientation_val=to_quaternion(pitch=0.0, roll=0.0, yaw=0.0)) for x, y in zip(np.linspace(0,-10,10), np.linspace(0,-20,10))], |
| 47 | + scale = 35, thickness = 5, duration = 10.0, is_persistent = False) |
| 48 | + |
0 commit comments