Accessing IMU data through SDK


#1

Hi,

I was wondering if it is possible to access IMU data through the SDK. I am using a Bebop drone and plan to use
IMU data for position estimation. I tried looking around the SDK build but coudnt find anything substantial.

If not through IMU, can I access the IMU data onboard the Parrot Bebop and poll it for my use ?


#2

Hi,

The drone is sending its position, speed and attitude.
In position you have latitude, longitude and altitude.
In speed you have the speed on x, y and z axis.
In attitude you have the roll, pitch, and yaw angles of the drone.

You can access these values by setting the appropriate callback.
In C:

ARCOMMANDS_Decoder_SetARDrone3PilotingStatePositionChangedCallback
ARCOMMANDS_Decoder_SetARDrone3PilotingStateSpeedChangedCallback
ARCOMMANDS_Decoder_SetARDrone3PilotingStateAttitudeChangedCallback

Best regards,
Djavan


Getting Sensor Value
#3

Hello,

I called the callbacks and I received well all the info. However, I would like to access the raw data from the sensors in order to improve the localization performance. Isn’t it possible?

Best Regards,
JDS


#4

Not yet .:wink:
Jerome


#5

Hi guys!

I’ve been trying for a while with the commands and the values are wrong.

Are all these callbacks based on GPS? if so, how can I get the speed based on the downlooking camera (horizontal displacement) and the altitude based on the ultrasound, and how can I get the speed on x,y,z based on accelerometers?

Below is the function in the SDK after extending the callbacks:
<code><pre> void registerARCommandsCallbacks (BD_MANAGER_t *deviceManager) { ARCOMMANDS_Decoder_SetCommonCommonStateBatteryStateChangedCallback(batteryStateChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3PilotingStateFlyingStateChangedCallback(flyingStateChangedCallback, deviceManager); // ADD HERE THE CALLBACKS YOU ARE INTERESTED IN ARCOMMANDS_Decoder_SetCommonCommonStateSensorsStatesListChangedCallback(sensorsStatesListChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3PilotingStatePositionChangedCallback(pilotingStatePositionChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3PilotingStateSpeedChangedCallback(speedChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3PilotingStateAttitudeChangedCallback(attitudeChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3PilotingStateAltitudeChangedCallback(altitudeChangedCallback, deviceManager); //ARCOMMANDS_Decoder_SetARDrone3GPSSettingsStateGPSUpdateStateChangedCallback(gpsStateChangedCallback, deviceManager); ARCOMMANDS_Decoder_SetARDrone3GPSSettingsStateGPSFixStateChangedCallback(gpsFixStateChangedCallback, deviceManager); //ARCOMMANDS_Decoder_SetARDrone3GPSStateNumberOfSatelliteChangedCallback(gpsNumberOfSatelliteChangedCallback, deviceManager); } </pre></code>
Howeve, I’m getting the following:

While Landing:

While hovering:

And here is the implementation of the callbacks:
`


void IHM_PrintPosition(IHM_t *ihm, double latitude, double longitude, double altitude)
{
if (ihm != NULL)
{
move(POSITION_Y, 0);
clrtoeol();
mvprintw(POSITION_Y, POSITION_X, “Latitude: %d, Longitude: %d, Altitude: %d”, latitude, longitude, altitude);
}
}

void IHM_PrintSpeed(IHM_t *ihm, float speedX, float speedY, float speedZ)
{
if (ihm != NULL)
{
move(SPEED_Y, 0);
clrtoeol();
mvprintw(SPEED_Y, SPEED_X, “SpeedX: %d, SpeedY: %d, SpeedZ: %d”, speedX, speedY, speedZ);
}
}

void IHM_PrintAttitude(IHM_t *ihm, float roll, float pitch, float yaw)
{
if (ihm != NULL)
{
move(ATTITUDE_Y, 0);
clrtoeol();
mvprintw(ATTITUDE_Y, ATTITUDE_X, “roll: %d, pitch: %d, yaw: %d”, roll, pitch, yaw);
}
}

void IHM_PrintAltitude(IHM_t *ihm, double altitude)
{
if(ihm != NULL)
{
move(ATTITUDE_Y, 0);
clrtoeol();
mvprintw(ALTITUDE_Y, ALTITUDE_X, “Altitude: %d”, altitude);
}
}

void IHM_PrintGPSState(IHM_t *ihm, uint8_t nos)
{
if(ihm != NULL)
{
move(GPS_Y, 0);
clrtoeol();
mvprintw(GPS_Y, GPS_X, “GPS Status: %d”, nos);
}
}

void IHM_PrintGPSFix(IHM_t *ihm, uint8_t fix)
{
if(ihm != NULL)
{
move(GPS_Y-1, 0);
clrtoeol();
mvprintw(GPS_Y-1, GPS_X, “GPS Fix: %d”, fix);
}
}

`


#6

Hi @HDaoud,

It seems that you’re messing up with print formats.

To print doubles and floats, you should write %f
Also, the IHM_PrintAltitude functions uses calls move(ATTITUDE_Y, 0); instead of ALTITUDE_Y.

Hope this helps,
Djavan


#7

Dear Djavan,

Thanks, it worked :smile: :relieved:

however, seems to be some delay, also the values fluctuates a lot. I need to work on that to filter wrong values and figure out the delay, is there something that is already implemented in this regard? Like time stamps for frames and IMU values,…etc.

ALTITUDE_Y is my bad! :sweat_smile: Thanks for the catch.


#8

Dear @Djavan and @Jerome,

Any updates on the access of raw IMU data?

When Bebop onground, the roll, pitch, and yaw always fluctuates between -2, and 2.

When hovering and flying, this continues also, the x,y,z speeds are always either 2 or -2!

Is there a way to get good measurements from the onboard IMU sensor? Do you recommend buying IMU and installing separately to get raw and accurate data?

Thank you!
Hayyan


#9

Hi,
Are you reading them correctly? As double?

You can find here code extracts.

Regards,
Djavan


#10

Hi @Djavan

Yes I’m reading and writing them as float:

void attitudeChangedCallback(float roll, float pitch, float yaw, void *custom)
{
BD_MANAGER_t *deviceManager = (BD_MANAGER_t *)custom;

if (deviceManager != NULL)
{
    deviceManager->dataAttitude.roll = roll;
    deviceManager->dataAttitude.pitch = pitch;
    deviceManager->dataAttitude.yaw = yaw;
    
    if(deviceManager->ihm != NULL)
    {
        IHM_PrintAttitude(deviceManager->ihm, roll, pitch, yaw);
    }
} 

}
void > IHM_PrintAttitude(IHM_t *ihm, float roll, float pitch, float yaw)
{
if (ihm != NULL)
{
move(ATTITUDE_Y, 0);
clrtoeol();

    if(roll < -100 || roll > 100) roll = 0;
    if(pitch < -100 || pitch > 100) pitch = 0;
    if(yaw < -100 || yaw > 100) yaw = 0;
    
    mvprintw(ATTITUDE_Y, ATTITUDE_X, "roll: %.3f, pitch: %.3f, yaw: %.3f", roll, pitch, yaw);
}

}

Is it different with the new way?

Thanks!


#11

I changed float to double and it’s working now! although float is the default in SDK, also in the link you provided it uses float as well.

Why it didn’t work?

Thank you!