Hi Everyone,
Looking to find out exactly what was modified in the CF firmware to enable the crazyflie to fly with the deck upside down.
Here is the topic. I cannot see the part of the code that arnaud points to as it is a broken link.
viewtopic.php?t=1784
Furthermore, the user YARO states that "I'm here again! I've solved this problem, I was not correctly changing sings and not in the right place. " However he does not go into detail as to what he was changing...
I am a complete newbie when it comes to using eclipse and modifying firmware. pretty familiar with arduino IDE so I that is a start.
I have PMed YARO with this thread, but it was almost 4 years ago now, so alot has probably changed in the firmware I imagine.
Thanks for the help.
Joe
IMU Sensor Upside down (specific lines to modify)
-
- Member
- Posts: 83
- Joined: Mon Jun 18, 2018 2:37 am
-
- Member
- Posts: 83
- Joined: Mon Jun 18, 2018 2:37 am
Re: IMU Sensor Upside down (specific lines to modify)
bump,
cheers
joe
cheers
joe
-
- Member
- Posts: 83
- Joined: Mon Jun 18, 2018 2:37 am
Re: IMU Sensor Upside down (specific lines to modify)
Hey everyone,
have done a little more investigation. And have tried to change the power distribution function. I think we are close. we have tried many different variations with varying results, sometimes it flips over sometimes it takes of and crashes seconds after it tried to correct pitch or roll.
Here is the latest attempt. from power_distribution_stock.c
The questions I have are...
[1] What would be the correct hardware configuration for this inversion?
- do the polarity of the motors neet to be inverted?
-does the A and B props have to stay on their respective arms after the deck is flipped (eg A stays with M4 and M2, Bstays with M3 and M1) This is what we are finding gets the thing off the ground.
[2] we have tried to work out the power distribution function as above? are we doing this right? See attched picture
[3] does anything else need to change in the code?
[4]
i also noticed this on line 276 in sensefusion6.c
does this have anything to do with the problem I am having?
[5] i eventuall want this to work with the qualisys system, I was wonderig if i had to invert the axis there as well. But I am pretty sure nothing has to happen in the qualisys tab of the client. this is just a firmware thing.
have done a little more investigation. And have tried to change the power distribution function. I think we are close. we have tried many different variations with varying results, sometimes it flips over sometimes it takes of and crashes seconds after it tried to correct pitch or roll.
Here is the latest attempt. from power_distribution_stock.c
Code: Select all
void powerDistribution(const control_t *control)
{
#ifdef QUAD_FORMATION_X
int16_t r = control->roll / 2.0f;
int16_t p = control->pitch / 2.0f;
motorPower.m1 = limitThrust(control->thrust + r + p + control->yaw);
motorPower.m2 = limitThrust(control->thrust + r - p + control->yaw);
motorPower.m3 = limitThrust(control->thrust - r - p - control->yaw);
motorPower.m4 = limitThrust(control->thrust - r + p - control->yaw);
[1] What would be the correct hardware configuration for this inversion?
- do the polarity of the motors neet to be inverted?
-does the A and B props have to stay on their respective arms after the deck is flipped (eg A stays with M4 and M2, Bstays with M3 and M1) This is what we are finding gets the thing off the ground.
[2] we have tried to work out the power distribution function as above? are we doing this right? See attched picture
[3] does anything else need to change in the code?
[4]
i also noticed this on line 276 in sensefusion6.c
Code: Select all
*pitch = asinf(gx) * 180 / M_PI_F; //Pitch seems to be inverted
[5] i eventuall want this to work with the qualisys system, I was wonderig if i had to invert the axis there as well. But I am pretty sure nothing has to happen in the qualisys tab of the client. this is just a firmware thing.
Re: IMU Sensor Upside down (specific lines to modify)
I gave it a quick shot and it this worked.
Flip the IMU. I did this in the sensor reading acc,gyro function and to keep right hand rule I flipped not only Z but Y as well.
Then since it is now up-side-down I flipped M1.M4 and M2,M3 in power distribution
Flip the IMU. I did this in the sensor reading acc,gyro function and to keep right hand rule I flipped not only Z but Y as well.
Code: Select all
void processAccGyroMeasurements(const uint8_t *buffer)
...
sensorData.gyro.x = -(gyroRaw.x - gyroBias.x) * SENSORS_DEG_PER_LSB_CFG;
sensorData.gyro.y = -(gyroRaw.y - gyroBias.y) * SENSORS_DEG_PER_LSB_CFG;
sensorData.gyro.z = -(gyroRaw.z - gyroBias.z) * SENSORS_DEG_PER_LSB_CFG;
applyAxis3fLpf((lpf2pData*)(&gyroLpf), &sensorData.gyro);
accScaled.x = -(accelRaw.x) * SENSORS_G_PER_LSB_CFG / accScale;
accScaled.y = -(accelRaw.y) * SENSORS_G_PER_LSB_CFG / accScale;
accScaled.z = -(accelRaw.z) * SENSORS_G_PER_LSB_CFG / accScale;
...
}
Code: Select all
void powerDistribution(const control_t *control)
{
...
motorPower.m4 = limitThrust(control->thrust - r + p + control->yaw);
motorPower.m3 = limitThrust(control->thrust - r - p - control->yaw);
motorPower.m2 = limitThrust(control->thrust + r - p + control->yaw);
motorPower.m1 = limitThrust(control->thrust + r + p - control->yaw);
...
-
- Member
- Posts: 83
- Joined: Mon Jun 18, 2018 2:37 am
Re: IMU Sensor Upside down (specific lines to modify)
This worked brilliantly thank you!
-
- Member
- Posts: 83
- Joined: Mon Jun 18, 2018 2:37 am
Re: IMU Sensor Upside down (specific lines to modify)
This works brilliantly on CF 2.0s but not CF 2.1 is there something I missed?
Re: IMU Sensor Upside down (specific lines to modify)
The 2.1 uses another IMU (BMI088) and flipping the IMU axis was done in the driver (could have been made higher up) so this needs to be done in the sensors_bmi088_bmp388.c for the CF2.1
Code: Select all
static void sensorsTask(void *param)
{
...
/* Gyro */
sensorData.gyro.x = (gyroRaw.x - gyroBias.x) * SENSORS_BMI088_DEG_PER_LSB_CFG;
sensorData.gyro.y = -(gyroRaw.y - gyroBias.y) * SENSORS_BMI088_DEG_PER_LSB_CFG;
sensorData.gyro.z = -(gyroRaw.z - gyroBias.z) * SENSORS_BMI088_DEG_PER_LSB_CFG;
applyAxis3fLpf((lpf2pData*)(&gyroLpf), &sensorData.gyro);
/* Acelerometer */
accScaled.x = accelRaw.x * SENSORS_BMI088_G_PER_LSB_CFG / accScale;
accScaled.y = -accelRaw.y * SENSORS_BMI088_G_PER_LSB_CFG / accScale;
accScaled.z = -accelRaw.z * SENSORS_BMI088_G_PER_LSB_CFG / accScale;
sensorsAccAlignToGravity(&accScaled, &sensorData.acc);
applyAxis3fLpf((lpf2pData*)(&accLpf), &sensorData.acc);
...