2024-12-28 11:15:43 +01:00

85 lines
3.3 KiB
C++

#pragma once
#include "Perception.h"
#include "Propulsion.h"
#include "ServoMotor.h"
namespace Passer {
namespace RoboidControl {
class NetworkSync;
/// @brief A Roboid is used to control autonomous robots
class Roboid : public Thing {
public:
/// @brief Default constructor for a Roboid
Roboid();
/// @brief Creates a Roboid with Perception and Propulsion abilities
/// @param perception The Perception implementation to use for this Roboid
/// @param propulsion The Propulsion implementation to use for this Roboid
Roboid(Propulsion *propulsion);
/// @brief Update the state of the Roboid
/// @param currentTimeMs The time in milliseconds when calling this
/// function
void Update(unsigned long currentTimeMs);
/// @brief The Perception module of this Roboid
Perception *perception = nullptr;
/// @brief The Propulsion module of this Roboid
Propulsion *propulsion = nullptr;
// ServoMotor *actuation = nullptr;
/// @brief The reference to the module to synchronize states across a network
NetworkSync *networkSync = nullptr;
/// @brief Retrieve the current position of the roboid
/// @return The position in carthesian coordinates in world space
/// @details The origin and units of the position depends on the position
/// tracking system used. This value will be Vector3::zero unless a position
/// is received through network synchronisation
// virtual Spherical16 GetPosition();
// Vector2 GetPosition2D();
/// @brief Retrieve the current orientation of the roboid
/// @return The orientation quaternion in world space
/// @details The origin orientation depends on the position tracking system
/// used. This value will be Quaternion::identity unless an orientation is
/// received though network synchronization
// virtual SwingTwist16 GetOrientation();
/// @brief Update the current position of the roboid
/// @param worldPosition The position of the roboid in carthesian coordinates
/// in world space
/// @details The use of this function will also update the positions and
/// orientations of the perceived objects by the roboid
/// (roboid->perception->perceivedObjects), as these are local to the
/// roboid's position.
// virtual void SetPosition(Spherical16 worldPosition);
/// @brief Update the current orientation of the roboid
/// @param worldOrientation The orientation of the roboid in world space
/// @details The use of this function will also update the orientations of the
/// perceived objects by the roboid (roboid->perception->perceivedObjets),
/// as these are local to the roboid' orientation.
// virtual void SetOrientation(SwingTwist16 worldOrientation);
// virtual void AddChild(Thing *child) override;
void Release(Thing *child);
Thing *worldOrigin =
nullptr; // thing to track the world origin to be able to transform
// world coordinates into roboid or local coordinates
// Perhaps this will move to perception at some point
/// @brief Loads the model and adds the skeleton (if any) to the roboid
/// @param url The url of the model
/// @remark The only supported model format is .gltf
void LoadModel(const char *url);
private:
unsigned long lastUpdateTimeMs = 0;
};
} // namespace RoboidControl
} // namespace Passer
using namespace Passer::RoboidControl;