Inspection tool for MAVLINK communication

1,223 views
Skip to first unread message

John Mayer

unread,
Apr 11, 2014, 1:35:15 PM4/11/14
to mav...@googlegroups.com
Hi,
  I came from the web world. I am currently working with drones, mavlink and some industry use-cases. I used both apm-planner and qgroundcontrol and several custom c++ code that communicates with the drone.
  I used the console in qgroundcontrol to see the incoming message from the drone. And in Apm Planner graphs, I see the incoming mavlink messages. Also using my custom C++ program I see what packets are being recieved. I also used the decode() method to see what message is coming.
  My question:
  I wanted to see the other side of the play. How can I see what message is being consumed by the drone? like if i send SetGlobalPositionSetPoint or other mavlink "command" messages, what is the right way to see if it's getting that message? How do we complete the feedback-loop?

Thank u

Meier Lorenz

unread,
Apr 12, 2014, 2:48:46 AM4/12/14
to mav...@googlegroups.com
Hi,

You apparently would need to instrument the drone, and that depends on which drone you’re using.

-Lorenz
--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "MAVLink" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mavlink+u...@googlegroups.com<mailto:mavlink+u...@googlegroups.com>.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

John Mayer

unread,
Apr 13, 2014, 3:41:35 PM4/13/14
to mav...@googlegroups.com
Thanks Lorenz,

I'm using the Pixhawk PX4 board 3DR quadcopter drone. it's this one:

http://cdn3.volusion.com/ptaas.qwpej/v/vspfiles/photos/3DR-Y8-RTF-3.jpg?1395989938

Thank you Lorenz
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mavlink+u...@googlegroups.com<mailto:mavlink+unsu...@googlegroups.com>.

Kevin Hester

unread,
Apr 13, 2014, 4:33:00 PM4/13/14
to mav...@googlegroups.com
Many write operations have corresponding read operations (or at least status messages that are periodically sent from the vehicle).  In Andropilot I made a construct to check for this.  You could do something similar, something approximately like:

mavlinkGuarded(setterFunction, validationFunction, failureFunction, numRetries, retryInterval)

The function you pass in for setter would do the SetGlobalSetPoint (or whatever) and if necessary do the sister 'get' operation.  The validation function would look at your local vehicle model object (to see the change due to the status messages).  The validation function would be run asynchronously every retryInterval.  If it fails numRetries in a row, the failure callback would be invoked to do whatever sort of error handling you need.

I think that one of the 'items on the menu' for a future version of mavlink is a more uniform mechanism for requesting optional acks.


--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "MAVLink" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mavlink+u...@googlegroups.com.

John Mayer

unread,
Apr 13, 2014, 7:48:17 PM4/13/14
to mav...@googlegroups.com, kev...@geeksville.com
Thank you Kevin,
You are right, I was a bit confused about ACK messages. I had that custom code to send ARM command to the UAV and it gave me ACKnowledgement message which was pretty cool. So I was like why is the SET_GLOBAL_POSITION_SETPOINT_INT message not giving me the ACKnowlegement?

So your suggestion is to use GLOBAL_POSITION_SETPOINT_INT ( #52 ) to see if SET_GLOBAL_POSITION_SETPOINT_INT ( #53 ) effectively changed the global set position set point right?
I like the idea. Thanks Kevin.

John


_________________________________________________

Kevin Hester

unread,
Apr 14, 2014, 12:08:07 AM4/14/14
to mav...@googlegroups.com

John Mayer

unread,
Apr 14, 2014, 2:06:49 PM4/14/14
to mav...@googlegroups.com, kev...@geeksville.com
Thanks Kevin, we are on the same page theoretically,
I'm getting all kinds of messages but not the GLOBAL_POSITION_SETPOINT_INT :(

I wrote the following methods

setGlobalPositionSetPoint();
getGlobalPositionSetPoint();


void UAS::setGlobalPositionSetPoint(){

          printf("Sending sample Global Position setpoint **\n");
          mavlink_message_t message;
          mavlink_set_global_position_setpoint_int_t sp;
          sp.latitude = 45000000;
          sp.longitude = 45000000;
          sp.altitude = 10000;
          sp.yaw = 0;
          sp.coordinate_frame = MAV_FRAME_GLOBAL; //can be  MAV_FRAME_GLOBAL or MAV_FRAME_GLOBAL_RELATIVE_ALT

          /* send from system 200 and component 0 */
          mavlink_msg_set_global_position_setpoint_int_encode(200,0,&message, &sp);

          sendMessage(message);
}


void UAS::getGlobalPositionSetPoint(){

          printf("Requesting Global Position setpoint **\n");
           mavlink_message_t message;
          mavlink_global_position_setpoint_int_t sp;
          sp.latitude = 23000000;                                   //I'm confused here. Why should a get/read operation have sp.latitude and sp.longitude specified.
          sp.longitude = 23000000;                                //Shouldn't I just say give me "GlobalPositionSetPoint" and then when i receive I first check if it's message "GlobalPositionSetPoint" and decode it and
          sp.altitude = 10000;                                        //get my lat, lon, alt?      https://pixhawk.ethz.ch/mavlink/#GLOBAL_POSITION_SETPOINT_INT 
          sp.yaw = 0;
          sp.coordinate_frame = MAV_FRAME_GLOBAL; //can be  MAV_FRAME_GLOBAL or MAV_FRAME_GLOBAL_RELATIVE_ALT

          /* send from system 200 and component 0 */
          mavlink_msg_global_position_setpoint_int_encode(200,0,&message, &sp);

          sendMessage(message);
}


And my receive part of the code that reads messages is here. It never gets to this piece of code though


...
 case MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT :
                {
                    printf("Received: MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT \n");
                    mavlink_global_position_setpoint_int_t p;
                    mavlink_msg_global_position_setpoint_int_decode(&message, &p);
                   // emit userPositionSetPointsChanged(uasId, p.latitude, p.longitude, p.altitude, p.yaw);
                    printf("@@ LAT: %d\n", p.latitude);
                    printf("@@ LNG: %d\n", p.longitude);
                    printf("@@ ALT: %d\n", p.altitude);
                }
            break;

...

To enable all messages to come through to my application, I've enabled all data transmission with frequency 5.

enableAllDataTransmission(5);


But still, that MSG_ID_GLOBAL_POSITION_SETPOINT_INT is not coming back.

Am i doing something wrong? Any ideas? insights? recommendations?
I'm working with a Pixhawk board px4 - quadcopter from 3DR, physically connected to my computer via USB cable. I also tried connecting via the radio.

Kevin Hester

unread,
Apr 14, 2014, 3:20:12 PM4/14/14
to mav...@googlegroups.com
For next steps I'd recommend grepping the APM code for GLOBAL_POSITION_SETPOINT to see if a) it has code to handle SET_GLOBAL_POSITION_SETPOINT_INT and b) it has code to send GLOBAL_POSITION_SETPOINT_INT.  

John Mayer

unread,
Apr 15, 2014, 4:55:11 AM4/15/14
to mav...@googlegroups.com, kev...@geeksville.com
Hi Kevin, thanks for the follow up, but I did some inspection on the ArduPilot project. And the GLOBAL_POSITION_SETPOINT  is no where to be found except in header files.

Check the following greps:

user@DE-workstation:~/projects/ardupilot/ardupilot$ grep -R --include="*.inl" "GLOBAL_POSITION_SETPOINT" *
user@DE-workstation:~/projects/ardupilot/ardupilot$ grep -R --include="*.ino" "GLOBAL_POSITION_SETPOINT" *
user@DE-workstation:~/projects/ardupilot/ardupilot$ grep -R --include="*.pde" "GLOBAL_POSITION_SETPOINT" *
user@DE-workstation:~/projects/ardupilot/ardupilot$ grep -R --include="*.c" "GLOBAL_POSITION_SETPOINT" *

I manually checked the project and I think the code that handles or takes a part in handling incoming messages is the commands_logic.pde. and it doesn't have GLOBAL_POSITION_SETPOINT. So may be that's why it was not listening to the SET commands and not replying to GET methods as well. So may be I should write a code that deals with that then... What do you think? Am i in the right way of thinking?

Thanks Kevin

Glenn Gregory

unread,
Apr 15, 2014, 6:54:06 PM4/15/14
to mav...@googlegroups.com
Hi in the GCS_MAVLINK::handleMessage function in
https://github.com/diydrones/ardupilot/blob/master/ArduCopter/GCS_Mavlink.pde
This handles the incoming mavlink messages. If your message ID you are sending is not handled in any of the switch cases then it won't be doing anything with it.
I'm not on a computer but it doesn't look like your msgID is there.

Kevin Hester

unread,
Apr 15, 2014, 7:10:10 PM4/15/14
to mav...@googlegroups.com
Yes.  That makes sense the APM is only partially compliant with the mavlink messages (like most mavlink compliant APs I suspect).  What are you trying to accomplish.  Are you trying to tell the vehicle to go to some position?  If so in APM land that is best accomplished by something like:

Kevin Hester

unread,
Apr 15, 2014, 8:35:12 PM4/15/14
to mav...@googlegroups.com
You might also be interested in this (alpha) toolkit:

Reply all
Reply to author
Forward
0 new messages