RoboidControl
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Attributes | Static Protected Attributes | List of all members
Passer::RoboidControl::ControlledMotor Class Reference

A motor with speed control It uses a feedback loop from an encoder to regulate the speed The speed is measured in revolutions per second. More...

#include <ControlledMotor.h>

Inheritance diagram for Passer::RoboidControl::ControlledMotor:
Passer::RoboidControl::Motor Passer::RoboidControl::Thing

Public Types

enum class  Direction { Clockwise = 1 , CounterClockwise = -1 }
 Motor turning direction. More...
 

Public Member Functions

 ControlledMotor ()
 
 ControlledMotor (Motor *motor, Encoder *encoder)
 
void Update (float currentTimeMs) override
 
virtual void SetTargetSpeed (float speed) override
 Set the target speed for the motor controller.
 
virtual float GetActualSpeed () override
 Get the actual speed from the encoder.
 
bool Drive (float distance)
 
virtual float GetTargetSpeed ()
 Get the current target speed of the motor.
 
bool IsMotor ()
 Check if the Thing is a Motor.
 
bool IsSensor ()
 Check if the Thing is a Sensor.
 
void SetParent (Thing *parent)
 
ThingGetParent ()
 
void AddChild (Thing *child)
 
ThingGetChild (unsigned char childIx)
 

Static Public Member Functions

static bool CheckType (Thing *thing)
 

Public Attributes

float velocity
 
float pidP = 0.1F
 
float pidD = 0.0F
 
float pidI = 0.0F
 
Motormotor
 
Encoderencoder
 
Direction direction = Direction::Clockwise
 The forward turning direction of the motor.
 
float currentTargetSpeed = 0
 
unsigned int type
 The type of Thing.
 
Polar position
 

Static Public Attributes

static const unsigned int SwitchType = SensorType | (unsigned int)Type::Switch
 The type of a switch sensor.
 
static const unsigned int DistanceSensorType
 The type of a distance sensor.
 
static const unsigned int ControlledMotorType
 The type of a controlled motor.
 
static const unsigned int UncontrolledMotorType
 The type of an uncontrolled motor.
 
static const unsigned int ServoType = (unsigned int)Type::Servo
 The type of an object received from the network.
 
static const unsigned int ExternalType = (unsigned int)Type::ExternalSensor
 

Protected Types

enum class  Type {
  Undetermined , Switch , DistanceSensor , ControlledMotor ,
  UncontrolledMotor , Servo , ExternalSensor
}
 Basic Thing types. More...
 

Protected Attributes

float lastUpdateTime = 0
 
float lastError = 0
 
float actualSpeed
 
float netDistance = 0
 
float startDistance = 0
 
bool driving = false
 
float targetDistance = 0
 
float lastEncoderPosition = 0
 
Thingparent = nullptr
 
unsigned char childCount = 0
 
Thing ** children = nullptr
 

Static Protected Attributes

static const unsigned int MotorType = 0x8000
 Bitmask for Motor type.
 
static const unsigned int SensorType = 0x4000
 Bitmap for Sensor type.
 

Detailed Description

A motor with speed control It uses a feedback loop from an encoder to regulate the speed The speed is measured in revolutions per second.

Member Enumeration Documentation

◆ Direction

enum class Passer::RoboidControl::Motor::Direction
stronginherited

Motor turning direction.

Enumerator
Clockwise 
CounterClockwise 

◆ Type

enum class Passer::RoboidControl::Thing::Type
strongprotectedinherited

Basic Thing types.

Enumerator
Undetermined 
Switch 
DistanceSensor 
ControlledMotor 
UncontrolledMotor 
Servo 
ExternalSensor 

Constructor & Destructor Documentation

◆ ControlledMotor() [1/2]

ControlledMotor::ControlledMotor ( )

◆ ControlledMotor() [2/2]

ControlledMotor::ControlledMotor ( Motor motor,
Encoder encoder 
)

Member Function Documentation

◆ CheckType()

static bool Passer::RoboidControl::ControlledMotor::CheckType ( Thing thing)
inlinestatic

◆ Update()

void ControlledMotor::Update ( float  currentTimeMs)
overridevirtual

Reimplemented from Passer::RoboidControl::Motor.

◆ SetTargetSpeed()

void ControlledMotor::SetTargetSpeed ( float  speed)
overridevirtual

Set the target speed for the motor controller.

Parameters
speedthe target in revolutions per second.

Reimplemented from Passer::RoboidControl::Motor.

◆ GetActualSpeed()

float ControlledMotor::GetActualSpeed ( )
overridevirtual

Get the actual speed from the encoder.

Returns
The speed in revolutions per second

Reimplemented from Passer::RoboidControl::Motor.

◆ Drive()

bool ControlledMotor::Drive ( float  distance)

◆ GetTargetSpeed()

float Motor::GetTargetSpeed ( )
virtualinherited

Get the current target speed of the motor.

Returns
The speed between -1 (full backward), 0 (stop) and 1 (full forward)

◆ IsMotor()

bool Thing::IsMotor ( )
inherited

Check if the Thing is a Motor.

Returns
True when the Thing is a Motor and False otherwise

◆ IsSensor()

bool Thing::IsSensor ( )
inherited

Check if the Thing is a Sensor.

Returns
True when the Thing is a Sensor and False otherwise

◆ SetParent()

void Thing::SetParent ( Thing parent)
inherited

◆ GetParent()

Thing * Thing::GetParent ( )
inherited

◆ AddChild()

void Thing::AddChild ( Thing child)
inherited

◆ GetChild()

Thing * Thing::GetChild ( unsigned char  childIx)
inherited

Member Data Documentation

◆ velocity

float Passer::RoboidControl::ControlledMotor::velocity

◆ pidP

float Passer::RoboidControl::ControlledMotor::pidP = 0.1F

◆ pidD

float Passer::RoboidControl::ControlledMotor::pidD = 0.0F

◆ pidI

float Passer::RoboidControl::ControlledMotor::pidI = 0.0F

◆ motor

Motor* Passer::RoboidControl::ControlledMotor::motor

◆ encoder

Encoder* Passer::RoboidControl::ControlledMotor::encoder

◆ lastUpdateTime

float Passer::RoboidControl::ControlledMotor::lastUpdateTime = 0
protected

◆ lastError

float Passer::RoboidControl::ControlledMotor::lastError = 0
protected

◆ actualSpeed

float Passer::RoboidControl::ControlledMotor::actualSpeed
protected

◆ netDistance

float Passer::RoboidControl::ControlledMotor::netDistance = 0
protected

◆ startDistance

float Passer::RoboidControl::ControlledMotor::startDistance = 0
protected

◆ driving

bool Passer::RoboidControl::ControlledMotor::driving = false
protected

◆ targetDistance

float Passer::RoboidControl::ControlledMotor::targetDistance = 0
protected

◆ lastEncoderPosition

float Passer::RoboidControl::ControlledMotor::lastEncoderPosition = 0
protected

◆ direction

Direction Passer::RoboidControl::Motor::direction = Direction::Clockwise
inherited

The forward turning direction of the motor.

◆ currentTargetSpeed

float Passer::RoboidControl::Motor::currentTargetSpeed = 0
inherited

◆ type

unsigned int Passer::RoboidControl::Thing::type
inherited

The type of Thing.

◆ SwitchType

const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch
staticinherited

The type of a switch sensor.

◆ DistanceSensorType

const unsigned int Thing::DistanceSensorType
staticinherited
Initial value:
=
static const unsigned int SensorType
Bitmap for Sensor type.
Definition Thing.h:48

The type of a distance sensor.

◆ ControlledMotorType

const unsigned int Thing::ControlledMotorType
staticinherited
Initial value:
=
static const unsigned int MotorType
Bitmask for Motor type.
Definition Thing.h:46

The type of a controlled motor.

◆ UncontrolledMotorType

const unsigned int Thing::UncontrolledMotorType
staticinherited
Initial value:

The type of an uncontrolled motor.

◆ ServoType

const unsigned int Thing::ServoType = (unsigned int)Type::Servo
staticinherited

The type of an object received from the network.

◆ ExternalType

const unsigned int Thing::ExternalType = (unsigned int)Type::ExternalSensor
staticinherited

◆ position

Polar Passer::RoboidControl::Thing::position
inherited

◆ MotorType

const unsigned int Passer::RoboidControl::Thing::MotorType = 0x8000
staticprotectedinherited

Bitmask for Motor type.

◆ SensorType

const unsigned int Passer::RoboidControl::Thing::SensorType = 0x4000
staticprotectedinherited

Bitmap for Sensor type.

◆ parent

Thing* Passer::RoboidControl::Thing::parent = nullptr
protectedinherited

◆ childCount

unsigned char Passer::RoboidControl::Thing::childCount = 0
protectedinherited

◆ children

Thing** Passer::RoboidControl::Thing::children = nullptr
protectedinherited

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