![]() |
Roboid Control for C++
|
A thing which can move itself using a differential drive system.
#include <DifferentialDrive.h>
Public Types | |
enum | Type : unsigned char { Undetermined , Switch , DistanceSensor , DirectionalSensor , TemperatureSensor , TouchSensor , ControlledMotor , UncontrolledMotor , Servo , Roboid , Humanoid , ExternalSensor , DifferentialDrive } |
Predefined thing types. | |
Public Member Functions | |
DifferentialDrive () | |
Create a differential drive without networking support. | |
DifferentialDrive (Participant *participant, unsigned char thingId=0) | |
Create a differential drive with networking support. | |
DifferentialDrive (Thing *parent, unsigned char thingId=0) | |
Create a new child differential drive. | |
void | SetDriveDimensions (float wheelDiameter, float wheelSeparation) |
Configures the dimensions of the drive. | |
void | SetMotors (Thing *leftWheel, Thing *rightWheel) |
Congures the motors for the wheels. | |
void | SetWheelVelocity (float speedLeft, float speedRight) |
Directly specify the speeds of the motors. | |
virtual void | Update (unsigned long currentMs, bool recursive=true) override |
void | SetName (const char *name) |
const char * | GetName () const |
void | SetModel (const char *url) |
Sets the location from where the 3D model of this Thing can be loaded from. | |
virtual void | SetParent (Thing *parent) |
Sets the parent of this Thing. | |
Thing * | GetParent () |
Gets the parent of this Thing. | |
Thing * | GetChildByIndex (unsigned char ix) |
Get a child by index. | |
virtual void | AddChild (Thing *child) |
Add a child Thing to this Thing. | |
Thing * | RemoveChild (Thing *child) |
Remove the given thing as a child of this thing. | |
Thing * | GetChild (unsigned char id, bool recurse=false) |
Get a child by thing Id. | |
Thing * | FindChild (const char *name, bool recurse=true) |
Find a thing by name. | |
void | SetPosition (Spherical position) |
Set the position of the thing. | |
Spherical | GetPosition () |
Get the position of the thing. | |
void | SetOrientation (SwingTwist orientation) |
Set the orientation of the thing. | |
SwingTwist | GetOrientation () |
Get the orientation of the thing. | |
void | SetLinearVelocity (Spherical linearVelocity) |
Set the linear velocity of the thing. | |
virtual Spherical | GetLinearVelocity () |
Get the linear velocity of the thing. | |
virtual void | SetAngularVelocity (Spherical angularVelocity) |
Set the angular velocity of the thing. | |
virtual Spherical | GetAngularVelocity () |
Get the angular velocity of the thing. | |
void | Update (bool recursive=false) |
Updates the state of the thing. | |
virtual int | GenerateBinary (char *buffer, unsigned char *ix) |
Function used to generate binary data for this thing. | |
virtual void | ProcessBinary (char *bytes) |
Function used to process binary data received for this thing. | |
Static Public Member Functions | |
static unsigned long | GetTimeMs () |
Get the current time in milliseconds. | |
static void | UpdateThings (unsigned long currentTimeMs) |
Public Attributes | |
bool | terminate = false |
Terminated things are no longer updated. | |
Participant * | owner = nullptr |
The participant managing this thing. | |
unsigned char | id = 0 |
The ID of the thing. | |
unsigned char | type = Type::Undetermined |
The type of Thing This can be either a Thing::Type of a byte value for custom types. | |
const char * | name = nullptr |
The name of the thing. | |
bool | nameChanged = false |
const char * | modelUrl = nullptr |
An URL pointing to the location where a model of the thing can be found. | |
float | modelScale = 1 |
The scale of the model (deprecated I think) | |
unsigned char | childCount = 0 |
The number of children. | |
bool | hierarchyChanged = true |
Indicator that the hierarchy of the thing has changed. | |
bool | positionUpdated = false |
Boolean indicating that the thing has an updated position. | |
bool | orientationUpdated = false |
Boolean indicating the thing has an updated orientation. | |
bool | linearVelocityUpdated = false |
Boolean indicating the thing has an updated linear velocity. | |
bool | angularVelocityUpdated = false |
Boolean indicating the thing has an updated angular velocity. | |
Protected Attributes | |
float | wheelRadius = 1.0f |
The radius of a wheel in meters. | |
float | wheelSeparation = 1.0f |
The distance between the wheels in meters. | |
float | rpsToMs = 1.0f |
Convert revolutions per second to meters per second. | |
Thing * | leftWheel = nullptr |
The left wheel. | |
Thing * | rightWheel = nullptr |
The right wheel. | |
RoboidControl::DifferentialDrive::DifferentialDrive | ( | Participant * | participant, |
unsigned char | thingId = 0 |
||
) |
Create a differential drive with networking support.
participant | The local participant |
thingId | The ID of the thing, leave out or set to zero to generate an ID |
RoboidControl::DifferentialDrive::DifferentialDrive | ( | Thing * | parent, |
unsigned char | thingId = 0 |
||
) |
Create a new child differential drive.
parent | The parent thing |
thingId | The ID of the thing, leave out or set to zero to generate an ID |
void RoboidControl::DifferentialDrive::SetDriveDimensions | ( | float | wheelDiameter, |
float | wheelSeparation | ||
) |
Configures the dimensions of the drive.
wheelDiameter | The diameter of the wheels in meters |
wheelSeparation | The distance between the wheels in meters |
These values are used to compute the desired wheel speed from the set linear and angular velocity.
Congures the motors for the wheels.
leftWheel | The motor for the left wheel |
rightWheel | The motor for the right wheel |
void RoboidControl::DifferentialDrive::SetWheelVelocity | ( | float | speedLeft, |
float | speedRight | ||
) |
Directly specify the speeds of the motors.
speedLeft | The speed of the left wheel in degrees per second. Positive moves the robot in the forward direction. |
speedRight | The speed of the right wheel in degrees per second. Positive moves the robot in the forward direction. |
|
overridevirtual |
Reimplemented from RoboidControl::Thing.
|
inherited |
Sets the location from where the 3D model of this Thing can be loaded from.
url | The url of the model |
|
virtualinherited |
|
inherited |
|
inherited |
Get a child by index.
ix | The child index |
|
virtualinherited |
Remove the given thing as a child of this thing.
child | The child to remove |
|
inherited |
Get a child by thing Id.
id | The thing ID to find |
recurse | Look recursively through all descendants |
|
inherited |
Find a thing by name.
name | The name of the thing |
recurse | Look recursively through all descendants |
|
inherited |
Set the position of the thing.
position | The new position in local space, in meters |
|
inherited |
Get the position of the thing.
|
inherited |
Set the orientation of the thing.
orientation | The new orientation in local space |
|
inherited |
Get the orientation of the thing.
|
inherited |
Set the linear velocity of the thing.
linearVelocity | The new linear velocity in local space, in meters per second |
|
virtualinherited |
Get the linear velocity of the thing.
|
virtualinherited |
Set the angular velocity of the thing.
angularVelocity | the new angular velocity in local space |
Reimplemented in RoboidControl::Arduino::DRV8833Motor.
|
virtualinherited |
Get the angular velocity of the thing.
|
staticinherited |
Get the current time in milliseconds.
|
virtualinherited |
Function used to generate binary data for this thing.
buffer | The byte array for thw binary data |
ix | The starting position for writing the binary data |
Reimplemented in RoboidControl::DigitalSensor, RoboidControl::TemperatureSensor, and RoboidControl::TouchSensor.
|
virtualinherited |
Function used to process binary data received for this thing.
bytes | The binary data |
Reimplemented in RoboidControl::DigitalSensor, RoboidControl::TemperatureSensor, and RoboidControl::TouchSensor.