Skip to content

Commit

Permalink
fix: globally available service_proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
simojo committed Jan 27, 2024
1 parent 2ea70b1 commit 6446fcc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/ddpg_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def episode_reset_and_grab_state():
# wait until position is reset
input("input to shut down px4...")
# disarm the px4
service_proxies.arming(False)
service_proxies.arming(value=False)
input("input to reset world...")
service_proxies.reset_world()
print("COMPLETE")
Expand Down Expand Up @@ -353,7 +353,8 @@ def episode_take_action(action):
simulation_nodes.launch_gazebo()
simulation_nodes.launch_clover_services()
simulation_nodes.launch_clover_model()
service_proxies.init()

service_proxies.init()

for ep in range(total_episodes):

Expand Down
22 changes: 11 additions & 11 deletions src/service_proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
set_rates = None
set_velocity = None

def init(self):
def init():
"""Create service proxies"""
# wait for /gazebo/reset_world to become available
rospy.wait_for_service('/gazebo/reset_world')
arming = rospy.ServiceProxy("/mavros/cmd/arming", CommandBool)
reset_world = rospy.ServiceProxy('/gazebo/reset_world', Empty)
globals()["arming"] = rospy.ServiceProxy("/mavros/cmd/arming", CommandBool)
globals()["reset_world"] = rospy.ServiceProxy('/gazebo/reset_world', Empty)
# https://github.com/CopterExpress/clover/blob/master/clover/srv/GetTelemetry.srv
get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)
navigate = rospy.ServiceProxy('navigate', srv.Navigate)
navigate_global = rospy.ServiceProxy('navigate_global', srv.NavigateGlobal)
set_position = rospy.ServiceProxy('set_position', srv.SetPosition)
set_velocity = rospy.ServiceProxy('set_velocity', srv.SetVelocity)
set_attitude = rospy.ServiceProxy('set_attitude', srv.SetAttitude)
set_rates = rospy.ServiceProxy('set_rates', srv.SetRates)
land = rospy.ServiceProxy('land', Trigger)
globals()["get_telemetry"] = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)
globals()["navigate"] = rospy.ServiceProxy('navigate', srv.Navigate)
globals()["navigate_global"] = rospy.ServiceProxy('navigate_global', srv.NavigateGlobal)
globals()["set_position"] = rospy.ServiceProxy('set_position', srv.SetPosition)
globals()["set_velocity"] = rospy.ServiceProxy('set_velocity', srv.SetVelocity)
globals()["set_attitude"] = rospy.ServiceProxy('set_attitude', srv.SetAttitude)
globals()["set_rates"] = rospy.ServiceProxy('set_rates', srv.SetRates)
globals()["land"] = rospy.ServiceProxy('land', Trigger)

0 comments on commit 6446fcc

Please sign in to comment.