Skip to content

Commit da3baa8

Browse files
authored
Merge pull request #42 from madratman/PR/fix-odom-cb-and-join
add another client for odom cb, and call .join() on fly_through*() ca…
2 parents 37e1b2c + 28c849d commit da3baa8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

baselines/baseline_racer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def __init__(self, drone_name = "drone_1", plot_transform=True, viz_traj=True, v
2222
# and use another airsim MultirotorClient for querying state commands
2323
self.airsim_client_images = airsim.MultirotorClient()
2424
self.airsim_client_images.confirmConnection()
25+
self.airsim_client_odom = airsim.MultirotorClient()
26+
self.airsim_client_odom.confirmConnection()
2527
self.level_name = None
2628

2729
self.image_callback_thread = threading.Thread(target=self.repeat_timer_image_callback, args=(self.image_callback, 0.03))
@@ -47,7 +49,6 @@ def reset_race(self):
4749
# arms drone, enable APIs, set default traj tracker gains
4850
def initialize_drone(self):
4951
self.airsim_client.enableApiControl(vehicle_name=self.drone_name)
50-
self.airsim_client_images.enableApiControl(vehicle_name=self.drone_name)
5152
self.airsim_client.arm(vehicle_name=self.drone_name)
5253

5354
# set default values for trajectory tracker gains
@@ -201,7 +202,7 @@ def image_callback(self):
201202

202203
def odometry_callback(self):
203204
# get uncompressed fpv cam image
204-
drone_state = self.airsim_client.getMultirotorState()
205+
drone_state = self.airsim_client_odom.getMultirotorState()
205206
# in world frame:
206207
position = drone_state.kinematics_estimated.position
207208
orientation = drone_state.kinematics_estimated.orientation
@@ -256,15 +257,15 @@ def main(args):
256257

257258
if args.planning_baseline_type == "all_gates_at_once" :
258259
if args.planning_and_control_api == "moveOnSpline":
259-
baseline_racer.fly_through_all_gates_at_once_with_moveOnSpline()
260+
baseline_racer.fly_through_all_gates_at_once_with_moveOnSpline().join()
260261
if args.planning_and_control_api == "moveOnSplineVelConstraints":
261-
baseline_racer.fly_through_all_gates_at_once_with_moveOnSplineVelConstraints()
262+
baseline_racer.fly_through_all_gates_at_once_with_moveOnSplineVelConstraints().join()
262263

263264
if args.planning_baseline_type == "all_gates_one_by_one":
264265
if args.planning_and_control_api == "moveOnSpline":
265-
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSpline()
266+
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSpline().join()
266267
if args.planning_and_control_api == "moveOnSplineVelConstraints":
267-
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSplineVelConstraints()
268+
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSplineVelConstraints().join()
268269

269270
baseline_racer.stop_image_callback_thread()
270271
baseline_racer.stop_odometry_callback_thread()

0 commit comments

Comments
 (0)