Generic Network sync

This commit is contained in:
Pascal Serrarens 2023-12-31 09:52:51 +01:00
parent 5e6bd0e748
commit 8e7be85ac6
4 changed files with 26 additions and 39 deletions

22
NetworkSync.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include "Perception.h"
#include "Roboid.h"
namespace Passer {
namespace RoboidControl {
class NetworkSync {
public:
virtual void NetworkUpdate(Roboid *roboid) = 0;
virtual void DestroyObject(PerceivedObject *obj) = 0;
static const char PoseMsg = 0x10;
static const char Pose_Position = 0x01;
static const char Pose_Orientation = 0x02;
static const char Pose_LinearVelocity = 0x04;
static const char Pose_AngularVelocity = 0x08;
};
} // namespace RoboidControl
} // namespace Passer

View File

@ -1,7 +1,7 @@
#include "Perception.h"
#include "Angle.h"
#include "DistanceSensor.h"
#include "RoboidWiFi.h"
#include "NetworkSync.h"
#include "Switch.h"
#include <Arduino.h>
@ -46,23 +46,6 @@ float Perception::GetDistance(float direction, float range) {
if (range < 0)
range = -range;
// for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
// Placement placement = sensorPlacements[sensorIx];
// // This still needs support for angles wrapping around 180 degrees !!!!
// if (placement.horizontalDirection > direction - range &&
// placement.horizontalDirection < direction + range) {
// Thing *thing = placement.thing;
// if (thing == nullptr)
// continue;
// if (thing->type == Thing::DistanceSensorType) {
// DistanceSensor *distanceSensor = (DistanceSensor *)thing;
// if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
// minDistance = fmin(minDistance, distanceSensor->GetDistance());
// }
// }
// }
for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) {
PerceivedObject *obj = perceivedObjects[objIx];
if (obj == nullptr)
@ -82,24 +65,6 @@ float Perception::GetDistance(float horizontalDirection,
if (range < 0)
range = -range;
// for (unsigned int sensorIx = 0; sensorIx < this->sensorCount; sensorIx++) {
// Placement placement = sensorPlacements[sensorIx];
// // This still needs support for angles wrapping around 180 degrees !!!!
// if (placement.horizontalDirection > horizontalDirection - range &&
// placement.horizontalDirection < horizontalDirection + range &&
// placement.verticalDirection > verticalDirection - range &&
// placement.verticalDirection < verticalDirection + range) {
// Thing *thing = placement.thing;
// if (thing == nullptr)
// continue;
// if (thing->type == Thing::DistanceSensorType) {
// DistanceSensor *distanceSensor = (DistanceSensor *)thing;
// if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
// minDistance = fmin(minDistance, distanceSensor->GetDistance());
// }
// }
// }
for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) {
PerceivedObject *obj = perceivedObjects[objIx];
if (obj == nullptr)

View File

@ -1,6 +1,6 @@
#include "Roboid.h"
#include "RoboidWiFi.h"
#include "NetworkSync.h"
Roboid::Roboid() {}

View File

@ -6,7 +6,7 @@
namespace Passer {
namespace RoboidControl {
class RoboidWiFi;
class NetworkSync;
/// @brief A Roboid is used to control autonomous robots
class Roboid {
@ -28,7 +28,7 @@ public:
/// @brief The Propulsion module of this Roboid
Propulsion *propulsion;
RoboidWiFi *networkSync = nullptr;
NetworkSync *networkSync = nullptr;
};
} // namespace RoboidControl