C# Example using MAVLink.dll

2,934 views
Skip to first unread message

David Turpin

unread,
Jan 23, 2020, 5:54:36 PM1/23/20
to MAVLink
Hello!

I'm trying to create support for MAVLink in C# and ultimately Unity. I grabbed a DLL via NuGet but quickly realized it was more bare-bones than what I was expecting.

So, I took a look at the source code to Mission Planner, which, as far as I can tell, is the only publicly-available working example of a MAVLink/C# integration. Unfortunately, that project is quite complex and not written very modularly. I started trying to isolate only the pieces I need, but there were so many dependencies and interdependencies that, after a while, I started looking for other options. Do you guys know anything I can take a look at?

What I'm ultimately trying to get is a fairly self-contained piece of code that includes the MAVLink DLL as well as as the necessary C# needed to run it. I have lots of familiarity with C# and some with .NET Sockets, but when it comes to MAVLink I'm very much a beginner. So, all I really need are some examples or guidance.

Thanks!
-David

P.S. I was intrigued when someone pointed me to the MAVLinkSDK CSharp Project, but after investigating I realized it also didn't work out of the box, and the website makes no mention of it. So, I'm a bit stumped on that one -- perhaps I need someone more experienced with MAVLink to explain to me how I would go about using that.




james pattison

unread,
Jan 23, 2020, 6:01:09 PM1/23/20
to mav...@googlegroups.com
Perhaps have a look at https://github.com/ArduPilot/pymavlink/pull/322

Regards,

James 

On 24 Jan 2020, at 9:54 am, David Turpin <dhtu...@gmail.com> wrote:


--
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.
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/ced7e229-b2c2-493e-b4be-284edeabb3ac%40googlegroups.com auf.

David Turpin

unread,
Jan 23, 2020, 6:09:36 PM1/23/20
to MAVLink
Thanks James. I don't think I need any code generation for this, though, right? I already have a working DLL of MAVLink 1. Perhaps I'm misunderstanding something...


On Thursday, January 23, 2020 at 3:01:09 PM UTC-8, james pattison wrote:
Perhaps have a look at https://github.com/ArduPilot/pymavlink/pull/322

Regards,

James 

On 24 Jan 2020, at 9:54 am, David Turpin <dhtu...@gmail.com> wrote:


Hello!

I'm trying to create support for MAVLink in C# and ultimately Unity. I grabbed a DLL via NuGet but quickly realized it was more bare-bones than what I was expecting.

So, I took a look at the source code to Mission Planner, which, as far as I can tell, is the only publicly-available working example of a MAVLink/C# integration. Unfortunately, that project is quite complex and not written very modularly. I started trying to isolate only the pieces I need, but there were so many dependencies and interdependencies that, after a while, I started looking for other options. Do you guys know anything I can take a look at?

What I'm ultimately trying to get is a fairly self-contained piece of code that includes the MAVLink DLL as well as as the necessary C# needed to run it. I have lots of familiarity with C# and some with .NET Sockets, but when it comes to MAVLink I'm very much a beginner. So, all I really need are some examples or guidance.

Thanks!
-David

P.S. I was intrigued when someone pointed me to the MAVLinkSDK CSharp Project, but after investigating I realized it also didn't work out of the box, and the website makes no mention of it. So, I'm a bit stumped on that one -- perhaps I need someone more experienced with MAVLink to explain to me how I would go about using that.




--
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 mav...@googlegroups.com.

David Turpin

unread,
Jan 23, 2020, 6:16:38 PM1/23/20
to MAVLink
Here's the correct link to the MAVLink SDK CSharp Project (I had it wrong in my original post): https://github.com/mavlink/MAVSDK-CSharp

james pattison

unread,
Jan 23, 2020, 7:56:26 PM1/23/20
to mav...@googlegroups.com
The DLL is probably fine if it’s documented. I’d suggest mavlink2 over mavlink1, so you don’t lose all the recent functionality.
Re the SDK: depending on your end use case, it may not be suitable at all.
The mavsdk is not mavlink generic: it’s hardcoded to PX4, and only includes the common.xml mavlink dialect.
So apart from being immature, unless you are only targeting PX4, it’s currently useless.

Regards,

James 

On 24 Jan 2020, at 10:16 am, David Turpin <dhtu...@gmail.com> wrote:


--
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.
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/5452d28c-e365-4917-ab0c-50c00607f308%40googlegroups.com auf.

markbr...@gmail.com

unread,
Jan 23, 2020, 8:15:37 PM1/23/20
to mav...@googlegroups.com

Perhaps it would be helpful to clarify the gap between ‘bare bones’ ( https://github.com/mavlink/MAVSDK-CSharp/tree/master/MAVSDK-CSharp ) and what you are looking for. What features do you need?

 

  • Mark West

Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/AFA624D8-527A-4306-A22C-1E058E6EA4AC%40gmail.com auf.

Michael Oborne

unread,
Jan 24, 2020, 2:14:40 AM1/24/20
to mav...@googlegroups.com
I can give some guidance to that NuGet package, in a few days. 

In the mission planner repo there is a sample project that uses it

Michael

--
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.
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/ced7e229-b2c2-493e-b4be-284edeabb3ac%40googlegroups.com auf.

Michael Oborne

unread,
Jan 24, 2020, 2:18:55 AM1/24/20
to mav...@googlegroups.com

David Turpin

unread,
Jan 24, 2020, 3:11:55 AM1/24/20
to MAVLink
Michael thank you so much!! I think this is exactly what I'm looking for if I can get it to work. When I run it, it is unable to detect any SerialPorts I can use to connect.

Annotation 2020-01-24 000701.png


I don't know how SerialPorts are supposed to work. In MissionPlanner, you don't select a port, you simply enter the IP of the ground station along with the port number 14550, and it automatically figures it out. Here, if I try to do that, the app crashes here:

crash.png

I've started digging into the MissionPlanner source code for answers, but if you have any clues that could help point me in the right direction, I would be much obliged!
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mav...@googlegroups.com.

David Turpin

unread,
Jan 24, 2020, 1:36:20 PM1/24/20
to MAVLink
To clarify, we are trying to connect to a ground station (router) via UDP, which is connected wirelessly to a Pixracer which is generating the telemetry data. It seems that the SimpleExample project has code for doing UDP connection, but it's not being used in the main loop in simpleexample.cs
Reply all
Reply to author
Forward
0 new messages