Hello everyone,
This is my first post in this forum.I have been trying to retrieve the attitude message form pixhawk using Message_Interval package but failed to receive it .I am using ArduCopter firmware(version 3.5xx) for pixhawk .
Here the source code :-
#include “mavlink.h”
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 7); // RX, TX
unsigned long previousMillisMAVLink = 0;
unsigned long next_interval_MAVLink = 1000;
const int num_hbs = 1;
int num_hbs_pasados = num_hbs;
void comm_receive()
{
mavlink_message_t msg;
mavlink_status_t status;
while(mySerial.available()>0)
{
uint8_t c = mySerial.read();
Serial.println©;
}
}
void setup()
{
mySerial.begin(57600);
Serial.begin(57600);
}
// Loop your program
void loop()
{
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
unsigned long currentMillisMAVLink = millis();
if (currentMillisMAVLink - previousMillisMAVLink >= next_interval_MAVLink)
{
previousMillisMAVLink = currentMillisMAVLink;
num_hbs_pasados++;
if(num_hbs_pasados>=num_hbs)
{
Mav_Request_Data();
Serial.println(“send”);
num_hbs_pasados=0;
}
}
comm_receive();
}
void Mav_Request_Data()
{
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
const uint16_t MAVStreamID= 30;
const uint32_t MAVRates = 511;
mavlink_msg_message_interval_pack(2, 0, &msg,MAVStreamID,MAVRates);
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
mySerial.write(buf, len);
Serial.println("…");
Serial.println(buf[0]);
Serial.println(buf[1]);
Serial.println(buf[2]);
Serial.println(buf[3]);
Serial.println(buf[4]);
Serial.println(buf[5]);
Serial.println(buf[6]);
Serial.println(buf[7]);
Serial.println(buf[8]);
Serial.println(buf[9]);
Serial.println(buf[10]);
Serial.println(buf[11]);
Serial.println(buf[12]);
Serial.println(buf[13]);
Serial.println("…");
}
I am using c_library_v1 library for mavlink protocol .I can see the heartbeat packet after every 1 sec
and sometime it shows the message ID 22 (PARAM_VALUE) .
(highlight line shows the heartbeat package)
(highlight line shows the param value package)
I try to debug it further and try to see transmit packet from arduino . However i don’t find any problem in transmit packet
The payload data contains correct streamrate(i.e 511) and message_id(i.e 30)
Can anyone explain what is mistake i am doing while retrieving the data?