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

DIY Robocars via Twitter
RT @gclue_akira: 柏の葉で走行させてるjetracerの中身 #instantNeRF #jetracer https://t.co/giVvuE4hP7
Jul 4
DIY Robocars via Twitter
Cool web-based self-driving simulator. Click save when the AI does the right thing https://github.com/pncsoares/self-driving-car
Jul 4
DIY Robocars via Twitter
RT @donkey_car: Human-scale Donkey Car! Hope this makes it to a @diyrobocars race https://www.youtube.com/watch?v=ZMaf031U8jg
Jun 25
DIY Robocars via Twitter
Jun 25
DIY Robocars via Twitter
Jun 16
DIY Robocars via Twitter
RT @GrantEMoe: I won my first @diyrobocars @donkey_car virtual race! Many thanks to @chr1sa @EllerbachMaxime @tawnkramer and everyone who m…
Jun 13
DIY Robocars via Twitter
RT @gclue_akira: JetRacerで自動走行したコースを、InstantNeRFで再構築。データセットは別々に収集 #jetracer #instantNeRT https://t.co/T8zjg3MFyO
Jun 13
DIY Robocars via Twitter
RT @SmallpixelCar: SPC 3.0 Now the motor also works. This car is doable. I just need to design a deck to mount my compute and sensors. http…
Jun 13
DIY Robocars via Twitter
RT @SmallpixelCar: My new car SPC 3.0. https://t.co/CKtkZOxeNQ
Jun 7
DIY Robocars via Twitter
RT @SmallpixelCar: High speed at @diyrobocars thanks @EdwardM26321707 for sharing the video https://t.co/o4317Y2U1S
Jun 7
DIY Robocars via Twitter
RT @SmallpixelCar: Today at @RAMS_RC_Club for @diyrobocars. Used @emlid RTK GPS and @adafruit @BoschGlobal IMU. Lap time 28s https://t.co/R…
May 28
DIY Robocars via Twitter
May 15
DIY Robocars via Twitter
May 14
DIY Robocars via Twitter
May 13
DIY Robocars via Twitter
RT @f1tenth: Say hi to our newest #F1TENTH creation for @ieee_ras_icra next week in Philly. It’s going to be huge! 😎 🔥 @AutowareFdn @PennEn…
May 13
DIY Robocars via Twitter
May 11
More…