ArduPilot / pymavlink

python MAVLink interface and utilities
Other
499 stars 597 forks source link

Send GPS data from vehicle to QGroundControl to display position #515

Open Scarf195 opened 3 years ago

Scarf195 commented 3 years ago

Hi, I need to send GPS data from my vehicle (fully controlled by ROS running on board) to a ground control station like QGC to display its position alongside other vehicles using ArduPilot (PX4).

The ROS running vehicle has not FCU on board like ArduPilot, so I need to create a ROS node that communicates with QGC using pymavlink. Do you know how to do that? I’m having trouble implementing this.

mark-nick-o commented 2 years ago

you can use pymavlink to communicate mavlink either through a direct connection on tcp or via mavlink-router like this to ip 10.0.2.51 in my case the_conection = custommav.mavlink_connection('tcp:10.0.2.51:5760',autoreconnect=True, source_system=id)

or like this via broadcast (can be example mavlink-router) try: the_conection = custommav.mavlink_connection('udpin:0.0.0.0:14550',autoreconnect=True, source_system=id) return the_conection,True except Exception as err_msg: print("Failed to connect : %s" % (err_msg)) return the_conection,False

one message you can use for GPS data is for example is GPS_RAW_INT e.g. the_connection.mav.gps_raw_int_send( 1000, 1, 22, 21, 1, 3, 1, 2, 3, 5)

also GLOBAL_POSITION_INT message.

then use rospy and roslib to bridge this to the ROS node like this link https://habr.com/ru/post/128046/

hope that helps and i didnt misinterpret what you asked and you want to make a bridge in code