Example #1
0
def my_code():
    act = ActuatorControl()
    act.header = Header()
    act.controls[0] = 0.0  #ros_roll
    act.controls[1] = 0.0  #ros_pitch
    act.controls[2] = 1  #ros_yaw
    act.controls[3] = 0.5  #ros_throttle
    act.controls[4] = 0.0
    act.controls[5] = 0.0
    act.controls[6] = 0.0
    act.controls[7] = 0.0

    while not rospy.is_shutdown():
        pub_act.publish(act)
Example #2
0
    def set_act(self, group, output, freq):
        """
		Offboard method that sets the values of the mixers and/or actuators of the vehicle.

		Parameters
		----------
		group: int
			Desired control group.
		output : list
			Desired output values for the mixers and/or actuators of the drone.
		freq : float
			Topic publishing frequency, in Hz.
		"""
        pub = rospy.Publisher(self.info.drone_ns + '/mavros/actuator_control',
                              ActuatorControl,
                              queue_size=1)
        msg = ActuatorControl()
        msg.header = Header()
        msg.header.stamp = rospy.Time.now()
        msg.group_mix = group
        msg.controls = output
        pub.publish(msg)
        rate = rospy.Rate(freq)
        rate.sleep()
Example #3
0
    armService(True)
except rospy.ServiceException, e:
    print "Service arm call failed: %s" % e

rospy.wait_for_service('/mavros/set_mode')
try:
    flightModeService = rospy.ServiceProxy('/mavros/set_mode',
                                           mavros_msgs.srv.SetMode)
    #http://wiki.ros.org/mavros/CustomModes for custom modes
    isModeChanged = flightModeService(
        custom_mode='OFFBOARD')  #return true or false
except rospy.ServiceException, e:
    print "service set_mode call failed: %s. GUIDED Mode could not be set. Check that GPS is enabled" % e

act = ActuatorControl()
act.header = Header()
act.controls[0] = 0.0  #ros_roll
act.controls[1] = 0.0  #ros_pitch
act.controls[2] = 0.0 + 0.2  #ros_yaw+offset
act.controls[3] = 0.0  #ros_throttle
act.controls[4] = 0.0
act.controls[5] = 0.0
act.controls[6] = 0.0
act.controls[7] = 0.0

while not rospy.is_shutdown():
    pub_act.publish(act)
    act.controls[2] = 0.0 + 0.2  #ros_yaw+offset
    act.controls[3] = 0.5  #ros_throttle
rate.sleep()