2024-05-31 09:53:21 +02:00

82 lines
2.2 KiB
C++

#pragma once
#include "LinearAlgebra/Polar.h"
#include "LinearAlgebra/Quaternion.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(unsigned char id);
/// @char The id of the thing
unsigned char id;
/// @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();
Spherical position;
Quaternion orientation;
void SetModel(const char *url, Vector3 position = Vector3(0, 0, 0),
Quaternion orientation = Quaternion::identity, float scale = 1);
const char *modelUrl = nullptr;
Vector3 modelPosition = Vector3::zero;
Quaternion modelOrientation = Quaternion::identity;
float modelScale = 1;
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;