2024-01-31 09:50:48 +01:00

71 lines
1.7 KiB
C++

#pragma once
#include "VectorAlgebra/Polar.h"
namespace Passer {
namespace RoboidControl {
/// @brief A thing is a functional component on a robot
class Thing {
public:
/// @brief Default constructor for a Thing
Thing();
/// @brief The type of Thing
unsigned int type;
/// @brief The type of a switch sensor
static const unsigned int SwitchType;
/// @brief The type of a distance sensor
static const unsigned int DistanceSensorType;
/// @brief The type of a controlled motor
static const unsigned int ControlledMotorType;
/// @brief The type of an uncontrolled motor
static const unsigned int UncontrolledMotorType;
/// @brief The type of an object received from the network
static const unsigned int ServoType;
static const unsigned int ExternalType;
/// @brief Check if the Thing is a Motor
/// @returns True when the Thing is a Motor and False otherwise
bool IsMotor();
/// @brief Check if the Thing is a Sensor
/// @returns True when the Thing is a Sensor and False otherwise
bool IsSensor();
Polar position;
void SetParent(Thing *parent);
Thing *GetParent();
void AddChild(Thing *child);
Thing *GetChild(unsigned char childIx);
protected:
/// @brief Bitmask for Motor type
static const unsigned int MotorType = 0x8000;
/// @brief Bitmap for Sensor type
static const unsigned int SensorType = 0x4000;
/// @brief Basic Thing types
enum class Type {
Undetermined,
// Sensor,
Switch,
DistanceSensor,
// Motor,
ControlledMotor,
UncontrolledMotor,
Servo,
// Other
ExternalSensor,
};
Thing *parent = nullptr;
unsigned char childCount = 0;
Thing **children = nullptr;
};
} // namespace RoboidControl
} // namespace Passer
using namespace Passer::RoboidControl;