![]() |
Roboid Control for C++
|
An HC-SR04 ultrasonic distance sensor.
#include <UltrasonicSensor.h>
Public Types | |
enum | Type { Undetermined , Switch , DistanceSensor , DirectionalSensor , TemperatureSensor , TouchSensor , ControlledMotor , UncontrolledMotor , Servo , Roboid , Humanoid , ExternalSensor } |
Predefined thing types. | |
Public Member Functions | |
UltrasonicSensor (Participant *participant, unsigned char pinTrigger, unsigned char pinEcho) | |
Setup an ultrasonic sensor. | |
float | GetDistance () |
erform an ultrasonic 'ping' to determine the distance to the nearest object | |
virtual void | Update (unsigned long currentTimeMs, bool recursive=false) override |
void | GenerateBinary (char *bytes, unsigned char *ix) override |
Function to create a binary message with the temperature. | |
virtual void | ProcessBinary (char *bytes) override |
Function to extract the temperature received in the binary message. | |
Thing * | FindThing (const char *name) |
Find a thing by name. | |
virtual void | SetParent (Thing *parent) |
Sets the parent Thing. | |
void | SetParent (Thing *root, const char *name) |
Thing * | GetParent () |
Gets the parent Thing. | |
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 recursive=false) |
Get a child by thing Id. | |
Thing * | GetChildByIndex (unsigned char ix) |
Get a child by index. | |
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 | Terminate () |
Terminated things are no longer updated. | |
void | SetModel (const char *url) |
Sets the location from where the 3D model of this Thing can be loaded from. | |
void | Update (bool recursive=false) |
Static Public Member Functions | |
static unsigned long | GetTimeMs () |
static void | UpdateThings (unsigned long currentTimeMs) |
Public Attributes | |
float | touchDistance = 0.2f |
The distance at which the object is considered to be touched. | |
float | distance = 0 |
The last read distance. | |
bool | touchedSomething = false |
Value which is true when the sensor is touching something, false otherwise. | |
Participant * | owner |
The participant managing this thing. | |
unsigned char | networkId = 0 |
The network ID of this thing. | |
unsigned char | id = 0 |
The ID of the thing. | |
unsigned char | type = 0 |
The type of Thing This can be either a Thing::Type of a byte value for custom types. | |
unsigned char | childCount = 0 |
The number of children. | |
const char * | name = nullptr |
The name of the thing. | |
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) | |
bool | positionUpdated = false |
The scale of the thing (deprecated I think) | |
bool | orientationUpdated = false |
boolean indicating if the orientation was updated | |
bool | linearVelocityUpdated = false |
bool | angularVelocityUpdated = false |
Protected Attributes | |
unsigned char | pinTrigger = 0 |
The pin number of the trigger signal. | |
unsigned char | pinEcho = 0 |
The pin number of the echo signal. | |
Thing * | parent = nullptr |
Thing ** | children = nullptr |
RoboidControl::Arduino::UltrasonicSensor::UltrasonicSensor | ( | Participant * | participant, |
unsigned char | pinTrigger, | ||
unsigned char | pinEcho | ||
) |
Setup an ultrasonic sensor.
participant | The participant to use |
pinTrigger | The pin number of the trigger signal |
pinEcho | The pin number of the echo signal |
float RoboidControl::Arduino::UltrasonicSensor::GetDistance | ( | ) |
erform an ultrasonic 'ping' to determine the distance to the nearest object
|
overridevirtual |
Reimplemented from RoboidControl::Thing.
|
overridevirtualinherited |
Function to create a binary message with the temperature.
buffer | The byte array for thw binary data |
ix | The starting position for writing the binary data |
Reimplemented from RoboidControl::Thing.
|
overridevirtualinherited |
Function to extract the temperature received in the binary message.
bytes | The binary data |
Reimplemented from RoboidControl::Thing.
|
inherited |
Find a thing by name.
name | Rhe name of the thing |
|
virtualinherited |
|
inherited |
|
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 |
recursive | Look recursively through all descendants |
|
inherited |
Get a child by index.
ix | The child index |
|
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.
|
inherited |
Sets the location from where the 3D model of this Thing can be loaded from.
url | The url of the model |
|
inherited |
The network ID of this thing.
|
inherited |
The scale of the thing (deprecated I think)
boolean indicating if the position was updated