Roboid Control for C++ 0.4
Loading...
Searching...
No Matches
ControlledMotor.h
1#pragma once
2
3#include "Motor.h"
4#include "RelativeEncoder.h"
5
6namespace RoboidControl {
7
11class ControlledMotor : public Motor {
12 public:
13 ControlledMotor(Motor* motor, RelativeEncoder* encoder, Thing* parent = Thing::LocalRoot());
14
15 float pidP = 0.5;
16 float pidD = 0;
17 float pidI = 0.2;
18
21
22 enum Direction { Forward = 1, Reverse = -1 };
23 Direction rotationDirection;
24
25 virtual void Update(bool recurse = false) override;
26
29 virtual void SetTargetVelocity(float velocity) override;
30
31 Motor* motor;
32 RelativeEncoder* encoder;
33
34 protected:
35 float integral = 0;
36 float lastError = 0;
37 float lastUpdateTime;
38};
39
40} // namespace RoboidControl
A motor with speed control It uses a feedback loop from an encoder to regulate the speed The speed is...
Definition ControlledMotor.h:11
virtual void SetTargetVelocity(float velocity) override
Set the target verlocity for the motor controller.
Definition ControlledMotor.cpp:17
float actualVelocity
The actual velocity in revolutions per second.
Definition ControlledMotor.h:20
virtual void Update(bool recurse=false) override
Updates the state of the thing.
Definition ControlledMotor.cpp:23
An Incremental Encoder measures the rotations of an axle using a rotary sensor. Some encoders are abl...
Definition RelativeEncoder.h:10
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