Hi All,
I was recently fiddling around the code for a while and decided to create a tutorial out of it so that others may find it useful. If I would have known this knowledge long back, I am sure I would have saved a lot of time since then! I find lot of beginners getting swayed and lack of knowhow on MavLink with respect to APM/PX4. Information on internet is scattered and not much of use!!
This will be "Step by Step" entertaining, PART - I of the series I plan to write.on:
What it Covers:
- MavLink, starting from scratch. What the hell is it and understand how it works with APM/ PX4
- Learn how developers think -> Arducopter communication with Mission Planner and vice-versa.
- Get a feel of 'How Stuffs works'.
Too much hype:) Well, this information has been collated from my experience and from internet. I know there is information on the new Wiki, it tells you what, I plan to tell you 'how'! :)
Please let me know if you found it interesting. If there is enough response, I will make another tutorial where I would add more 'Step by step' knowhow!!
Options:
- More on MavLink
- Learning Arducopter source code, Step by Step
- Making swarm (multiple) copters work with your 3DR Telemetry radio! I am working on it.
See attachment for [MAVLink Tutorial for Absolute Dummies (Part –I)]
Edit: Request you to post your queries over the forum directly, as it is not possible for me to address all queries I get by email!
--
Best regards,
Shyam
Replies
Hi Juraj,
Have you tried using qgroundControl first? This might be an alternate to using Mission Planner. You just have to establish connection with the GCS on your computer and it will auto list all the commands coming in from the APM and going to the APM (if you have edited something on your own).
If I understand correctly, you said "We want to achieve the same functionality". So, it must be already working on APM and GCS, and its just that you are trying to use/ construct your own GCS software?
From what I understand, the problem isn't on the APM side, rather on the GCS software side you are building. The commands must just flow in. My suggestion would be to debug.write the stream of commands coming in and write it to a text file for you to analyze. Using APM 2.5/ 2.6 etc for MavLink should not matter, because this is something in software and not hardware.
Regards..
Thanks, I am trying to learn more! Blue Skies!
Hi Hassanayoub85,
Here is what I find from mavlink_types.h file.
#define MAVLINK_CORE_HEADER_LEN 5 ///< Length of core header (of the comm. layer): message length (1 byte) + message sequence (1 byte) + message system id (1 byte) + message component id (1 byte) + message type id (1 byte)
#define MAVLINK_NUM_HEADER_BYTES (MAVLINK_CORE_HEADER_LEN + 1) ///< Length of all header bytes, including core and checksum
#define MAVLINK_NUM_CHECKSUM_BYTES 2
#define MAVLINK_NUM_NON_PAYLOAD_BYTES (MAVLINK_NUM_HEADER_BYTES + MAVLINK_NUM_CHECKSUM_BYTES)
#define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) ///< Maximum packet length
You would find from the above that the "Length of all header bytes" amounts to 6 bytes. As per the tutorial I wrote, each MavLink packet has a size of 6 bytes for the header, which includes the start byte. I didn't get the time to search 0xFE in the code, I am sure it is hiding somewhere ;)
If it incorporates byte memory for this byte then it ought to be getting generated somewhere. I am sorry currently, i am not having access to code as i am on a travel. Hopefully i can be of some help when i am back, if you still haven't figured out.
Regards,
Shyam
Hi Phoenix,
Sorry for the late response. I do not know if you have already solved the issue by now.
As far as I remember, I had some trouble compiling that piece of code on qgroundcontrol's website, but was eventually able to compile the code (had to make minor changes in header file locations).
Also, make sure you have the MavLink header file accessible and that is where I remember I got one of the compile errors. Can you share what error you got?
Regards,
Shyam
Hi Phonix,
If you are just starting out with a secondary controller, it might be good to use a beaglebone or Raspberry Pi as there is a lot of support there for it. I have tried it on the Rpi and it would work well.
However, I didn't get your point when you said 'too slow'. What do you find as slow?
PS: I am sorry for the late reply, as I have been more on travel nowadays.
Regards..
From what I understand, you wish to know how to edit the C# GUI to edit your commands. For this, it would be helpful if you/ your friends have worked in C#/ Visual Studio. You will need to add an extra dropdown for example, to choose your options from which gets sent to the board either in real time or during sending settings to the EEPROM on-board memory.
You also would need to introduce some code into Ardupilot, mainly GCS_Mavlink.pde to have your custom commands work in real time. I have PM you my Skype ID. I can help you, if you may have specific questions.
- Shyam
Hi Marcin,
Thank you for the comments. 1 months seems less to develop something by yourself when you are just getting started. I have some questions and then suggestions for you:
- Its fine to have a WPF C# app, but I assume you want it to be a desktop application. Why not use/ reuse Mission planner. AFAIK, it is not written in WPF but pure C#. Would you want to make use of that? If you need some coding help in C# (Mission planner) / C++ (Ardupilot) you can PM me.
- You can remove some of the tabs (like DataFlash/ Mission WP planning/ Settings Config, etc) in the Mission Planner C# application. Use Visual Studio 2012, to compile the code first and simply remove the additional tab pages (under Tab Control) in the User Design GUI form. This way you can work out to get what you want (Throttle, Pitch, etc) values are sent to and fro via the MavLink protocol.
Hope this helps to get a direction.
Regards,
Shyam
@Marcin,
You have to use Visual Studio 2012 and build it with less trouble. You can use VS 2010, but you might face a whole chunk of assembly mismatch and will be time consuming. It is better to have original VS 2012, get a download from Microsoft website or if you want to get a cracked version of it you are free to do so (but I won't recommend that on a public forum :)
AFAIK, the answer to your question is No. There is no cropped version of MP (for a desktop application built in C#). You can use QGroundControl, etc. But, if you were to build MP yourself on your Windows PC, I would simply go and remove the DataLogger, Flight Planning page, Settings etc that you don't need by just removing the tab pages from the UserControl form GUI - and boom its done - no rocket science there. You don't add or remove code directly to make it light weight, just delete what you don't want.. This makes it comfortable light for your use.
-
2
-
3
-
4
-
5
-
6
of 6 Next