diff --git a/NetworkSync.cpp b/NetworkSync.cpp index 6e60913..aa5a3b4 100644 --- a/NetworkSync.cpp +++ b/NetworkSync.cpp @@ -32,11 +32,11 @@ void NetworkSync::ReceiveNetworkId() { #ifdef RC_DEBUG printf("_Received network Id %d\n", this->networkId); #endif - delay(100); + // delay(100); PublishModel(roboid); - delay(100); - if (roboid->actuationRoot != nullptr) - PublishRelativeThing(roboid->actuationRoot, true); + // delay(100); + if (roboid->actuation != nullptr) + PublishRelativeThing(roboid->actuation, true); } void NetworkSync::NewObject(InterestingThing *thing) { @@ -69,10 +69,10 @@ void NetworkSync::PublishRelativeThing(Thing *thing, bool recurse) { SendSpherical(buffer, &ix, thing->position); SendBuffer(ix); - delay(100); + // delay(100); PublishModel(thing); - delay(1000); + // delay(1000); if (recurse) { Thing *child = thing->GetChild(0); if (child != nullptr) @@ -167,8 +167,8 @@ void NetworkSync::SendPose(Roboid *roboid, bool recurse) { SendBuffer(ix); if (recurse) { - delay(10); - Thing *child = roboid->actuationRoot; + // delay(10); + Thing *child = roboid->actuation; if (child != nullptr) SendPose(child, true); } @@ -184,7 +184,7 @@ void NetworkSync::SendPose(Thing *thing, bool recurse) { SendBuffer(ix); if (recurse) { - delay(10); + // delay(10); Thing *child = thing->GetChild(0); if (child != nullptr) SendPose(child, true); @@ -202,7 +202,7 @@ void NetworkSync::PublishClient() { #endif // PublishModel(roboid); - // if (roboid->actuationRoot != nullptr) + // if (roboid->actuation != nullptr) // PublishRelativeThing(roboid->actuationRoot, false); } diff --git a/Perception.cpp b/Perception.cpp index ef2e96b..a110bcd 100644 --- a/Perception.cpp +++ b/Perception.cpp @@ -446,6 +446,9 @@ InterestingThing *Perception::ThingOfType(unsigned char thingType) { } InterestingThing *Perception::GetMostInterestingThing() { + if (this->trackedObjects == nullptr) + return nullptr; + InterestingThing *closestObject = nullptr; float closestDistance = INFINITY; for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) { diff --git a/Roboid.cpp b/Roboid.cpp index f2a0417..31d103e 100644 --- a/Roboid.cpp +++ b/Roboid.cpp @@ -19,7 +19,7 @@ Roboid::Roboid() { this->perception->roboid = this; this->propulsion = nullptr; this->networkSync = nullptr; - this->actuationRoot = nullptr; + this->actuation = nullptr; this->worldPosition = Vector3::zero; // this->worldOrientation = Quaternion::identity; this->worldAngleAxis = AngleAxis(); @@ -37,15 +37,15 @@ Roboid::Roboid(Perception *perception, Propulsion *propulsion) : Roboid() { propulsion->roboid = this; } -Roboid::Roboid(Perception *perception, ServoMotor *actuationRoot) : Roboid() { +Roboid::Roboid(Perception *perception, ServoMotor *actuation) : Roboid() { this->perception = perception; perception->roboid = this; this->propulsion = nullptr; - this->actuationRoot = actuationRoot; + this->actuation = actuation; } -Roboid::Roboid(ServoMotor *actuationRoot) : actuationRoot(actuationRoot) {} +Roboid::Roboid(ServoMotor *actuation) : actuation(actuation) {} void Roboid::Update(float currentTimeMs) { if (perception != nullptr) @@ -64,8 +64,8 @@ void Roboid::Update(float currentTimeMs) { Vector3::up)); } - if (actuationRoot != nullptr) - actuationRoot->Update(currentTimeMs); + if (actuation != nullptr) + actuation->Update(currentTimeMs); if (networkSync != nullptr) networkSync->NetworkUpdate(this); diff --git a/Roboid.h b/Roboid.h index 28c7189..7b93d98 100644 --- a/Roboid.h +++ b/Roboid.h @@ -20,7 +20,7 @@ public: /// @param propulsion The Propulsion implementation to use for this Roboid Roboid(Perception *perception, Propulsion *propulsion = nullptr); - Roboid(Perception *perception, ServoMotor *actuationRoot); + Roboid(Perception *perception, ServoMotor *actuation); Roboid(ServoMotor *actuationRoot); @@ -33,7 +33,7 @@ public: Perception *perception = nullptr; /// @brief The Propulsion module of this Roboid Propulsion *propulsion = nullptr; - ServoMotor *actuationRoot = nullptr; + ServoMotor *actuation = nullptr; /// @brief The reference to the module to synchronize states across a network NetworkSync *networkSync = nullptr;