|
|
|
@ -2,21 +2,22 @@
@@ -2,21 +2,22 @@
|
|
|
|
|
#include "Rover.h" |
|
|
|
|
|
|
|
|
|
// Function to set a desired pitch angle according to throttle
|
|
|
|
|
void Rover::balance_pitch(float &throttle, bool armed) |
|
|
|
|
void Rover::balancebot_pitch_control(float &throttle, bool armed) |
|
|
|
|
{ |
|
|
|
|
// calculate desired pitch angle
|
|
|
|
|
float demanded_pitch = radians(-(throttle/100) * g2.bal_pitch_max); |
|
|
|
|
const float demanded_pitch = radians(-throttle * 0.01f * g2.bal_pitch_max); |
|
|
|
|
|
|
|
|
|
// calculate required throttle using PID controller
|
|
|
|
|
float balance_throttle = g2.attitude_control.get_throttle_out_from_pitch(demanded_pitch, armed)*100; |
|
|
|
|
const float balance_throttle = g2.attitude_control.get_throttle_out_from_pitch(demanded_pitch, armed) * 100.0f; |
|
|
|
|
|
|
|
|
|
throttle = constrain_float(balance_throttle, -100, 100); |
|
|
|
|
// constrain throttle between -100 and 100
|
|
|
|
|
throttle = constrain_float(balance_throttle, -100.0f, 100.0f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// returns true if vehicle is a balance bot
|
|
|
|
|
// called in AP_MotorsUGV::output()
|
|
|
|
|
// this affects whether the vehicle tries to control its pitch with throttle output
|
|
|
|
|
bool Rover::is_BalanceBot() const |
|
|
|
|
bool Rover::is_balancebot() const |
|
|
|
|
{ |
|
|
|
|
return ((enum frame_class)g2.frame_class.get() == FRAME_BALANCEBOT); |
|
|
|
|
} |
|
|
|
|