mavros icon indicating copy to clipboard operation
mavros copied to clipboard

[question] Receiving mavlink msgs via a ros node?

Open dkati opened this issue 3 years ago • 7 comments

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

dkati avatar Oct 20 '21 11:10 dkati

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?

vooon avatar Oct 20 '21 14:10 vooon

  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.

dkati avatar Oct 20 '21 17:10 dkati

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.

vooon avatar Oct 20 '21 18:10 vooon

any example or something for that waypoint plugin?

dkati avatar Oct 20 '21 19:10 dkati

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

vooon avatar Oct 20 '21 19:10 vooon

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

dkati avatar Oct 21 '21 08:10 dkati

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

vooon avatar Oct 21 '21 09:10 vooon