Hi there, I'm currently working on a project that will let allow to UGV and UAV to work together on several tasks. The first thing we have to accomplish is wireless communication between the UGV and UAV. For this we have chosen to utilize mavlink messages and send over the 3DR radios. The UGV will be run off of a linux computer and so I'm trying to write some code to send our own mavlink messages over the radio. Currently, I am testing the system by plugging both ends of the radio into the linux computer. However, I am having some trouble sending the mavlink messages over the radio link. 

I am using the sample code found on this link. http://pixhawk.org/dev/offboard_communication

Basically there are 2 programs, send_quad_commands and mavlink_serial. send_quad_commands opens up serial communication to the radio and tries to send the mavlink message set_quad_swarm_roll_pitch_yaw_thrust. mavlink_serial is looking for incoming messages from the radio. As soon as a message is detected, it reads in the first byte and passes it to mavlink_parse_char(). If we message can be decoded, it should return true and the program continues to collect the data from the message. However, I can not get mavlink_parse_char() to return true. 

if (read(fd, &cp, 1) > 0) {
   // Check if a message could be decoded, return the message in case yes
   msgReceived = mavlink_parse_char(MAVLINK_COMM_1, cp, &message, &status);

Above are the lines of code I am referencing. I've also attached the code for mavlink_serial and send_quad_commands so you can see the entire thing. 

The radios are definitely sending messages across the link and the radio on the other end is receiving messages, but none of the messages are being verified by mavlink_parse_char(). I am not sure if this is a problem with transmission of the data, receiving the data, or the radios corrupting the message. 

Does anyone have any clue as to what our problem could be? Any help or advice on this subject would be much appreciated. Thanks!

Views: 890

Attachments:

Reply to This

Replies to This Discussion

That should work. I has something similar (code wise) working several times and it was not like flawed or anything.

Maybe see if MAVProxy can be used to trace messages. Else I would try log all the incoming binary data to a file, and see with a hex editor that the basic packet structure can be identified - starting with FE, having the right length etc.

And check the baud rates first :)

Regards

Soren

Thanks for the tips. The problem is definitely not in our baud rates. We were able to look at the binary data and found the FE heading. However, when it is passed into mavlink_parse_char(), it will not return that the packet is valid. Would you mind letting us see the portion of your code that handles incoming messages? 

Thanks again!

Hi Elmer,

a quick look at your code shows that there is a minor issue with the way you are decoding the message. In the file that you attached, mavlink_serial.cpp line 319, you are working on the case where the message is of type MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST, but you are using imu structure and imu decoder to do the message decoding. I believe that you should have to use the respective struct for that message. I think it's in common/mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h

If this resolved your issue, please mark it as so.

Best

Hi, I'm new to using the Pixhawk on UAVs and I was having some trouble sending data over the 3DR telemetry radios. This is a basic question so please bear with me as I really want understand how to effectively use the pixhawk and this post looks helpful.

I'm using the Pixhawk and the PX4 Firmware (only, No ardupilot code) and I want to send information (such as GPS) over the telemetry radios to view it on a TeraTerm console. I've looked through the mavlink_serial.cpp and send_quad_commands.cpp and I have a high level understanding but I still have questions

1) I see that send_quad_commands has a "send_serial" function, Do I need to make my own function to send GPS(or any other data)?

2) Is there an example that goes through the steps of opening the serial port, setting up the port, sending data and closing the port?

If there is basic example with this information that would be helpful.

Again I'm new to this so I apologize if I'm asking questions that have already been asked and solved.

Thanks for your help!

Reply to Discussion

RSS

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service