This commit is contained in:
Pascal Serrarens 2024-06-17 12:03:57 +02:00
parent c52d009c91
commit 7dfd2b0004
4 changed files with 19 additions and 18 deletions

View File

@ -19,7 +19,7 @@ void ControlledMotor::SetTargetSpeed(float speed) {
// : Motor::Direction::Clockwise;
}
void ControlledMotor::Update(float currentTimeMs) {
void ControlledMotor::Update(unsigned long currentTimeMs) {
this->actualSpeed = encoder->GetRevolutionsPerSecond(currentTimeMs);
if (this->currentTargetSpeed < 0)
this->actualSpeed = -this->actualSpeed;

View File

@ -35,8 +35,8 @@ void NetworkSync::ReceiveNetworkId() {
// delay(100);
PublishModel(roboid);
// delay(100);
if (roboid->actuation != nullptr)
PublishRelativeThing(roboid->actuation, true);
if (roboid->childCount > 0)
PublishRelativeThing(roboid->GetChild(0), true);
}
void NetworkSync::NewObject(InterestingThing *thing) {
@ -89,11 +89,11 @@ void NetworkSync::PublishModel(Roboid *roboid) {
return;
unsigned char ix = 0;
buffer[ix++] = 0x90; // modelMsg
buffer[ix++] = 0x00; // objectId
Spherical s = Spherical(roboid->modelPosition);
buffer[ix++] = 0x90; // modelMsg
buffer[ix++] = 0x00; // objectId
Spherical s = Spherical::zero; //(roboid->modelPosition);
SendSpherical(buffer, &ix, s);
SendFloat16(buffer, &ix, roboid->modelScale);
SendFloat16(buffer, &ix, 1); // roboid->modelScale);
buffer[ix++] = len;
for (int urlIx = 0; urlIx < len; urlIx++)
@ -111,11 +111,11 @@ void NetworkSync::PublishModel(Thing *thing) {
return;
unsigned char ix = 0;
buffer[ix++] = 0x90; // modelMsg
buffer[ix++] = thing->id; // objectId
Spherical s = Spherical(thing->modelPosition);
buffer[ix++] = 0x90; // modelMsg
buffer[ix++] = thing->id; // objectId
Spherical s = Spherical::zero; // Spherical(thing->modelPosition);
SendSpherical(buffer, &ix, s);
SendFloat16(buffer, &ix, thing->modelScale);
SendFloat16(buffer, &ix, 1); // thing->modelScale);
buffer[ix++] = len;
for (int urlIx = 0; urlIx < len; urlIx++)
@ -168,7 +168,7 @@ void NetworkSync::SendPose(Roboid *roboid, bool recurse) {
if (recurse) {
// delay(10);
Thing *child = roboid->actuation;
Thing *child = roboid->GetChild(0); // actuation;
if (child != nullptr)
SendPose(child, true);
}
@ -213,8 +213,8 @@ void NetworkSync::PublishTrackedObjects(Roboid *roboid,
InterestingThing *obj = objects[objIx];
if (obj == nullptr)
continue;
if (obj->sensor->type == Thing::ExternalType)
continue;
// if (obj->sensor->type == Thing::ExternalType)
// continue;
if (obj->confidence > 0) {
PublishTrackedObject(roboid, obj);

View File

@ -72,7 +72,7 @@ public:
void SendPose(Roboid *roboid, bool recurse = true);
void SendPose(Thing *thing, bool recurse = true);
virtual void SendText(const char *s) {};
virtual void SendText(const char *s);
protected:
Roboid *roboid;

View File

@ -76,6 +76,10 @@ public:
/// @param currentTimeMs The current clock time in milliseconds
virtual void Update(unsigned long currentTimeMs) {}
unsigned char childCount = 0;
const char *modelUrl = nullptr;
protected:
/// @brief Bitmask for Motor type
static const unsigned int MotorType = 0x8000;
@ -99,10 +103,7 @@ protected:
};
Thing *parent = nullptr;
unsigned char childCount = 0;
Thing **children = nullptr;
const char *modelUrl = nullptr;
};
} // namespace RoboidControl