TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
DroneOdometryModel3D Class Reference

IOdometryModel3D implementation for quadcopters/drones using motor percentages. More...

#include <DroneOdometryModel3D.h>

Inheritance diagram for DroneOdometryModel3D:
Inheritance graph
[legend]
Collaboration diagram for DroneOdometryModel3D:
Collaboration graph
[legend]

Public Member Functions

void registerCallback (void(*callback)(void *), void *userData) override
 Register a callback to be invoked on relevant events (e.g., input change).
 
 DroneOdometryModel3D (float maxVz=5.0f, float maxRollRate=200.0f, float maxPitchRate=200.0f, float maxYawRate=100.0f)
 Construct a DroneOdometryModel3D with configurable max rates.
 
void setMotorPercent (int motor, float percent)
 Set the percentage (0..100) for a given motor (0..3).
 
virtual void registerCallback (void(*callback)(void *), void *userData)
 Register a callback to be invoked on relevant events (e.g., input change, update).
 
virtual void getLinearVelocity (float &vx, float &vy, float &vz) const =0
 Get the current linear velocity (vx, vy, vz) in m/s (robot frame).
 
virtual void getAngularVelocity (float &wx, float &wy, float &wz) const =0
 Get the current angular velocity (wx, wy, wz) in rad/s (robot frame).
 
- Public Member Functions inherited from MessageHandler
virtual bool onMessage (const Message< float > &msg)=0
 Handle an incoming message (pure virtual).
 
virtual bool onMessage (const Message< Coordinate< float > > &msg)
 
virtual bool onMessage (const Message< GPSCoordinate > &msg)
 
virtual bool onMessage (const Message< MotionState3D > &msg)
 

Static Public Attributes

static constexpr int NUM_MOTORS = 4
 

Protected Member Functions

bool onMessage (const Message< float > &msg)
 Handle incoming motor speed messages (MessageContent::MotorSpeed, origin_id = motor index).
 
void getLinearVelocity (float &vx, float &vy, float &vz) const override
 Compute linear velocity (vx, vy, vz) in m/s (body frame). Only vz is modeled (vertical climb/descent), vx and vy are zero.
 
void getAngularVelocity (float &wx, float &wy, float &wz) const override
 Compute angular velocity (wx, wy, wz) in rad/s (body frame). Roll and pitch rates are proportional to left/right and front/back motor differences. Yaw rate is proportional to diagonal differences (simplified torque model).
 

Static Protected Member Functions

static float clamp (float v, float min, float max)
 

Protected Attributes

void(* callback )(void *) = nullptr
 
void * userData = nullptr
 
std::array< float, NUM_MOTORS > motorPercent
 
float maxVz
 
float maxRollRate
 
float maxPitchRate
 
float maxYawRate
 

Detailed Description

IOdometryModel3D implementation for quadcopters/drones using motor percentages.

This model computes linear and angular velocities for a quadcopter based on the percentage output (0-100%) of each motor. It assumes a standard X-configuration quadcopter with four motors:

Features

Notes

Usage Example

model.setMotorPercent(0, 60); // Front Left
model.setMotorPercent(1, 60); // Front Right
model.setMotorPercent(2, 60); // Rear Right
model.setMotorPercent(3, 60); // Rear Left
float vx, vy, vz, wx, wy, wz;
model.getLinearVelocity(vx, vy, vz);
model.getAngularVelocity(wx, wy, wz);
IOdometryModel3D implementation for quadcopters/drones using motor percentages.
Definition: DroneOdometryModel3D.h:65
void getAngularVelocity(float &wx, float &wy, float &wz) const override
Compute angular velocity (wx, wy, wz) in rad/s (body frame). Roll and pitch rates are proportional to...
Definition: DroneOdometryModel3D.h:147
void getLinearVelocity(float &vx, float &vy, float &vz) const override
Compute linear velocity (vx, vy, vz) in m/s (body frame). Only vz is modeled (vertical climb/descent)...
Definition: DroneOdometryModel3D.h:131
void setMotorPercent(int motor, float percent)
Set the percentage (0..100) for a given motor (0..3).
Definition: DroneOdometryModel3D.h:102

Constructor & Destructor Documentation

◆ DroneOdometryModel3D()

DroneOdometryModel3D ( float  maxVz = 5.0f,
float  maxRollRate = 200.0f,
float  maxPitchRate = 200.0f,
float  maxYawRate = 100.0f 
)
inline

Construct a DroneOdometryModel3D with configurable max rates.

Parameters
maxVzMaximum vertical speed (m/s) at 100% throttle. Typical: 5 m/s.
maxRollRateMaximum roll rate (deg/s, converted to rad/s). Typical: 200 deg/s.
maxPitchRateMaximum pitch rate (deg/s, converted to rad/s). Typical: 200 deg/s.
maxYawRateMaximum yaw rate (deg/s, converted to rad/s). Typical: 100 deg/s.

Member Function Documentation

◆ getAngularVelocity()

void getAngularVelocity ( float &  wx,
float &  wy,
float &  wz 
) const
inlineoverrideprotectedvirtual

Compute angular velocity (wx, wy, wz) in rad/s (body frame). Roll and pitch rates are proportional to left/right and front/back motor differences. Yaw rate is proportional to diagonal differences (simplified torque model).

Implements IOdometryModel3D.

◆ getLinearVelocity()

void getLinearVelocity ( float &  vx,
float &  vy,
float &  vz 
) const
inlineoverrideprotectedvirtual

Compute linear velocity (vx, vy, vz) in m/s (body frame). Only vz is modeled (vertical climb/descent), vx and vy are zero.

Implements IOdometryModel3D.

◆ onMessage()

bool onMessage ( const Message< float > &  msg)
inlineprotectedvirtual

Handle incoming motor speed messages (MessageContent::MotorSpeed, origin_id = motor index).

Implements MessageHandler.

◆ registerCallback()

void registerCallback ( void(*)(void *)  callback,
void *  userData 
)
inlineoverridevirtual

Register a callback to be invoked on relevant events (e.g., input change).

Reimplemented from IOdometryModel3D.


The documentation for this class was generated from the following file: