Network send position
This commit is contained in:
parent
08e053f05a
commit
c41fbbc309
@ -42,6 +42,8 @@ public:
|
|||||||
|
|
||||||
void PublishTrackedObjects(SendBuffer sendBuffer, InterestingThing **objects);
|
void PublishTrackedObjects(SendBuffer sendBuffer, InterestingThing **objects);
|
||||||
|
|
||||||
|
virtual void SendPosition(Vector3 worldPosition){};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NetworkPerception *networkPerception;
|
NetworkPerception *networkPerception;
|
||||||
void PublishTrackedObject(SendBuffer sendBuffer, InterestingThing *object);
|
void PublishTrackedObject(SendBuffer sendBuffer, InterestingThing *object);
|
||||||
|
14
Roboid.cpp
14
Roboid.cpp
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "NetworkSync.h"
|
#include "NetworkSync.h"
|
||||||
|
|
||||||
|
#define RC_DEBUG
|
||||||
|
|
||||||
#ifdef RC_DEBUG
|
#ifdef RC_DEBUG
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#endif
|
#endif
|
||||||
@ -10,12 +12,19 @@ Roboid::Roboid() {
|
|||||||
#ifdef RC_DEBUG
|
#ifdef RC_DEBUG
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
#endif
|
#endif
|
||||||
|
this->perception = new Perception();
|
||||||
|
this->perception->roboid = this;
|
||||||
|
this->propulsion = nullptr;
|
||||||
|
this->actuationRoot = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Roboid::Roboid(Perception *perception, Propulsion *propulsion) : Roboid() {
|
Roboid::Roboid(Perception *perception, Propulsion *propulsion) : Roboid() {
|
||||||
|
if (this->perception != nullptr)
|
||||||
|
delete this->perception;
|
||||||
this->perception = perception;
|
this->perception = perception;
|
||||||
if (perception != nullptr)
|
if (perception != nullptr)
|
||||||
perception->roboid = this;
|
perception->roboid = this;
|
||||||
|
|
||||||
this->propulsion = propulsion;
|
this->propulsion = propulsion;
|
||||||
if (propulsion != nullptr)
|
if (propulsion != nullptr)
|
||||||
propulsion->roboid = this;
|
propulsion->roboid = this;
|
||||||
@ -34,8 +43,10 @@ Roboid::Roboid(ServoMotor *actuationRoot) : actuationRoot(actuationRoot) {}
|
|||||||
void Roboid::Update(float currentTimeMs) {
|
void Roboid::Update(float currentTimeMs) {
|
||||||
if (perception != nullptr)
|
if (perception != nullptr)
|
||||||
perception->Update(currentTimeMs);
|
perception->Update(currentTimeMs);
|
||||||
|
|
||||||
if (propulsion != nullptr)
|
if (propulsion != nullptr)
|
||||||
propulsion->Update(currentTimeMs);
|
propulsion->Update(currentTimeMs);
|
||||||
|
|
||||||
if (networkSync != nullptr)
|
if (networkSync != nullptr)
|
||||||
networkSync->NetworkUpdate(this);
|
networkSync->NetworkUpdate(this);
|
||||||
|
|
||||||
@ -55,6 +66,9 @@ void Roboid::SetPosition(Vector3 newWorldPosition) {
|
|||||||
Polar polarTranslation = Polar(angle, distance);
|
Polar polarTranslation = Polar(angle, distance);
|
||||||
perception->UpdatePose(polarTranslation);
|
perception->UpdatePose(polarTranslation);
|
||||||
this->worldPosition = newWorldPosition;
|
this->worldPosition = newWorldPosition;
|
||||||
|
|
||||||
|
if (networkSync != nullptr)
|
||||||
|
networkSync->SendPosition(this->worldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Roboid::SetOrientation(Quaternion worldOrientation) {
|
void Roboid::SetOrientation(Quaternion worldOrientation) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user