Open JoonmoAhn opened 7 years ago
Hi JoonmoAhn,
I am trying to publish a custom MAVLink message to PX4 and have followed the same steps. I saw your post here and could see that all of my steps are the same. I saw that you could solve your issue.
The only observation between your issue in the link I mentioned and the Manual you posted is generating Mavlink headers in v2.0 instead of v1.0 in the Firmware. On the Mavlink folder in ros workspace, its still v1.0.
Correct me if this is the only change and did this lead to publishing your Mavlink message?
Thanks.
-VS
@visrinivasan Did you follow the steps that I wrote in my previous post?? Several changes were made from that post and my manual. The big changes are
Mavlink ID was changed from 150 to 229 (or could be any other number that is not used by other mavlink messages)
Even though you are using ROS Indigo, you have to install mavlink in Kinetic version.
Even though it uses v1.0 in Mavros, Firmware uses v2.0 for some reason. I tried changing v1.0 files in Firmware, but no errors were made while building firmware, which means Firmware doesn't use v1.0. So, you have to edit your mavlink message in v2.0 for Firmware.
I included my mavlink message in Firmware "common.xml" file instead of making in other "custom_message.xml" file. Then, I had to remove original "common", and "standard" directories. And, mavgenerate new "common" and "standard" directories by "standard.xml". If you only mavgenerate "standard.xml" it automatically makes "common" directory and corresponding mavlink header files also.
After these changes, I could solve the problem. Hope this helps you a little.
@JoonmoAhn thanks for the update. I had everything in place except for using Firmware v2.0.
Got it working now. :)
@JoonmoAhn now that I am receiving my message on nsh, my next step is to visualize this MAVLink message on QGC. Have you tried doing that? I am having some issue trying to connect to QGC and Mavros at the same time. The connection flow I am looking for is: Mavros<-->UDP<-->FCU<-->Telemetry<-->QGC
@visrinivasan @JoonmoAhn In the function send_to_pixhawk() the message type is mavlink_message_t. But I want this message to be sent to custom mavlink message that I have added in the common.xml. How can I achieve this.
@pratyusv did you use the template and follow similar to what @JoonmoAhn has provided above? I am still not sure if I understand your question properly. What is your message ID for your custom message that you added to common.xml (CAUTION: ensure that the ID has not been used by other MAVLINK messages)
@JoonmoAhn I am continuing on a project from a PhD student. His Ground station workspace doesnt seem to have the Mavlink folder which is the last step as outlined. He seems to have had the PixHawk system with Mavros working fine till now. How does one go about this in the case that Mavlink doesnt seem to be there? I just started on this project a week back so I am still catching up on Mavros.
Cheers
@JoonmoAhn This document looks excellent. There has been a request to include it in the PX4 Devguide - https://github.com/PX4/Devguide/issues/806 and update it to ROS melodic.
@hamishwillee Thank you for your compliment. It would be my honor to include my documentation into the PX4 Devguide! However, I haven't been using PX4 for long time, so I can't modify the documentation into up-to-date version of PX4 and ROS. If you are okay, it will be really thankful if you could upload the documentation and modify it into up-to-date version.
Thanks! I've created a PR to pull it in https://github.com/PX4/Devguide/pull/810
Hopefully it will get updated first :-)
Version :
MAVROS installation : Simply follow instruction "Source Installation" from this link Even with ROS Indigo on your computer, just install mavlink in "kinetic" version
MAVROS LEVEL :
Edit "mavros_plugins.xml" in (workspace/src/mavros/mavros_extras). Add following lines.
Edit "CMakeLists.txt" in (workspace/src/mavros/mavros_extras). Add following one line in "add_library".
Inside "common.xml" in (workspace/src/mavlink/message_definitions/v1.0), add your mavlink message as following.
PX4 LEVEL :
Inside "common.xml" in (Firmware/mavlink/include/mavlink/v2.0/message_definitions), add your mavlink message as following. (Just like MAVROS LEVEL step 4)
Remove "common", "standard" directories in (Firmware/mavlink/include/mavlink/v2.0).
Git clone "mavlink_generator" at your home directory (or any directory you want) and execute it.
You will see some little window that is titled "MAVLink Generator".
Then, press Generate!! You will see "common", and "standard" directories made in (/Firmware/mavlink/include/mavlink/v2.0/)
Make your own uORB message file "key_command.msg" in (Firmware/msg). My "key_command.msg" has only
char cmd
in the code. Then, in "CMakeLists.txt" in (Firmware/msg), includeEdit "mavlink_receiver.h" in (Firmware/src/modules/mavlink)
Edit "mavlink_receiver.cpp" in (Firmware/src/modules/mavlink). This is where Px4 receives Mavlink message sent from ROS, and publish it as uORB topic.
-CMakeListst.txt
-key_receiver.cpp
NOW!! You are ready to build all your work!!
Build at ROS :
At your workspace "catkin build".
Beforehand, you have to set your "px4.launch" in (/workspace/src/mavros/mavros/launch). Edit "px4.launch" as below. If you are using USB to connect your computer with Pixhawk, you have to set "fcu_url" as shown below. But, if you are using CP2102 to connect your computer with Pixhawk, you have to replace "ttyACM0" with "ttyUSB0". Modifying "gcs_url" is to connect your Pixhawk with UDP, because serial communication cannot accept Mavros, and your nutshell connection simultaneously.
Write your IP address at "xxx.xx.xxx.xxx"
Build at PX4 :
make px4fmu-v2_default upload
cd Firmware/Tools ./mavlink_shell.py xxx.xx.xxx.xxx:14557 --baudrate 57600