RoboidControl
Loading...
Searching...
No Matches
d:/PlatformIO/RoboidControl/NetworkSync.h
Go to the documentation of this file.
1#pragma once
2
3#include "NetworkPerception.h"
4#include "Perception.h"
5#include "Roboid.h"
6#include "Types.h"
7
8namespace Passer {
9namespace RoboidControl {
10
13public:
15
16 unsigned char networkId;
17
20 virtual void NetworkUpdate(Roboid *roboid) = 0;
23 virtual void DestroyObject(InterestingThing *obj) = 0;
24 virtual void NewObject(InterestingThing *obj) {};
26 static const unsigned char PoseMsg = 0x10;
27 static const unsigned char PoseTypeMsg = 0x11;
28 static const unsigned char RelativePoseMsg = 0x12;
31 static const unsigned char Pose_Position = 0x01;
34 static const unsigned char Pose_Orientation = 0x02;
37 static const unsigned char Pose_LinearVelocity = 0x04;
40 static const char Pose_AngularVelocity = 0x08;
41
42 static const unsigned char DestroyMsg = 0x20;
43
44 static const unsigned char AngVelocity2DMsg = 0x46;
45 static const unsigned char Position2DMsg = 0x61;
46 static const unsigned char Velocity2DMsg = 0x62;
47 static const unsigned char CreateMsg = 0x80;
48 static const unsigned char InvestigateMsg = 0x81;
49 static const unsigned char ClientMsg = 0xA0;
50 static const unsigned char NetworkIdMsg = 0xA1;
51
52 typedef void (*Buffer)(UInt8 *buffer, UInt16 bufferSize);
53
54 void ReceiveMessage(Roboid *roboid, unsigned char bytecount);
55
56 void ReceiveNetworkId();
57
59
60 void SendPoseMsg(Buffer sendBuffer, Roboid *roboid);
61 void SendDestroyObject(Buffer sendBuffer, InterestingThing *obj);
63
64 void PublishTrackedObjects(Buffer sendBuffer, InterestingThing **objects);
65
66 virtual void SendPosition(Vector3 worldPosition) {};
67 virtual void SendPose(Vector3 worldPosition, Quaternion worldOrientation) {};
68
69protected:
71 void PublishTrackedObject(Buffer sendBuffer, InterestingThing *object);
72 void PublishRelativeObject(Buffer sendBuffer, UInt8 parentId,
73 InterestingThing *object);
74
75 void SendSingle100(unsigned char *data, unsigned int startIndex, float value);
76 void SendInt32(unsigned char *data, unsigned int startIndex, Int32 value);
77 void SendAngle8(unsigned char *data, unsigned int startIndex,
78 const float value);
79 // void SendAngle16(unsigned char *data, unsigned int startIndex,
80 // const float value);
81 // void SendAngle32(unsigned char *data, unsigned int startIndex,
82 // const float value);
83 void SendVector3(unsigned char *data, unsigned char *startIndex,
84 const Vector3 v);
85 void SendQuaternion(unsigned char *data, const int startIndex,
86 const Quaternion q);
87
88 void SendPolar(unsigned char *data, unsigned char *startIndex, Polar p);
89 void SendSpherical(unsigned char *data, int startIndex, Spherical s);
90 // void SendSpherical16(unsigned char *data, int startIndex, Spherical s);
91 // void SendSpherical32(unsigned char *data, int startIndex, Spherical s);
92 void SendQuat32(unsigned char *data, unsigned char *startIndex,
93 const Quaternion q);
94
95 unsigned char *buffer; // =[32];
96 virtual void SendBuffer(unsigned char bufferSize);
97
98 void PublishClient();
99};
100
101} // namespace RoboidControl
102} // namespace Passer
SInt32 Int32
Definition Types.h:18
unsigned short UInt16
Definition Types.h:7
unsigned char UInt8
Definition Types.h:3
An object tracked by the roboid.
Definition TrackedObject.h:12
Definition NetworkPerception.h:10
Interface for synchronizaing state between clients across a network.
Definition NetworkSync.h:12
static const unsigned char PoseTypeMsg
Definition NetworkSync.h:27
void SendPoseMsg(Buffer sendBuffer, Roboid *roboid)
Definition NetworkSync.cpp:211
unsigned char networkId
Definition NetworkSync.h:16
NetworkPerception * networkPerception
Definition NetworkSync.h:70
unsigned char * buffer
Definition NetworkSync.h:95
void SendInvestigateThing(InterestingThing *thing)
Definition NetworkSync.cpp:258
void SendAngle8(unsigned char *data, unsigned int startIndex, const float value)
Definition NetworkSync.cpp:95
virtual void SendPose(Vector3 worldPosition, Quaternion worldOrientation)
Definition NetworkSync.h:67
static const unsigned char Pose_Position
A bit pattern for the pose, stating that this message contains a position in world coordinates.
Definition NetworkSync.h:31
void SendQuat32(unsigned char *data, unsigned char *startIndex, const Quaternion q)
Definition NetworkSync.cpp:76
void PublishClient()
Definition NetworkSync.cpp:143
void PublishTrackedObjects(Buffer sendBuffer, InterestingThing **objects)
Definition NetworkSync.cpp:150
void SendDestroyObject(Buffer sendBuffer, InterestingThing *obj)
Definition NetworkSync.cpp:248
static const unsigned char Velocity2DMsg
Definition NetworkSync.h:46
void ReceiveNetworkId()
Definition NetworkSync.cpp:25
static const unsigned char InvestigateMsg
Definition NetworkSync.h:48
static const unsigned char Pose_Orientation
A bit pattern for the pose, stating that this message contains an orientation in world coordinates.
Definition NetworkSync.h:34
void SendInt32(unsigned char *data, unsigned int startIndex, Int32 value)
Definition NetworkSync.cpp:132
static const unsigned char NetworkIdMsg
Definition NetworkSync.h:50
static const unsigned char DestroyMsg
Definition NetworkSync.h:42
static const unsigned char Pose_LinearVelocity
A bit pattern for the pose, stating that this messsage contains a linear velocity in world coordinate...
Definition NetworkSync.h:37
static const unsigned char ClientMsg
Definition NetworkSync.h:49
void SendSingle100(unsigned char *data, unsigned int startIndex, float value)
Definition NetworkSync.cpp:122
static const unsigned char RelativePoseMsg
Definition NetworkSync.h:28
NetworkSync()
Definition NetworkSync.cpp:12
void SendPolar(unsigned char *data, unsigned char *startIndex, Polar p)
Definition NetworkSync.cpp:49
virtual void SendBuffer(unsigned char bufferSize)
Definition NetworkSync.cpp:141
void SendSpherical(unsigned char *data, int startIndex, Spherical s)
Definition NetworkSync.cpp:55
void SendQuaternion(unsigned char *data, const int startIndex, const Quaternion q)
Definition NetworkSync.cpp:40
static const unsigned char Position2DMsg
Definition NetworkSync.h:45
void(* Buffer)(UInt8 *buffer, UInt16 bufferSize)
Definition NetworkSync.h:52
static const unsigned char CreateMsg
Definition NetworkSync.h:47
void ReceiveMessage(Roboid *roboid, unsigned char bytecount)
Definition NetworkSync.cpp:14
virtual void NewObject(InterestingThing *obj)
Definition NetworkSync.h:24
void SendVector3(unsigned char *data, unsigned char *startIndex, const Vector3 v)
Definition NetworkSync.cpp:30
void PublishRelativeObject(Buffer sendBuffer, UInt8 parentId, InterestingThing *object)
Definition NetworkSync.cpp:196
static const unsigned char PoseMsg
The id of a Pose message.
Definition NetworkSync.h:26
static const unsigned char AngVelocity2DMsg
Definition NetworkSync.h:44
virtual void NetworkUpdate(Roboid *roboid)=0
Retreive and send the roboid state.
static const char Pose_AngularVelocity
A bit pattern for the pose, stating that this message contains an angular velocity in world coordinat...
Definition NetworkSync.h:40
virtual void DestroyObject(InterestingThing *obj)=0
Inform that the given object is no longer being tracked.
void PublishTrackedObject(Buffer sendBuffer, InterestingThing *object)
Definition NetworkSync.cpp:167
virtual void SendPosition(Vector3 worldPosition)
Definition NetworkSync.h:66
A Roboid is used to control autonomous robots.
Definition Roboid.h:14
Definition AbsoluteEncoder.h:5