Problem Receiving Attitude Data Over MAVLink

Hey.

First thing, I apologize for bringing up the MAVLink communication problem issue again. I am a newbie, but I have done A LOT of searching for days, and read a lot of threads on this issue. But unfortunately I'm still stuck.

I am trying to receive telemetry data (attitude, altitude & etc.) from a quadrotor equipped with Pixhawk (PX4) in the ground PC in MATLAB software. So far, I have been able to receive heartbeat messages & decode them using MAVLink standard libraries. But when I try to ask Pixhawk to stream the data for attitude for example, I am getting nothing but heartbeat. I am generating the message to request the data like this:

mavlink_msg_request_data_stream_pack(127, 0, &tx_msg,
                        1, 0, MAV_DATA_STREAM_ALL, message_rate, 1);

I am not sure about the SysID (127) & CompID (0) for the ground station. Also, I don't know how to request for attitude & altitude data, MAV_DATA_STREAM types only contain RAW_SENSORS which does not give roll, pitch & yaw angles. I have found MSG_ATTITUDE message type (ID 30), but I don't know how to request it.

I tried connecting through Mission Planner first, Mission Planner requests all types of data, then I disconnect from Mission Planner & start reading the streams in MATLAB. Now I can receive messages other than heartbeat, including MSG_ATTITUDE. I decode the attitude message like this:

if (mavlink_parse_char(chan, InputBuffer[i], &rx_msg, &status))
                        {
                            switch(rx_msg.msgid)
                            {
                                case (0):
                                {
                                    printf("Heartbeat received\n");
                                }
                                case (MAVLINK_MSG_ID_ATTITUDE):
                                {
                                    mavlink_attitude_t attitude;
                                    mavlink_msg_attitude_decode(&rx_msg, &attitude);
                                    printf("roll: %f:\n", attitude.roll);
                                    printf("pitch: %f:\n", attitude.pitch);
                                    printf("yaw: %f:\n\n", attitude.yaw);
                                }

The angles are supposed to be in radians (-pi~pi range) but I'm getting a combination of zeros & large numbers:

roll: 0.000000:
pitch: 0.000000:
yaw: 132252144.000000:

 roll: 119557600.000000:
pitch: -0.000000:
yaw: 0.000000:

roll: 40866207285332089000000000000.000000:
pitch: 0.000000:
yaw: 36575633408.000000:

 roll: -4949342.000000:
pitch: 0.000000:
yaw: 0.000000:

I can't figure out the problem. I would appreciate it if anyone can help me with this, I have been struggling with it for a week...

Thanks

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity