I'd like to replace imu of ardupilot mega 2.5 by another rs232 imu. Can you help me?
Hello, everyone
I'm new here. I'm stay in Thailand (asia).
I'd like to replace imu of ardupilot mega 2.5 by another rs232 imu. Can you help me?
I've a questions. Where are variable -> roll, pitch, yaw that I can replace for my new imu.
I don't know where to replace or force the variable for my new imu.
-------------------------------------------------------------------------------------------------------------
At first i try to edit the value from AP_AHRS library.
in AP_AHRS_MPU6000.cpp
...
AP_AHRS_MPU6000::euler_angles(void)
{
//_dcm_matrix.to_euler(&roll, &pitch, &yaw);
--> force roll as 0.785 rad or 45 degree _dcm_matrix.to_euler(0.785, &pitch, &yaw);
// cannot use this because the quaternion is not correct for yaw drift
//quaternion.to_euler(&roll, &pitch, &yaw);
roll_sensor = degrees(roll) * 100;
--> force pitch as 45 degree pitch_sensor = 450;
yaw_sensor = degrees(yaw) * 100;
if (yaw_sensor < 0)
yaw_sensor += 36000;
}
...
and in another file
APM_AHRS_DCM.cpp
...
AP_AHRS_DCM::euler_angles(void)
{
//_dcm_matrix.to_euler(&roll, &pitch, &yaw);
--> force roll as 0.785 rad or 45 degree _dcm_matrix.to_euler(0.785, &pitch, &yaw);
roll_sensor = degrees(roll) * 100;
--> force pitchas 45 degree pitch_sensor = 450;
yaw_sensor = degrees(yaw) * 100;
if (yaw_sensor < 0)
yaw_sensor += 36000;
}
...
Then I burned code on arduipilot and test imu response via mission planner.
The imu response still normal, the value don't offset by my code.
Please help me.
Can everyone sugguest me where roll, pitch, yaw that I can replace my new imu value.
Thank you for your attention
UUasin
Replies
Hi Randy,
I'm working on the same project as UUasin. We use arduplane, not arducopter. Not sure if the controllers are similar or not. Regarding the rate controller, we aware of that. However, in this state, we just want to replace euler angles from external AHRS to ones from ardupilot. After we finish with this, we will do more. Could someone please suggest us where exactly should we replace the roll/pitch/yaw values ?
uuasin,
It's a big thing you're trying to change so it's not super simple I'm afraid. If your IMU only provides acceleration and gyro values then you should write a new AP_InertialSensor. If your IMU also provides attitude information then you'll probably also want to write a new AP_AHRS. I think your class could be fairly thin and might look mostly like the HIL (Hardware-in-the-loop) classes.
Thank you Randy,
My sensor already provided Euler value such roll, pitch and yaw. And probably include some filter too.
So I think if I could find roll, pitch and yaw of ardupilot, I replace with my Euler value.
Please suggest me too.
Many thank
UUasin
UUasin,
Arducopter also uses the accelerometer values for position control (i.e. altitude hold and loiter). The raw gyro values are also used in the rate controller. So simply swapping in the angles from your imu won't work well I'm afraid.
Anyway, you can try but you'll need to write a new AP_AHRS library I think.