Mission Planner and Mavlink

150 views
Skip to first unread message

Ahmet Basri Altay

unread,
Apr 28, 2021, 8:47:24 AM4/28/21
to MAVLink
I want to send the heartbeat signal to Mission planner using STM32 and communicate with mission planner to stm32. What am I supposed to do?

Mrunal Shinde

unread,
Apr 28, 2021, 8:52:25 AM4/28/21
to MAVLink
Are you using a STM32F1 bluepill?

Ahmet Basri Altay

unread,
Apr 28, 2021, 8:54:32 AM4/28/21
to mav...@googlegroups.com
No I am using STM32F411

Mrunal Shinde <shinde.m...@gmail.com>, 28 Nis 2021 Çar, 15:52 tarihinde şunu yazdı:
Are you using a STM32F1 bluepill?


On Wednesday, April 28, 2021 at 6:17:24 PM UTC+5:30 altay...@gmail.com wrote:
I want to send the heartbeat signal to Mission planner using STM32 and communicate with mission planner to stm32. What am I supposed to do?

--
Sie erhalten diese Nachricht, weil Sie in Google Groups ein Thema der Gruppe "MAVLink" abonniert haben.
Wenn Sie sich von diesem Thema abmelden möchten, rufen Sie https://groups.google.com/d/topic/mavlink/yAL_GUZHyik/unsubscribe auf.
Wenn Sie sich von dieser Gruppe und allen Themen dieser Gruppe abmelden 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/4f3939ce-db1a-4f91-9f14-f49a5ca9a7c6n%40googlegroups.com auf.

Mrunal Shinde

unread,
Apr 28, 2021, 8:57:45 AM4/28/21
to MAVLink
Alright . First you need to download the right libraries .You can get them  here : https://mavlink.io/en/getting_started/use_libraries.html
Have you downloaded them?Also what type of data do you want to send to mission planner ? i.e attitude , gps etc specify 

Ahmet Basri Altay

unread,
Apr 28, 2021, 9:06:11 AM4/28/21
to mav...@googlegroups.com
Yeah, I have the right libraries. I want to send pitch, roll, yaw, longitud values etc.

Mrunal Shinde <shinde.m...@gmail.com>, 28 Nis 2021 Çar, 15:57 tarihinde şunu yazdı:
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/f91c1819-6a9f-4272-95f4-d9b0ce3485c7n%40googlegroups.com auf.

Mrunal Shinde

unread,
Apr 28, 2021, 9:22:23 AM4/28/21
to MAVLink
Alright. So after that you need to write a simple code that can receive a mavlink msg from mission planner and parse it. 
i.e tell you what kind of msg it is . 
You can get an example here : https://mavlink.io/en/mavgen_c/
After decoding the msg you need to send it the data that it is requesting .

Ahmet Basri Altay

unread,
Apr 28, 2021, 9:29:20 AM4/28/21
to mav...@googlegroups.com
I have already reviewed the example here, but I could not understand how the recieve process is done and how it is controlled. Can you explain them a little bit for me? Thanks for everything.

Mrunal Shinde <shinde.m...@gmail.com>, 28 Nis 2021 Çar, 16:22 tarihinde şunu yazdı:
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/bea54544-31c5-43f4-8147-da490049eb0cn%40googlegroups.com auf.

Mrunal Shinde

unread,
Apr 28, 2021, 9:46:18 AM4/28/21
to MAVLink
Alright . Ill try actually am not good at explaining .
Ill share my code and explain you through it . So excuse me if i say something wrong.
First you start by initializing and creating objects of the these specific classes . 
Other things you need are system id =1(for  vehicle ) component id=1 (for flight controller) target system id = 255( for mission planner) target component id =1 ( for mission planner )




#include "c_library_v2-master/ardupilotmega/mavlink.h"
mavlink_status_t status;
mavlink_message_t msg;
uint8_t sysid = 1, compid = 1, targetsys_id = 255, targetcomp_id = 1, count = 0;

//initialize serial 
//I am using serial to connect to mission planner and serial1 to debug and read
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial1.begin(115200);
}
void loop() {
  if (Serial.available() > 0)
  {
    while (Serial.available() > 0)
    {
      uint8_t byte = Serial.read();
      if (mavlink_parse_char(chan, byte, &msg, &status))
      {
        Serial1.print("Received message with ID ");
        Serial1.print(msg.msgid);
        Serial1.print(" Serquence :");
        Serial1.print(msg.seq);
        Serial1.print(" from Component:");
        Serial1.print(msg.compid);
        Serial1.print(" of system:");
        Serial1.println(msg.sysid);
        ... DECODE THE MESSAGE PAYLOAD HERE ...
        Serial1.println(mavlink_get_msg_entry(&msg));
      }
    }
  }
}
This will give you the message id that mp is request . 
So once you get the message id you can further decode it by using a switch statement 

switch (msg.msgid)
    {
      case MAVLINK_MSG_ID_REQUEST_DATA_STREAM :
        {
          req_message_rate = mavlink_msg_request_data_stream_get_req_message_rate(&msg);
          target_system = mavlink_msg_request_data_stream_get_target_system(&msg);
          target_component = mavlink_msg_request_data_stream_get_target_component(&msg);
          req_stream_id = mavlink_msg_request_data_stream_get_req_stream_id(&msg);
          start_stop = mavlink_msg_request_data_stream_get_start_stop(&msg);
                    Serial1.print("RDS   ");
                    Serial1.print(req_message_rate);
                    Serial1.print(" ");
                    Serial1.print(target_system);
                    Serial1.print(" ");
                    Serial1.print(target_component);
                    Serial1.print(" ");
                    Serial1.print(req_stream_id);
                    Serial1.print(" ");
                    Serial1.println(start_stop);
       }
}
This is and example to decode the elements of MSGid request_data_stream 
Similiarly you can decode other messages once you get their msg id 

Mrunal Shinde

unread,
Apr 28, 2021, 9:48:31 AM4/28/21
to MAVLink
And also i forgot to include the channel . you need to initialize another variable :
int chan = MAVLINK_COMM_0;
We are using channel 0 to connect to mission planner .

Ahmet Basri Altay

unread,
Apr 28, 2021, 9:51:47 AM4/28/21
to mav...@googlegroups.com
Okey. Thank you so much for everything. I can't work right now but I will examine it as soon as possible. Then I hope we can communicate again. Thank you so much again.


Mrunal Shinde <shinde.m...@gmail.com>, 28 Nis 2021 Çar, 16:46 tarihinde şunu yazdı:
Wenn Sie diese Diskussion im Web verfolgen möchten, rufen Sie https://groups.google.com/d/msgid/mavlink/b79956ce-4d27-454c-b242-9562226cba88n%40googlegroups.com auf.

Mrunal Shinde

unread,
Apr 28, 2021, 9:58:15 AM4/28/21
to MAVLink
Yes surely !

Ahmet Basri Altay

unread,
May 18, 2021, 2:45:15 AM5/18/21
to MAVLink
Hello, have a nice day, I came again.  I tried to use the v2 libraries here   https://mavlink.io/en/mavgen_c/     However, I did not succeed in this and I constantly got errors in .h files.   I use the keil interface and the c language.  I think these are the problems.   and i couldn't figure it out.  Which library and IDE did you use? I wonder if the arduino IDE OR Visual or something different?
28 Nisan 2021 Çarşamba tarihinde saat 16:58:15 UTC+3 itibarıyla shinde.m...@gmail.com şunları yazdı:
Reply all
Reply to author
Forward
0 new messages