Created
September 8, 2017 10:06
-
-
Save dsposito/e9daaed88ae13dff9546f0cfc6c92694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# ROS | |
import rospy | |
from mavros_msgs.srv import SetMode | |
from mavros_msgs.srv import CommandBool | |
# System | |
import time | |
rospy.init_node('rosimple_node', anonymous = True) | |
# Set Mode | |
print("SET MODE") | |
rospy.wait_for_service('/mavros/set_mode') | |
try: | |
modeService = rospy.ServiceProxy('/mavros/set_mode', SetMode) | |
modeResponse = modeService(0, 'STABILIZE') | |
rospy.loginfo(modeResponse) | |
except rospy.ServiceException as e: | |
print("Service call failed: %s" %e) | |
# Arm | |
print("ARM") | |
rospy.wait_for_service('/mavros/cmd/arming') | |
try: | |
armService = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool) | |
armResponse = armService(True) | |
rospy.loginfo(armResponse) | |
except rospy.ServiceException as e: | |
print("Service call failed: %s" %e) | |
time.sleep(5) | |
# Disarm | |
print("DISARM") | |
rospy.wait_for_service('/mavros/cmd/arming') | |
try: | |
armService = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool) | |
armService(False) | |
except rospy.ServiceException as e: | |
print("Service call failed: %s" %e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment