Working with MAVlink messages in ROS without Mavros

from pymavlink import mavutil
from mavros import mavlink
# ip of drone
conn = mavutil.mavlink_connection("tcp:192.168.0.2:5760")
while True:
msg = conn.recv_msg()
rosmsg = mavlink.convert_to_rosmsg(msg)
print(rosmsg)
from pymavlink import mavutil
from mavros import mavlink
# new import!
from pymavlink.dialects.v20.common import MAVLink
# ip of drone
conn = mavutil.mavlink_connection("tcp:192.168.0.2:5760")
while True:
msg = conn.recv_msg()
rosmsg = mavlink.convert_to_rosmsg(msg)
print(rosmsg)
# Now we turn it back
bytes = mavlink.convert_to_bytes(rosmsg)
original_message = conn.mav.decode(bytes)
print(original_message)
from pymavlink import mavutil
from mavros import mavlink
from pymavlink.dialects.v20.common import MAVLink
# ip of drone
conn = mavutil.mavlink_connection("tcp:192.168.0.2:5760")
while True:
msg = conn.recv_msg()
msg.pack(conn.mav) # <----- new line to fix crc issue
rosmsg = mavlink.convert_to_rosmsg(msg)
print(rosmsg)
# Now we turn it back
bytes = mavlink.convert_to_bytes(rosmsg)
original_message = conn.mav.decode(bytes)
print(original_message)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store