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
How to use the new @donkey_car graphical UI to edit driving data for better training https://www.youtube.com/watch?v=J5-zHNeNebQ
yesterday
DIY Robocars via Twitter
RT @SmallpixelCar: Wrote a program to find the light positions at @circuitlaunch. Here is the hypothesis of the light locations updating ba…
Saturday
DIY Robocars via Twitter
RT @SmallpixelCar: Broke my @HokuyoUsa Lidar today. Luckily the non-cone localization, based on @a1k0n LightSLAM idea, works. It will help…
Thursday
DIY Robocars via Twitter
@gclue_akira CC @NVIDIAEmbedded
Nov 23
DIY Robocars via Twitter
RT @luxonis: OAK-D PoE Autonomous Vehicle (Courtesy of zonyl in our Discord: https://discord.gg/EPsZHkg9Nx) https://t.co/PNDewvJdrb
Nov 23
DIY Robocars via Twitter
RT @f1tenth: It is getting dark and rainy on the F1TENTH racetrack in the @LGSVLSimulator. Testing out the new flood lights for the racetra…
Nov 23
DIY Robocars via Twitter
RT @JoeSpeeds: Live Now! Alex of @IndyAChallenge winning @TU_Muenchen team talking about their racing strategy and open source @OpenRobotic…
Nov 20
DIY Robocars via Twitter
RT @DAVGtech: Live NOW! Alexander Wischnewski of Indy Autonomous Challenge winning TUM team talking racing @diyrobocars @Heavy02011 @Ottawa…
Nov 20
DIY Robocars via Twitter
Incredible training performance with Donkeycar https://www.youtube.com/watch?v=9yy7ASttw04
Nov 9
DIY Robocars via Twitter
RT @JoeSpeeds: Sat Nov 6 Virtual DonkeyCar (and other cars, too) Race. So bring any car? @diyrobocars @IndyAChallenge https://t.co/nZQTff5…
Oct 31
DIY Robocars via Twitter
RT @JoeSpeeds: @chr1sa awesomely scary to see in person as our $1M robot almost clipped the walls as it spun at 140mph. But it was also awe…
Oct 29
DIY Robocars via Twitter
RT @chr1sa: Hey, @a1k0n's amazing "localize by the ceiling lights" @diyrobocars made @hackaday! It's consistently been the fastest in our…
Oct 25
DIY Robocars via Twitter
RT @IMS: It’s only fitting that @BostonDynamics Spot is waving the green flag for today’s @IndyAChallenge! Watch LIVE 👉 https://t.co/NtKnO…
Oct 23
DIY Robocars via Twitter
RT @IndyAChallenge: Congratulations to @TU_Muenchen the winners of the historic @IndyAChallenge and $1M. The first autonomous racecar comp…
Oct 23
DIY Robocars via Twitter
RT @JoeSpeeds: 🏎@TU_Muenchen #ROS 2 @EclipseCyclone #DDS #Zenoh 137mph. Saturday 10am EDT @IndyAChallenge @Twitch http://indyautonomouschallenge.com/stream
Oct 23
DIY Robocars via Twitter
RT @DAVGtech: Another incident: https://t.co/G1pTxQug6B
Oct 23
More…