RoboidControl
Loading...
Searching...
No Matches
d:/PlatformIO/RoboidControl/Thing.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace Passer {
6namespace RoboidControl {
7
9class Thing {
10public:
12 Thing();
13
15 unsigned int type;
16
18 static const unsigned int SwitchType;
20 static const unsigned int DistanceSensorType;
22 static const unsigned int ControlledMotorType;
24 static const unsigned int UncontrolledMotorType;
26 static const unsigned int ServoType;
27 static const unsigned int ExternalType;
28
31 bool IsMotor();
34 bool IsSensor();
35
36 Polar position;
37
38 void SetParent(Thing *parent);
40
41 void AddChild(Thing *child);
42 Thing *GetChild(unsigned char childIx);
43
44protected:
46 static const unsigned int MotorType = 0x8000;
48 static const unsigned int SensorType = 0x4000;
49
51 enum class Type {
53 // Sensor,
54 Switch,
56 // Motor,
59 Servo,
60 // Other
62 };
63
64 Thing *parent = nullptr;
65 unsigned char childCount = 0;
66 Thing **children = nullptr;
67};
68
69} // namespace RoboidControl
70} // namespace Passer
71using namespace Passer::RoboidControl;
A thing is a functional component on a robot.
Definition Thing.h:9
static const unsigned int DistanceSensorType
The type of a distance sensor.
Definition Thing.h:20
bool IsSensor()
Check if the Thing is a Sensor.
Definition Thing.cpp:24
static const unsigned int MotorType
Bitmask for Motor type.
Definition Thing.h:46
bool IsMotor()
Check if the Thing is a Motor.
Definition Thing.cpp:22
Thing()
Default constructor for a Thing.
Definition Thing.cpp:5
static const unsigned int ControlledMotorType
The type of a controlled motor.
Definition Thing.h:22
static const unsigned int UncontrolledMotorType
The type of an uncontrolled motor.
Definition Thing.h:24
Thing * GetParent()
Definition Thing.cpp:28
Thing * parent
Definition Thing.h:64
Thing ** children
Definition Thing.h:66
unsigned int type
The type of Thing.
Definition Thing.h:15
static const unsigned int SensorType
Bitmap for Sensor type.
Definition Thing.h:48
static const unsigned int SwitchType
The type of a switch sensor.
Definition Thing.h:18
unsigned char childCount
Definition Thing.h:65
static const unsigned int ServoType
The type of an object received from the network.
Definition Thing.h:26
Polar position
Definition Thing.h:36
void AddChild(Thing *child)
Definition Thing.cpp:30
void SetParent(Thing *parent)
Definition Thing.cpp:26
Type
Basic Thing types.
Definition Thing.h:51
static const unsigned int ExternalType
Definition Thing.h:27
Thing * GetChild(unsigned char childIx)
Definition Thing.cpp:45
Definition Accelerometer.h:7
Definition AbsoluteEncoder.h:5