Car model with differential drive. The direction is controlled by adjusting the speed of the motors. Even motors are on the left side, odd motors are on the right side.
More...
|
|
void | setPins (int motor, int in1, int in2) |
| | Set the pins for a specific motor (0=front left, 1=front right, 2=rear left, 3=rear right)
|
| |
|
void | setSpeed (float percent) |
| | Set forward/reverse speed for all motors (percent, -100 to 100). Positive = forward, negative = reverse.
|
| |
|
void | setSteeringAgle (float angle) |
| | Set turn (percent, -100 to 100). Positive = right, negative = left. This slows down the motors on one side to turn the car.
|
| |
|
void | setSteeringAngle (Angle angle) |
| |
| void | end () override |
| | Stop all motors and reset speed and turn state.
|
| |
| void | setMotorGain (int motor, float gain) |
| | Set a calibration gain for a specific motor (default 1.0).
|
| |
| bool | isPinsSet () const |
| | Check if the necessary pins for the vehicle's actuators have been set (pure virtual).
|
| |
| bool | onMessage (const Message< float > &msg) override |
| | Handle an incoming message (pure virtual).
|
| |
| std::vector< MessageContent > | getControls () const override |
| |
|
MotorMT & | getMotor (size_t index) |
| |
| std::vector< IMotor< T > * > | getMotors () override |
| |
| bool | begin () |
| | Initialize the vehicle.
|
| |
| virtual void | end ()=0 |
| | Reset the vehicle to a safe or neutral state (pure virtual).
|
| |
| virtual bool | isPinsSet () const =0 |
| | Check if the necessary pins for the vehicle's actuators have been set (pure virtual).
|
| |
|
virtual std::vector< MessageContent > | getControls () const =0 |
| |
|
float | getSpeedFactor () const |
| | Get the speed factor (scaling for speed commands).
|
| |
|
void | setSpeedFactor (float factor) |
| | Set the speed factor (scaling for speed commands).
|
| |
|
virtual std::vector< IMotor< MotorT > * > | getMotors ()=0 |
| |
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) |
| |
| void | subscribe (MessageHandler &handler, MessageOrigin origin=MessageOrigin::Undefined, MessageContent content=MessageContent::Undefined) |
| | Subscribe a message handler to this source, with optional filtering.
|
| |
|
void | unsubscribeAll () |
| | Remove all registered message handlers.
|
| |
| void | sendMessage (Message< float > &msg) |
| | Publish a message to all registered handlers.
|
| |
| void | sendMessage (const Message< Coordinate< float > > &msg) |
| | Publish a message to all registered handlers.
|
| |
| void | sendMessage (const Message< GPSCoordinate > &msg) |
| | Publish a message to all registered handlers.
|
| |
|
void | sendMessage (const Message< MotionState3D > &msg) |
| | Overload for MotionState3D messages.
|
| |
template<size_t N = 4, typename T = float, typename MotorMT = BrushedMotor<T>>
class tinyrobotics::CarDifferential< N, T, MotorMT >
Car model with differential drive. The direction is controlled by adjusting the speed of the motors. Even motors are on the left side, odd motors are on the right side.
This class abstracts a simple N-wheel-drive car:
- N motor count (e.g. 4: front left, front right, rear left, rear right) via HBridge
- No steering servo: direction is controlled by varying motor speeds
Usage Example:
CarDifferentialWD<4> car;
car.setPins(0, 2, 3);
car.setPins(1, 5, 6);
car.setPins(2, 8, 9);
car.setPins(3, 11, 12);
car.setSpeed(60);
car.setTurn(30);
car.end();