Added Root & new Thing ref. constructor

This commit is contained in:
Pascal Serrarens 2025-05-17 18:09:38 +02:00
parent 17de9db0be
commit 3f8eadf8cc
2 changed files with 36 additions and 16 deletions

View File

@ -20,12 +20,28 @@ namespace RoboidControl {
#pragma region Init #pragma region Init
// Thing::Thing(unsigned char thingType) Thing Root = Thing(Thing::Type::Undetermined, Root);
// : Thing(IsolatedParticipant::Isolated(), thingType) {}
Thing::Thing(Participant* owner, Thing::Thing(unsigned char thingType, Thing& parent) {
unsigned char thingType) { this->type = thingType;
// unsigned char thingId) {
this->position = Spherical::zero;
this->positionUpdated = true;
this->orientation = SwingTwist::identity;
this->orientationUpdated = true;
this->hierarchyChanged = true;
this->linearVelocity = Spherical::zero;
this->angularVelocity = Spherical::zero;
// std::cout << "add thing [" << (int)this->id << "] to owner "
// << this->owner->ipAddress << ":" << this->owner->port <<
// std::endl;
this->owner->Add(this, true);
}
Thing::Thing(Participant* owner, unsigned char thingType) {
// unsigned char thingId) {
if (owner == nullptr) if (owner == nullptr)
owner = IsolatedParticipant::Isolated(); owner = IsolatedParticipant::Isolated();
this->owner = owner; this->owner = owner;

24
Thing.h
View File

@ -41,10 +41,9 @@ class Thing {
}; };
#pragma region Init #pragma region Init
static Thing Root; // = Thing(Type::Undetermined, Root);
/// @brief Create a new thing without communication abilities Thing(unsigned char thingType = Type::Undetermined, Thing& parent = Root);
/// @param thingType The type of thing (can use Thing::Type)
//Thing(unsigned char thingType = Type::Undetermined);
/// @brief Create a new thing for a participant /// @brief Create a new thing for a participant
/// @param owner The owning participant /// @param owner The owning participant
@ -53,7 +52,7 @@ class Thing {
/// an ID /// an ID
Thing(Participant* owner = nullptr, Thing(Participant* owner = nullptr,
unsigned char thingType = Type::Undetermined); unsigned char thingType = Type::Undetermined);
//unsigned char thingId = 0); // unsigned char thingId = 0);
/// @brief Create a new child thing /// @brief Create a new child thing
/// @param parent The parent thing /// @param parent The parent thing
@ -61,11 +60,14 @@ class Thing {
/// @param thingId The ID of the thing, leave out or set to zero to generate /// @param thingId The ID of the thing, leave out or set to zero to generate
/// an ID /// an ID
/// @note The owner will be the same as the owner of the parent thing /// @note The owner will be the same as the owner of the parent thing
Thing(Thing* parent, unsigned char thingType = 0); //, unsigned char thingId = 0); Thing(Thing* parent,
unsigned char thingType = 0); //, unsigned char thingId = 0);
static Thing Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId); static Thing Reconstruct(Participant* owner,
unsigned char thingType,
unsigned char thingId);
#pragma endregion Init #pragma endregion Init
public: public:
/// @brief Terminated things are no longer updated /// @brief Terminated things are no longer updated
@ -201,9 +203,11 @@ class Thing {
/// parent's orientation /// parent's orientation
SwingTwist orientation; SwingTwist orientation;
/// @brief The linear velocity of the thing in local space, in meters per second /// @brief The linear velocity of the thing in local space, in meters per
/// second
Spherical linearVelocity; Spherical linearVelocity;
/// @brief The angular velocity of the thing in local space, in degrees per second /// @brief The angular velocity of the thing in local space, in degrees per
/// second
Spherical angularVelocity; Spherical angularVelocity;
#pragma endregion Pose #pragma endregion Pose
@ -216,7 +220,7 @@ class Thing {
static unsigned long GetTimeMs(); static unsigned long GetTimeMs();
/// @brief Updates the state of the thing /// @brief Updates the state of the thing
//void Update(bool recursive = false); // void Update(bool recursive = false);
/// @brief Updates the state of the thing /// @brief Updates the state of the thing
/// @param currentTimeMs The current clock time in milliseconds; if this is /// @param currentTimeMs The current clock time in milliseconds; if this is