PX4 Firmware
PX4 Autopilot Software http://px4.io
ControlMath Namespace Reference

Functions

void thrustToAttitude (const matrix::Vector3f &thr_sp, const float yaw_sp, vehicle_attitude_setpoint_s &attitude_setpoint)
 Converts thrust vector and yaw set-point to a desired attitude. More...
 
Vector2f constrainXY (const matrix::Vector2f &v0, const matrix::Vector2f &v1, const float &max)
 Outputs the sum of two vectors but respecting the limits and priority. More...
 
bool cross_sphere_line (const matrix::Vector3f &sphere_c, const float sphere_r, const matrix::Vector3f &line_a, const matrix::Vector3f &line_b, matrix::Vector3f &res)
 This method was used for smoothing the corners along two lines. More...
 

Function Documentation

◆ constrainXY()

matrix::Vector2f ControlMath::constrainXY ( const matrix::Vector2f v0,
const matrix::Vector2f v1,
const float &  max 
)

Outputs the sum of two vectors but respecting the limits and priority.

The sum of two vectors are constraint such that v0 has priority over v1. This means that if the length of (v0+v1) exceeds max, then it is constraint such that v0 has priority.

Parameters
v0a 2D vector that has priority given the maximum available magnitude.
v1a 2D vector that less priority given the maximum available magnitude.
Returns
2D vector

Definition at line 107 of file ControlMath.cpp.

References matrix::Vector< Type, M >::dot(), f(), matrix::Vector< Type, M >::length(), matrix::max(), and matrix::Vector< Type, M >::normalized().

Referenced by PositionControl::_positionController(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cross_sphere_line()

bool ControlMath::cross_sphere_line ( const matrix::Vector3f sphere_c,
const float  sphere_r,
const matrix::Vector3f line_a,
const matrix::Vector3f line_b,
matrix::Vector3f res 
)

This method was used for smoothing the corners along two lines.

Parameters
sphere_c
sphere_r
line_a
line_b
resreturn boolean

Note: this method is not used anywhere and first requires review before usage.

Definition at line 172 of file ControlMath.cpp.

References f(), matrix::Vector< Type, M >::length(), and matrix::Vector< Type, M >::normalize().

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ thrustToAttitude()

void ControlMath::thrustToAttitude ( const matrix::Vector3f thr_sp,
const float  yaw_sp,
vehicle_attitude_setpoint_s attitude_setpoint 
)

Converts thrust vector and yaw set-point to a desired attitude.

Parameters
thr_spa 3D vector
yaw_spthe desired yaw
Returns
vehicle_attitude_setpoints_s structure

Definition at line 47 of file ControlMath.cpp.

References matrix::Matrix< Type, M, N >::copyTo(), f(), matrix::Vector< Type, M >::length(), matrix::Vector< Type, M >::normalize(), matrix::Vector3< Type >::normalized(), vehicle_attitude_setpoint_s::pitch_body, vehicle_attitude_setpoint_s::q_d, vehicle_attitude_setpoint_s::q_d_valid, vehicle_attitude_setpoint_s::roll_body, vehicle_attitude_setpoint_s::thrust_body, vehicle_attitude_setpoint_s::yaw_body, and matrix::Matrix< Type, M, N >::zero().

Referenced by PositionControl::getAttitudeSetpoint(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function: