Roboid Control for Python
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Thing Class Reference

Detailed Description

A thing is the basic building block.

Inheritance diagram for Thing:
DifferentialDrive TouchSensor TemperatureSensor TouchSensor

Classes

class  Type
 Predefined thing types. More...
 

Public Member Functions

None __init__ (self, Optional['Participant'] owner=None, Optional['Thing'] parent=None, int thing_type=Type.Undetermined, int thing_id=0)
 Create a new thing.
 
 SetParent (self, Optional['Thing'] parent)
 Sets the parent of this Thing.
 
 AddChild (self, 'Thing' child)
 Add a child Thing to this Thing.
 
 RemoveChild (self, 'Thing' child)
 Remove the given thing as a child of this thing.
 
Optional[ 'Thing'] GetChild (self, int thing_id, bool recurse=False)
 Get a child by thing Id.
 
Optional[ 'Thing'] FindChild (self, str name, bool recurse=True)
 Find a thing by name.
 
None SetPosition (self, Spherical position)
 Set the position of the thing.
 
None SetOrientation (self, Quaternion orientation)
 Set the orientation of the thing.
 
None SetLinearVelocity (self, Spherical linear_velocity)
 Set the linear velocity of the thing.
 
None SetAngularVelocity (self, Spherical angular_velocity)
 Set the angular velocity of the thing.
 
None Update (self, int currentTimeMs=0, bool recurse=False)
 Update de state of the thing.
 
int GenerateBinary (self, bytearray bytes, set[int] ix_ref)
 Function used to generate binary data for this thing.
 
 ProcessBinary (self, bytes data)
 Function used to process binary data received for this thing.
 

Static Public Member Functions

int GetTimeMs ()
 Get the current time in milliseconds.
 

Public Attributes

 owner
 
 parent
 
 position
 
 position_updated
 
 orientation
 
 orientation_updated
 
 linear_velocity_updated
 
 linear_velocity
 
 angular_velocity_updated
 
 angular_velocity
 

Static Public Attributes

 Position
 
int Orientation = 0x02
 
int LinearVelocity = 0x04
 
int AngularVelocity = 0x08
 

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
Optional['Participant']   owner = None,
Optional['Thing']   parent = None,
int   thing_type = Type.Undetermined,
int   thing_id = 0 
)

Create a new thing.

Parameters
ownerThe owning participant
parentThe parent thing (will override owner if set)
thing_typeThe type of thing (can use Thing.Type)
thingIdThe ID of the thing, leave out or set to zero to generate an ID

Reimplemented in DifferentialDrive, TouchSensor, TemperatureSensor, and TouchSensor.

Member Function Documentation

◆ SetParent()

SetParent (   self,
Optional['Thing']  parent 
)

Sets the parent of this Thing.

Parameters
TheThing which should become the parent
Note
Do not set Thing.parent directly, as that will break the parent-child relation

◆ AddChild()

AddChild (   self,
'Thing child 
)

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
Note
Do not add a thing to Thing.children directly, as that will break the parent-child relation

◆ RemoveChild()

RemoveChild (   self,
'Thing child 
)

Remove the given thing as a child of this thing.

Parameters
childThe child to remove

◆ GetChild()

Optional['Thing'] GetChild (   self,
int  thing_id,
bool   recurse = False 
)

Get a child by thing Id.

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

◆ FindChild()

Optional['Thing'] FindChild (   self,
str  name,
bool   recurse = True 
)

Find a thing by name.

Parameters
nameThe name of the thing
Returns
The found thing or nullptr when nothing is found
Parameters
recurseLook recursively through all descendants

◆ SetPosition()

None SetPosition (   self,
Spherical  position 
)

Set the position of the thing.

Parameters
positionThe new position in local space, in meters

◆ SetOrientation()

None SetOrientation (   self,
Quaternion  orientation 
)

Set the orientation of the thing.

Parameters
orientationThe new orientation in local space

◆ SetLinearVelocity()

None SetLinearVelocity (   self,
Spherical  linear_velocity 
)

Set the linear velocity of the thing.

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

◆ SetAngularVelocity()

None SetAngularVelocity (   self,
Spherical  angular_velocity 
)

Set the angular velocity of the thing.

Parameters
angularVelocitythe new angular velocity in local space

◆ GetTimeMs()

int GetTimeMs ( )
static

Get the current time in milliseconds.

Returns
The current time in milliseconds

◆ Update()

None Update (   self,
int   currentTimeMs = 0,
bool   recurse = False 
)

Update de state of the thing.

Parameters
currentTimeMsThe current clock time in milliseconds; If this is zero, the current time is retrieved automatically
recurseWhen true, this will Update the descendants recursively

Reimplemented in DifferentialDrive.

◆ GenerateBinary()

int GenerateBinary (   self,
bytearray  bytes,
set[int]  ix_ref 
)

Function used to generate binary data for this thing.

Parameters
bufferThe byte array for thw binary data
ix_refA single element array with the starting position for writing the binary data
Returns
The size of the binary data

Reimplemented in TouchSensor, TemperatureSensor, and TouchSensor.

◆ ProcessBinary()

ProcessBinary (   self,
bytes  data 
)

Function used to process binary data received for this thing.

Parameters
bytesThe binary data

Reimplemented in TouchSensor, TemperatureSensor, and TouchSensor.


The documentation for this class was generated from the following file: