Roboid Control for C#
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Properties | Events | List of all members
RoboidControl.DifferentialDrive Class Reference

Detailed Description

A thing which can move itself using a differential drive system.

See also
https://en.wikipedia.org/wiki/Differential_wheeled_robot
Inheritance diagram for RoboidControl.DifferentialDrive:
RoboidControl.Thing

Public Types

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

Public Member Functions

 DifferentialDrive ()
 Create a differential drive without networking support.
 
 DifferentialDrive (LocalParticipant participant)
 Create a differential drive with networking support.
 
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.
 
override void Update (ulong currentMs, bool recursive=true)
 
virtual void CreateComponent ()
 Function which can be used to create components in external engines.
 
delegate void ChangeHandler ()
 
delegate void SphericalHandler (Spherical v)
 
delegate void ThingHandler (Thing t)
 
void AddChild (Thing child)
 Attach a thing as a child of this thing.
 
void RemoveChild (Thing child)
 Remove the given thing as a child of this thing.
 
void Update (bool recursive=false)
 Convience function for use in Unity which removes the need for a currentTime argument.
 
virtual byte[] GenerateBinary ()
 Function used to generate binary data for this thing.
 
virtual void ProcessBinary (byte[] bytes)
 Function used to process binary data received for this thing.
 

Static Public Member Functions

static void InvokeNewThing (Thing thing)
 Trigger the creation for the given thing.
 
static bool IsThing (Thing thing, byte networkId, byte thingId)
 Check if the thing has the given properaties.
 

Public Attributes

Participant owner
 The participant to which this thing belongs.
 
byte networkId
 The network ID of this thing.
 
byte id
 The ID of this thing.
 
byte type
 The type of this thing. This can be either a Thing::Type (needs casting) or a byte value for custom types.
 
List< Thingchildren = new List<Thing>()
 The list of children of this thing.
 
string modelUrl = ""
 An URL pointing to the location where a model of the thing can be found.
 
bool hasPosition = false
 
Spherical angularVelocity = Spherical.zero
 The angular velocity of the thing in local space.
 
Unity.Thing component = null
 A reference to the representation of the thing in Unity.
 

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 = null
 The left wheel.
 
Thing rightWheel = null
 The right wheel.
 

Properties

Thing parent [get, set]
 The parent of this thing.
 
virtual string name [get, set]
 The name of the thing.
 
Spherical position [get, set]
 The position of the thing in local space, in meters.
 
SwingTwist orientation [get, set]
 The orientation of the thing in local space.
 
Spherical linearVelocity [get, set]
 The linear velocity of the thing in local space in meters per second.
 

Events

ChangeHandler OnParentChanged = delegate { }
 Event which is triggered when the parent changes.
 
ChangeHandler OnNameChanged = delegate { }
 Event which is triggered when the name changes.
 
ChangeHandler OnPositionChanged = delegate { }
 Event triggered when the position has changed.
 
ChangeHandler OnOrientationChanged = delegate { }
 Event triggered when the orientation has changed.
 
SphericalHandler OnLinearVelocityChanged = delegate { }
 Event triggered when the linear velocity has changed.
 
static ThingHandler OnNewThing = delegate { }
 Event triggered when a new thing has been created.
 

Constructor & Destructor Documentation

◆ DifferentialDrive()

RoboidControl.DifferentialDrive.DifferentialDrive ( LocalParticipant  participant)

Create a differential drive with networking support.

Parameters
participantThe local participant

Member Function Documentation

◆ SetDriveDimensions()

void RoboidControl.DifferentialDrive.SetDriveDimensions ( float  wheelDiameter,
float  wheelSeparation 
)

Configures the dimensions of the drive.

Parameters
wheelDiameterThe diameter of the wheels in meters
wheelSeparationThe distance between the wheels in meters

These values are used to compute the desired wheel speed from the set linear and angular velocity.

See also
SetLinearVelocity SetAngularVelocity

◆ SetMotors()

void RoboidControl.DifferentialDrive.SetMotors ( Thing  leftWheel,
Thing  rightWheel 
)

Congures the motors for the wheels.

Parameters
leftWheelThe motor for the left wheel
rightWheelThe motor for the right wheel

◆ SetWheelVelocity()

void RoboidControl.DifferentialDrive.SetWheelVelocity ( float  speedLeft,
float  speedRight 
)

Directly specify the speeds of the motors.

Parameters
speedLeftThe speed of the left wheel in degrees per second. Positive moves the robot in the forward direction.
speedRightThe speed of the right wheel in degrees per second. Positive moves the robot in the forward direction.

◆ Update()

override void RoboidControl.DifferentialDrive.Update ( ulong  currentMs,
bool  recursive = true 
)
virtual

Reimplemented from RoboidControl.Thing.

◆ CreateComponent()

virtual void RoboidControl.Thing.CreateComponent ( )
virtualinherited

Function which can be used to create components in external engines.

Currently this is used to create GameObjects in Unity

Reimplemented in RoboidControl.DistanceSensor, and RoboidControl.TouchSensor.

◆ AddChild()

void RoboidControl.Thing.AddChild ( Thing  child)
inherited

Attach a thing as a child of this thing.

Parameters
childThe thing to attach as a child

◆ RemoveChild()

void RoboidControl.Thing.RemoveChild ( Thing  child)
inherited

Remove the given thing as a child of this thing.

Parameters
childThe child to remove

◆ GenerateBinary()

virtual byte[] RoboidControl.Thing.GenerateBinary ( )
virtualinherited

Function used to generate binary data for this thing.

Returns
a byte array with the binary data
See also
Passer::RoboidControl::BinaryMsg

Reimplemented in RoboidControl.TouchSensor.

◆ ProcessBinary()

virtual void RoboidControl.Thing.ProcessBinary ( byte[]  bytes)
virtualinherited

Function used to process binary data received for this thing.

Parameters
bytesThe binary data

Reimplemented in RoboidControl.DistanceSensor, and RoboidControl.TemperatureSensor.

◆ InvokeNewThing()

static void RoboidControl.Thing.InvokeNewThing ( Thing  thing)
staticinherited

Trigger the creation for the given thing.

Parameters
thingThe created thing

◆ IsThing()

static bool RoboidControl.Thing.IsThing ( Thing  thing,
byte  networkId,
byte  thingId 
)
staticinherited

Check if the thing has the given properaties.

Parameters
thingThe thing to check
networkIdThe network ID to compare to
thingIdThe thing ID to compare to
Returns
True when the thing has the given properties