Roboid Control for C++ 0.4
Loading...
Searching...
No Matches
DifferentialDrive.h
1#pragma once
2
3#include "Thing.h"
4#include "Motor.h"
5
6namespace RoboidControl {
7
11class DifferentialDrive : public Thing {
12 public:
18
19 DifferentialDrive(Motor* leftMotor, Motor* rightMotor, Thing* parent = Thing::LocalRoot());
20
28 void SetDriveDimensions(float wheelDiameter, float wheelSeparation);
29
30 // Motor& GetMotorLeft();
31 // Motor& GetMotorRight();
35 void SetMotors(Motor& leftMotor, Motor& rightMotor);
36
42 void SetWheelVelocity(float speedLeft, float speedRight);
43
45 virtual void Update(bool recursive = true) override;
46
47 int GenerateBinary(char* bytes, unsigned char* ix) override;
48 // virtual void ProcessBinary(char* bytes) override;
49
51 Motor* leftWheel = nullptr;
53 Motor* rightWheel = nullptr;
54
55 protected:
57 float wheelRadius = 0.0f;
59 float wheelSeparation = 0.0f;
60
62 float rpsToMs = 1.0f;
63
64};
65
66} // namespace RoboidControl
A thing which can move itself using a differential drive system.
Definition DifferentialDrive.h:11
float rpsToMs
Convert revolutions per second to meters per second.
Definition DifferentialDrive.h:62
int GenerateBinary(char *bytes, unsigned char *ix) override
Function used to generate binary data for this thing.
Definition DifferentialDrive.cpp:98
void SetMotors(Motor &leftMotor, Motor &rightMotor)
Congures the motors for the wheels.
Definition DifferentialDrive.cpp:51
float wheelRadius
The radius of a wheel in meters.
Definition DifferentialDrive.h:57
void SetWheelVelocity(float speedLeft, float speedRight)
Directly specify the speeds of the motors.
Definition DifferentialDrive.cpp:60
Motor * leftWheel
The left wheel.
Definition DifferentialDrive.h:51
float wheelSeparation
The distance between the wheels in meters.
Definition DifferentialDrive.h:59
void SetDriveDimensions(float wheelDiameter, float wheelSeparation)
Configures the dimensions of the drive.
Definition DifferentialDrive.cpp:28
Motor * rightWheel
The right wheel.
Definition DifferentialDrive.h:53
virtual void Update(bool recursive=true) override
Definition DifferentialDrive.cpp:74
A thing is the primitive building block.
Definition Thing.h:20
static Thing * LocalRoot()
The root thing for the local participant.
Definition Thing.cpp:23