I built a TRex 450 with an APM mounted as suggested by Randy but am thinking about changing it and mounting it in a different way that would result in the APM being upside down.  My question is, can I easily correct this by modifying the code?  Is it just a matter of changing the sign for a number of the signals?  I noticed there is a config parameter for changing the orientation of the magnetometer, but I didn't see anything for the orientation of the APM.

 

 

 

 

Views: 610

Reply to This

Replies to This Discussion

Graham,

     There's no easy way to do this I'm afraid.  It's definitely possible though but you'd need to modify perhaps the AP_IMU_Oilpan.h file in the AP_IMU library or maybe somewhere in the DCM lib when it consumes the accelerometer and gyro data..but I can't tell you exactly what you'd need to change.  If the APM is upside-down I think you need to reverse the pitch gyro values and all three (x,y,z) accelerometer values.

Thanks for this Randy. I am going to try and see if I can make it work and I'll let you know if I am successful.
It looks like I found the spot and it is much easier than I had thought. I am planning on changing the signs as needed to compensate for the flip. Does this makes sense? Do you think there will be other places in the code that I will need to correct? Or is it really this easy?

// Sensors: GYROX, GYROY, GYROZ, ACCELX, ACCELY, ACCELZ
const uint8_t AP_IMU_Oilpan::_sensors[6] = { 1, 2, 0, 4, 5, 6}; // Channel assignments on the APM oilpan
const int8_t AP_IMU_Oilpan::_sensor_signs[6] = { 1,-1,-1, 1,-1,-1}; // Channel orientation vs. normal

Ah nicely done.  Yes, that makes sense and that might very well be enough.  I think normally in the rest of the code we use DCM which has already processed the sensor values.

I got it working upside down! For the record, this is with the pins facing towards the back and the APM with the components facing down. Here is the line I used:

const int8_t AP_IMU_Oilpan::_sensor_signs[6] = { 1,1,1, 1,1,1}; // Channel orientation vs. normal,

I flipped GYROY, GYROZ, ACCELY, ACCELZ. Perhaps we can add a configuration to make this easier for other people in the future. For now I am going to focus on getting it flying and make sure it all works as I expect.

Congrats!  well done!

Yes, great stuff!  Just made this mod to mount an apm1 under my 3DR frame.  Works tremendously. :)  The filename has changed but grepping on GYROY etc will turn it up.

Is this configuration (inverted AMP) option added to the mission planner setup yet or is it going to be added if not already? 

Reply to Discussion

RSS

© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service