Roboid Control for C++
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
RoboidControl::Arduino::DigitalInput Class Reference

Detailed Description

A digital input represents the stat of a digital GPIO pin.

#include <DigitalInput.h>

Inheritance diagram for RoboidControl::Arduino::DigitalInput:
RoboidControl::TouchSensor RoboidControl::Thing

Public Types

enum  Type {
  Undetermined , Switch , DistanceSensor , DirectionalSensor ,
  TemperatureSensor , TouchSensor , ControlledMotor , UncontrolledMotor ,
  Servo , Roboid , Humanoid , ExternalSensor
}
 Predefined thing types.
 

Public Member Functions

 DigitalInput (Participant *participant, unsigned char pin)
 Create a new digital input.
 
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.
 
ThingFindThing (const char *name)
 Find a thing by name.
 
virtual void SetParent (Thing *parent)
 Sets the parent Thing.
 
void SetParent (Thing *root, const char *name)
 
ThingGetParent ()
 Gets the parent Thing.
 
virtual void AddChild (Thing *child)
 Add a child Thing to this Thing.
 
ThingRemoveChild (Thing *child)
 Remove the given thing as a child of this thing.
 
ThingGetChild (unsigned char id, bool recursive=false)
 Get a child by thing Id.
 
ThingGetChildByIndex (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

bool touchedSomething = false
 Value which is true when the sensor is touching something, false otherwise.
 
Participantowner
 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 pin = 0
 The pin used for digital input.
 
Thingparent = nullptr
 
Thing ** children = nullptr
 

Constructor & Destructor Documentation

◆ DigitalInput()

RoboidControl::Arduino::DigitalInput::DigitalInput ( Participant participant,
unsigned char  pin 
)

Create a new digital input.

Parameters
participantThe participant to use
pinThe digital pin

Member Function Documentation

◆ Update()

void RoboidControl::Arduino::DigitalInput::Update ( unsigned long  currentTimeMs,
bool  recursive = false 
)
overridevirtual

Reimplemented from RoboidControl::Thing.

◆ GenerateBinary()

void RoboidControl::TouchSensor::GenerateBinary ( char *  bytes,
unsigned char *  ix 
)
overridevirtualinherited

Function to create a binary message with the temperature.

Parameters
bufferThe byte array for thw binary data
ixThe starting position for writing the binary data

Reimplemented from RoboidControl::Thing.

◆ ProcessBinary()

void RoboidControl::TouchSensor::ProcessBinary ( char *  bytes)
overridevirtualinherited

Function to extract the temperature received in the binary message.

Parameters
bytesThe binary data

Reimplemented from RoboidControl::Thing.

◆ FindThing()

Thing * RoboidControl::Thing::FindThing ( const char *  name)
inherited

Find a thing by name.

Parameters
nameRhe name of the thing
Returns
The found thing or nullptr when nothing is found

◆ SetParent()

void RoboidControl::Thing::SetParent ( Thing parent)
virtualinherited

Sets the parent Thing.

Parameters
parentThe Thing which should become the parnet
Remarks
This is equivalent to calling parent->AddChild(this);

◆ GetParent()

Thing * RoboidControl::Thing::GetParent ( )
inherited

Gets the parent Thing.

Returns
The parent Thing

◆ AddChild()

void RoboidControl::Thing::AddChild ( Thing child)
virtualinherited

Add a child Thing to this Thing.

Parameters
childThe Thing which should become a child
Remarks
When the Thing is already a child, it will not be added again

◆ RemoveChild()

Thing * RoboidControl::Thing::RemoveChild ( Thing child)
inherited

Remove the given thing as a child of this thing.

Parameters
childThe child to remove
Returns
The removed child or nullptr if the child could not be found

◆ GetChild()

Thing * RoboidControl::Thing::GetChild ( unsigned char  id,
bool  recursive = false 
)
inherited

Get a child by thing Id.

Parameters
idThe thing ID to find
recursiveLook recursively through all descendants
Returns
The found thing of nullptr when nothing is found

◆ GetChildByIndex()

Thing * RoboidControl::Thing::GetChildByIndex ( unsigned char  ix)
inherited

Get a child by index.

Parameters
ixThe child index
Returns
The found thing of nullptr when nothing is found

◆ SetPosition()

void RoboidControl::Thing::SetPosition ( Spherical  position)
inherited

Set the position of the thing.

Parameters
positionThe new position in local space, in meters

◆ GetPosition()

Spherical RoboidControl::Thing::GetPosition ( )
inherited

Get the position of the thing.

Returns
The position in local space, in meters

◆ SetOrientation()

void RoboidControl::Thing::SetOrientation ( SwingTwist  orientation)
inherited

Set the orientation of the thing.

Parameters
orientationThe new orientation in local space

◆ GetOrientation()

SwingTwist RoboidControl::Thing::GetOrientation ( )
inherited

Get the orientation of the thing.

Returns
The orienation in local space

◆ SetLinearVelocity()

void RoboidControl::Thing::SetLinearVelocity ( Spherical  linearVelocity)
inherited

Set the linear velocity of the thing.

Parameters
linearVelocityThe new linear velocity in local space, in meters per second

◆ GetLinearVelocity()

Spherical RoboidControl::Thing::GetLinearVelocity ( )
virtualinherited

Get the linear velocity of the thing.

Returns
The linear velocity in local space, in meters per second

◆ SetAngularVelocity()

void RoboidControl::Thing::SetAngularVelocity ( Spherical  angularVelocity)
virtualinherited

Set the angular velocity of the thing.

Parameters
angularVelocitythe new angular velocity in local space

Reimplemented in RoboidControl::Arduino::DRV8833Motor.

◆ GetAngularVelocity()

Spherical RoboidControl::Thing::GetAngularVelocity ( )
virtualinherited

Get the angular velocity of the thing.

Returns
The angular velocity in local space

◆ SetModel()

void RoboidControl::Thing::SetModel ( const char *  url)
inherited

Sets the location from where the 3D model of this Thing can be loaded from.

Parameters
urlThe url of the model
Remarks
Although the roboid implementation is not dependent on the model, the only official supported model format is .obj

Member Data Documentation

◆ networkId

unsigned char RoboidControl::Thing::networkId = 0
inherited

The network ID of this thing.

Note
This field will likely disappear in future versions

◆ positionUpdated

bool RoboidControl::Thing::positionUpdated = false
inherited

The scale of the thing (deprecated I think)

boolean indicating if the position was updated