Class PolynomialThrustMap
Defined in File polynomial_thrust_map.hpp
Class Documentation
-
class PolynomialThrustMap
Polynomial thrust map class.
Computes throttle command from thrust and voltage by evaluating: throttle = a + b * T + c * V + d * T^2 + e * T * V + f * V^2
Public Functions
-
inline explicit PolynomialThrustMap(unsigned int n_motors)
Construct a PolynomialThrustMap with zero-initialized coefficients.
- Parameters:
n_motors – Number of motors of the platform.
-
inline explicit PolynomialThrustMap(unsigned int n_motors, double max_throttle, double min_throttle, double a, double b, double c, double d, double e, double f, double gamma2, double gamma1, double gamma0, bool use_correction_factor, as2::AerialPlatform *platform_node_ptr)
Construct a PolynomialThrustMap with given coefficients.
- Parameters:
n_motors – Number of motors of the platform.
max_throttle – Maximum throttle value for normalized output.
min_throttle – Minimum throttle value for normalized output.
a – Constant coefficient of the throttle polynomial.
b – Linear thrust coefficient of the throttle polynomial.
c – Linear voltage coefficient of the throttle polynomial.
d – Quadratic thrust coefficient of the throttle polynomial.
e – Cross (thrust * voltage) coefficient of the throttle polynomial.
f – Quadratic voltage coefficient of the throttle polynomial.
gamma2 – Quadratic coefficient of the voltage correction factor polynomial.
gamma1 – Linear coefficient of the voltage correction factor polynomial.
gamma0 – Constant coefficient of the voltage correction factor polynomial.
use_correction_factor – Whether to apply the voltage correction factor.
platform_node_ptr – Pointer to the aerial platform node.
-
std::string to_string() const
Return string with thrust map parameters for logging.
- Returns:
String with thrust map parameters.
-
template<typename T>
T getParameter(std::string param_name) const Read a ROS 2 parameter from platform config file, declaring it if not yet set.
- Template Parameters:
T – Type to cast the parameter value to.
- Parameters:
param_name – Name of the ROS 2 parameter to read.
- Returns:
The parameter value cast to type T.
-
void set_parameters(double max_throttle, double min_throttle, double a, double b, double c, double d, double e, double f, bool use_correction_factor, double gamma2, double gamma1, double gamma0)
Set all thrust map parameters.
-
void readParameters()
Read and load all polynomial coefficients from config file.
-
void initialize(as2::AerialPlatform *platform_node_ptr)
Initialize the thrust map with a pointer to the aerial platform node.
- Parameters:
platform_node_ptr – Pointer to the aerial platform node.
-
double mapThrust(double thrust, double voltage)
Compute a throttle command from thrust and voltage.
- Parameters:
thrust – Desired thrust in Newtons.
voltage – Current battery voltage in Volts.
- Returns:
Throttle command in the calibrated range.
-
uint16_t getThrottle_useconds(double thrust, double voltage)
Compute the throttle command in microseconds from thrust and voltage.
- Parameters:
thrust – Desired thrust in Newtons.
voltage – Current battery voltage in Volts.
- Returns:
Throttle command in microseconds (us).
-
double getThrottle_normalized(double thrust, double voltage)
Compute the normalized throttle command from thrust and voltage.
- Parameters:
thrust – Desired thrust in Newtons.
voltage – Current battery voltage in Volts.
- Returns:
Normalized throttle command in the specified throttle range.
Protected Attributes
-
as2::AerialPlatform *platform_node_ptr_
Friends
-
inline friend std::ostream &operator<<(std::ostream &os, const PolynomialThrustMap &tm)
-
inline explicit PolynomialThrustMap(unsigned int n_motors)