mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
902 stars 993 forks source link

[question] Receiving mavlink msgs via a ros node? #1637

Open dkati opened 3 years ago

dkati commented 3 years ago

Good evening. Actually, i have 2 questions

(1)

Is this possible? i want to read mavlink messages in a cpp ros node but i cant understand a thing...

(i am already flying with offboard mode, cpp waypoints handling etc...)

To be more specific, i want to read the messages that be spawned by

rosrun mavros mavros_node

but also from

make px4_sitl gazebo

I think the msgs from mavros_node can be grabbed from /rosout subscription at 'msg' section (?)


My main goal is to implement a mechanism of "did the mission sending succeded?". (2)

Do i need https://mavlink.io/en/messages/common.html#MISSION_ACK ? if so, i see no example of implementing it

vooon commented 3 years ago

No, that's not possible to get mavlink messages sent by mavros to fcu via ros messages because it talks directly to the device. (well that is possible if you put some proxy, like in mavros 2).

But isn't that enough to check success flag of WaypointPush.srv?

dkati commented 3 years ago
  1. proxy? u mean mavproxy.py ?

  2. "not possible to get mavlink messages sent by mavros to fcu via ros messages". No No.i want the opposite. get the mavlink msgs that goes from fcu to my mavros node...so i can check the ACK of some commands

  3. But isn't that enough to check success flag of WaypointPush.srv? I think no. the boolean that gets returned from MyService.call(); represents the success of TRANSMITTING data to service. it doesnt describe the success/fail of FCU's receive. Correct me if i am wrong

When running make px4_sitl gazebo i see some mavlink messages. that what i want to grab from mavros node.

vooon commented 3 years ago

Ah, messages from fcu can be captured on /mavlink/from. But waypoint plugin handles MISSION_ACK, may resend item, and set failures in case of error.

dkati commented 3 years ago

any example or something for that waypoint plugin?

vooon commented 3 years ago

https://github.com/mavlink/mavros/blob/master/mavros/src/plugins/waypoint.cpp https://github.com/mavlink/mavros/blob/master/mavros/scripts/mavwp

dkati commented 3 years ago

Ah, messages from fcu can be captured on /mavlink/from. echoing the topic i get something like

header: 
  seq: 10602
  stamp: 
    secs: 1634802983
    nsecs: 502280507
  frame_id: ''
framing_status: 1
magic: 253
len: 19
incompat_flags: 0
compat_flags: 0
seq: 248
sysid: 1
compid: 1
msgid: 74
checksum: 31028
payload64: [4493412415915950080, 4622710564961510866, 4554029406788321371]
signature: []

With more research i found out that i have to get that message and convert it to mavlink msg. Printing both msgs i get no "readable string" to parse...i only get that payload64 which i dont know what is

vooon commented 3 years ago

https://github.com/mavlink/mavros/blob/master/mavros_msgs/include/mavros_msgs/mavlink_convert.h https://github.com/mavlink/mavros/blob/master/mavros/src/mavros/mavlink.py