You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
858 B
24 lines
858 B
7 years ago
|
#include<stdio.h>
|
||
|
#include "Rover.h"
|
||
|
|
||
7 years ago
|
// Function to set a desired pitch angle according to throttle
|
||
7 years ago
|
void Rover::balancebot_pitch_control(float &throttle, bool armed)
|
||
7 years ago
|
{
|
||
7 years ago
|
// calculate desired pitch angle
|
||
7 years ago
|
const float demanded_pitch = radians(-throttle * 0.01f * g2.bal_pitch_max);
|
||
7 years ago
|
|
||
|
// calculate required throttle using PID controller
|
||
7 years ago
|
const float balance_throttle = g2.attitude_control.get_throttle_out_from_pitch(demanded_pitch, armed, G_Dt) * 100.0f;
|
||
7 years ago
|
|
||
7 years ago
|
// constrain throttle between -100 and 100
|
||
|
throttle = constrain_float(balance_throttle, -100.0f, 100.0f);
|
||
7 years ago
|
}
|
||
|
|
||
|
// 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
|
||
7 years ago
|
bool Rover::is_balancebot() const
|
||
7 years ago
|
{
|
||
|
return ((enum frame_class)g2.frame_class.get() == FRAME_BALANCEBOT);
|
||
|
}
|