RoboidControl
Loading...
Searching...
No Matches
d:/PlatformIO/RoboidControl/ControlledMotor.h
Go to the documentation of this file.
1#pragma once
2
3#include "Encoder.h"
4#include "Motor.h"
5
6namespace Passer {
7namespace RoboidControl {
8
12class ControlledMotor : public Motor {
13public:
16
17 inline static bool CheckType(Thing *thing) {
18 return (thing->type & (int)Thing::Type::ControlledMotor) != 0;
19 }
20 float velocity;
21
22 float pidP = 0.1F;
23 float pidD = 0.0F;
24 float pidI = 0.0F;
25
26 void Update(float currentTimeMs) override;
27
30 virtual void SetTargetSpeed(float speed) override;
31
34 virtual float GetActualSpeed() override;
35
36 bool Drive(float distance);
37
40
41protected:
42 float lastUpdateTime = 0;
43 float lastError = 0;
44 // float targetSpeed;
46 float netDistance = 0;
47 float startDistance = 0;
48
49 // enum Direction { Forward = 1, Reverse = -1 };
50
51 // Direction rotationDirection;
52
53 bool driving = false;
54 float targetDistance = 0;
56};
57
58} // namespace RoboidControl
59} // namespace Passer
60using namespace Passer::RoboidControl;
A motor with speed control It uses a feedback loop from an encoder to regulate the speed The speed is...
Definition ControlledMotor.h:12
float lastError
Definition ControlledMotor.h:43
Motor * motor
Definition ControlledMotor.h:38
float velocity
Definition ControlledMotor.h:20
Encoder * encoder
Definition ControlledMotor.h:39
float targetDistance
Definition ControlledMotor.h:54
float pidI
Definition ControlledMotor.h:24
bool Drive(float distance)
Definition ControlledMotor.cpp:54
bool driving
Definition ControlledMotor.h:53
float startDistance
Definition ControlledMotor.h:47
static bool CheckType(Thing *thing)
Definition ControlledMotor.h:17
float actualSpeed
Definition ControlledMotor.h:45
ControlledMotor()
Definition ControlledMotor.cpp:3
void Update(float currentTimeMs) override
Definition ControlledMotor.cpp:22
virtual float GetActualSpeed() override
Get the actual speed from the encoder.
Definition ControlledMotor.cpp:52
float pidD
Definition ControlledMotor.h:23
float lastUpdateTime
Definition ControlledMotor.h:42
float pidP
Definition ControlledMotor.h:22
virtual void SetTargetSpeed(float speed) override
Set the target speed for the motor controller.
Definition ControlledMotor.cpp:14
float netDistance
Definition ControlledMotor.h:46
float lastEncoderPosition
Definition ControlledMotor.h:55
An Encoder measures the rotations of an axle using a rotary sensor Some encoders are able to detect d...
Definition IncrementalEncoder.h:8
A Motor is a Thing which can move parts of the Roboid.
Definition Motor.h:12
A thing is a functional component on a robot.
Definition Thing.h:9
unsigned int type
The type of Thing.
Definition Thing.h:15
Definition Accelerometer.h:7
Definition AbsoluteEncoder.h:5