Generic Network sync
This commit is contained in:
parent
5e6bd0e748
commit
8e7be85ac6
22
NetworkSync.h
Normal file
22
NetworkSync.h
Normal 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
|
@ -1,7 +1,7 @@
|
|||||||
#include "Perception.h"
|
#include "Perception.h"
|
||||||
#include "Angle.h"
|
#include "Angle.h"
|
||||||
#include "DistanceSensor.h"
|
#include "DistanceSensor.h"
|
||||||
#include "RoboidWiFi.h"
|
#include "NetworkSync.h"
|
||||||
#include "Switch.h"
|
#include "Switch.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
@ -46,23 +46,6 @@ float Perception::GetDistance(float direction, float range) {
|
|||||||
if (range < 0)
|
if (range < 0)
|
||||||
range = -range;
|
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++) {
|
for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) {
|
||||||
PerceivedObject *obj = perceivedObjects[objIx];
|
PerceivedObject *obj = perceivedObjects[objIx];
|
||||||
if (obj == nullptr)
|
if (obj == nullptr)
|
||||||
@ -82,24 +65,6 @@ float Perception::GetDistance(float horizontalDirection,
|
|||||||
if (range < 0)
|
if (range < 0)
|
||||||
range = -range;
|
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++) {
|
for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) {
|
||||||
PerceivedObject *obj = perceivedObjects[objIx];
|
PerceivedObject *obj = perceivedObjects[objIx];
|
||||||
if (obj == nullptr)
|
if (obj == nullptr)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Roboid.h"
|
#include "Roboid.h"
|
||||||
|
|
||||||
#include "RoboidWiFi.h"
|
#include "NetworkSync.h"
|
||||||
|
|
||||||
Roboid::Roboid() {}
|
Roboid::Roboid() {}
|
||||||
|
|
||||||
|
4
Roboid.h
4
Roboid.h
@ -6,7 +6,7 @@
|
|||||||
namespace Passer {
|
namespace Passer {
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class RoboidWiFi;
|
class NetworkSync;
|
||||||
|
|
||||||
/// @brief A Roboid is used to control autonomous robots
|
/// @brief A Roboid is used to control autonomous robots
|
||||||
class Roboid {
|
class Roboid {
|
||||||
@ -28,7 +28,7 @@ public:
|
|||||||
/// @brief The Propulsion module of this Roboid
|
/// @brief The Propulsion module of this Roboid
|
||||||
Propulsion *propulsion;
|
Propulsion *propulsion;
|
||||||
|
|
||||||
RoboidWiFi *networkSync = nullptr;
|
NetworkSync *networkSync = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user