mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
a5e28f0729
Also remove constraint on throttle output (this is handle in the AP_MotorsUGV library Also move balance bot declarations to alphabetical order within Rover.h
21 lines
768 B
C++
21 lines
768 B
C++
#include<stdio.h>
|
|
#include "Rover.h"
|
|
|
|
// Function to set a desired pitch angle according to throttle
|
|
void Rover::balancebot_pitch_control(float &throttle)
|
|
{
|
|
// calculate desired pitch angle
|
|
const float demanded_pitch = radians(-throttle * 0.01f * g2.bal_pitch_max);
|
|
|
|
// calculate required throttle using PID controller
|
|
throttle = g2.attitude_control.get_throttle_out_from_pitch(demanded_pitch, g2.motors.limit.throttle_lower, g2.motors.limit.throttle_upper, G_Dt) * 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
|
|
{
|
|
return ((enum frame_class)g2.frame_class.get() == FRAME_BALANCEBOT);
|
|
}
|