Skip to content

Commit

Permalink
Merge pull request #42 from madratman/PR/fix-odom-cb-and-join
Browse files Browse the repository at this point in the history
add another client for odom cb, and call .join() on fly_through*() ca…
  • Loading branch information
madratman authored Aug 26, 2019
2 parents 37e1b2c + 28c849d commit da3baa8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions baselines/baseline_racer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def __init__(self, drone_name = "drone_1", plot_transform=True, viz_traj=True, v
# and use another airsim MultirotorClient for querying state commands
self.airsim_client_images = airsim.MultirotorClient()
self.airsim_client_images.confirmConnection()
self.airsim_client_odom = airsim.MultirotorClient()
self.airsim_client_odom.confirmConnection()
self.level_name = None

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

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

def odometry_callback(self):
# get uncompressed fpv cam image
drone_state = self.airsim_client.getMultirotorState()
drone_state = self.airsim_client_odom.getMultirotorState()
# in world frame:
position = drone_state.kinematics_estimated.position
orientation = drone_state.kinematics_estimated.orientation
Expand Down Expand Up @@ -256,15 +257,15 @@ def main(args):

if args.planning_baseline_type == "all_gates_at_once" :
if args.planning_and_control_api == "moveOnSpline":
baseline_racer.fly_through_all_gates_at_once_with_moveOnSpline()
baseline_racer.fly_through_all_gates_at_once_with_moveOnSpline().join()
if args.planning_and_control_api == "moveOnSplineVelConstraints":
baseline_racer.fly_through_all_gates_at_once_with_moveOnSplineVelConstraints()
baseline_racer.fly_through_all_gates_at_once_with_moveOnSplineVelConstraints().join()

if args.planning_baseline_type == "all_gates_one_by_one":
if args.planning_and_control_api == "moveOnSpline":
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSpline()
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSpline().join()
if args.planning_and_control_api == "moveOnSplineVelConstraints":
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSplineVelConstraints()
baseline_racer.fly_through_all_gates_one_by_one_with_moveOnSplineVelConstraints().join()

baseline_racer.stop_image_callback_thread()
baseline_racer.stop_odometry_callback_thread()
Expand Down

0 comments on commit da3baa8

Please sign in to comment.