Skip to content

Instantly share code, notes, and snippets.

@sfalexrog
Created February 3, 2020 16:05
Show Gist options
  • Save sfalexrog/dc4394310293a074f8b879e0d5a5f988 to your computer and use it in GitHub Desktop.
Save sfalexrog/dc4394310293a074f8b879e0d5a5f988 to your computer and use it in GitHub Desktop.
Read and print thrust using mavros and MAVLink
from __future__ import print_function
import rospy
from mavros import mavlink
from pymavlink import mavutil
from mavros_msgs.msg import Mavlink
rospy.init_node('thrust_read')
link = mavutil.mavlink.MAVLink('', 255, 1)
def mavlink_message_handler(msg):
if msg.msgid == 140:
mav_bytes_msg = mavlink.convert_to_bytes(msg)
mav_msg = link.decode(mav_bytes_msg)
print(mav_msg.controls[3])
mavlink_sub = rospy.Subscriber('mavlink/from', Mavlink, mavlink_message_handler)
rospy.spin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment