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

Detailed Description

A thing is the primitive building block.

#include <Thing.h>

Inheritance diagram for Passer::RoboidControl::Thing:
Passer::RoboidControl::TemperatureSensor

Public Types

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

Public Member Functions

 Thing (Type thingType=Type::Undetermined)
 Create a new thing of the given type.
 
 Thing (unsigned char thingType)
 Create a new thing of the give type.
 
 Thing (RemoteParticipant *participant, unsigned char networkId, unsigned char thingId, Type thingType=Type::Undetermined)
 Create a new thing for the given participant.
 
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 (Spherical16 position)
 Set the position of the thing.
 
Spherical16 GetPosition ()
 Get the position of the thing.
 
void SetOrientation (SwingTwist16 orientation)
 Set the orientation of the thing.
 
SwingTwist16 GetOrientation ()
 Get the orientation of the thing.
 
virtual Spherical16 GetLinearVelocity ()
 Get the linear velocity of the thing.
 
virtual Spherical16 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.
 
virtual void Update (unsigned long currentTimeMs)
 Updates the state of the thing.
 
virtual void GenerateBinary (char *buffer, unsigned char *ix)
 Function used to generate binary data for this thing.
 
virtual void ProcessBinary (char *bytes)
 

Public Attributes

RemoteParticipantparticipant
 
unsigned char networkId = 0
 
unsigned char id = 0
 The ID of the thing.
 
unsigned char type = 0
 The type of Thing.
 
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)
 
float scale = 1
 The scale of the thing (deprecated I think)
 
bool positionUpdated = false
 boolean indicating if the position was updated
 
bool orientationUpdated = false
 boolean indicating if the orientation was updated
 
Spherical16 linearVelocity
 
Spherical16 angularVelocity
 

Protected Attributes

Thingparent = nullptr
 
Thing ** children = nullptr
 
Spherical16 position
 The position in local space.
 
SwingTwist16 orientation
 The orientation in local space.
 

Constructor & Destructor Documentation

◆ Thing() [1/3]

Thing::Thing ( Type  thingType = Type::Undetermined)

Create a new thing of the given type.

Parameters
thingTypeThe predefined type of thing

◆ Thing() [2/3]

Thing::Thing ( unsigned char  thingType)

Create a new thing of the give type.

Parameters
thingTypeThe custom type of the thing

◆ Thing() [3/3]

Thing::Thing ( RemoteParticipant participant,
unsigned char  networkId,
unsigned char  thingId,
Type  thingType = Type::Undetermined 
)

Create a new thing for the given participant.

Parameters
participantThe participant for which this thing is created
networkIdThe network ID of the thing
thingIdThe ID of the thing
thingTypeThe type of thing

Member Function Documentation

◆ FindThing()

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

Find a thing by name.

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

◆ SetParent()

void Thing::SetParent ( Thing parent)
virtual

Sets the parent Thing.

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

◆ GetParent()

Thing * Thing::GetParent ( )

Gets the parent Thing.

Returns
The parent Thing

◆ AddChild()

void Thing::AddChild ( Thing child)
virtual

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 * Thing::RemoveChild ( Thing child)

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 * Thing::GetChild ( unsigned char  id,
bool  recursive = false 
)

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 * Thing::GetChildByIndex ( unsigned char  ix)

Get a child by index.

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

◆ SetPosition()

void Thing::SetPosition ( Spherical16  position)

Set the position of the thing.

Parameters
positionThe new position in local space, in meters

◆ GetPosition()

Spherical16 Thing::GetPosition ( )

Get the position of the thing.

Returns
The position in local space, in meters

◆ SetOrientation()

void Thing::SetOrientation ( SwingTwist16  orientation)

Set the orientation of the thing.

Parameters
orientationThe new orientation in local space

◆ GetOrientation()

SwingTwist16 Thing::GetOrientation ( )

Get the orientation of the thing.

Returns
The orienation in local space

◆ GetLinearVelocity()

Spherical16 Thing::GetLinearVelocity ( )
virtual

Get the linear velocity of the thing.

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

◆ GetAngularVelocity()

Spherical16 Thing::GetAngularVelocity ( )
virtual

Get the angular velocity of the thing.

Returns
The angular velocity in local space

◆ SetModel()

void Thing::SetModel ( const char *  url)

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

◆ Update()

virtual void Passer::RoboidControl::Thing::Update ( unsigned long  currentTimeMs)
inlinevirtual

Updates the state of the thing.

Parameters
currentTimeMsThe current clock time in milliseconds

◆ GenerateBinary()

void Thing::GenerateBinary ( char *  buffer,
unsigned char *  ix 
)
virtual

Function used to generate binary data for this thing.

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

Reimplemented in Passer::RoboidControl::TemperatureSensor.

◆ ProcessBinary()

void Thing::ProcessBinary ( char *  bytes)
virtual
Parameters
bytesThe binary data

Reimplemented in Passer::RoboidControl::TemperatureSensor.

Member Data Documentation

◆ position

Spherical16 Passer::RoboidControl::Thing::position
protected

The position in local space.

Remarks
When this Thing has a parent, the position is relative to the parent's position and orientation

◆ orientation

SwingTwist16 Passer::RoboidControl::Thing::orientation
protected

The orientation in local space.

Remarks
When this Thing has a parent, the orientation is relative to the parent's orientation