Add SendInt
This commit is contained in:
parent
7dfd2b0004
commit
c299bb0018
@ -32,9 +32,7 @@ void NetworkSync::ReceiveNetworkId() {
|
||||
#ifdef RC_DEBUG
|
||||
printf("_Received network Id %d\n", this->networkId);
|
||||
#endif
|
||||
// delay(100);
|
||||
PublishModel(roboid);
|
||||
// delay(100);
|
||||
if (roboid->childCount > 0)
|
||||
PublishRelativeThing(roboid->GetChild(0), true);
|
||||
}
|
||||
@ -136,28 +134,6 @@ void NetworkSync::DestroyObject(InterestingThing *thing) {
|
||||
}
|
||||
|
||||
void NetworkSync::SendPose(Roboid *roboid, bool recurse) {
|
||||
// if (roboid->propulsion == nullptr)
|
||||
// return;
|
||||
|
||||
// Polar velocity = roboid->propulsion->GetVelocity();
|
||||
// Vector2 worldVelocity2 =
|
||||
// Vector2::Rotate(Vector2::forward * velocity.distance, velocity.angle);
|
||||
// Vector3 worldVelocity3 = Vector3(worldVelocity2.x, 0, worldVelocity2.y);
|
||||
|
||||
// float angularVelocity = roboid->propulsion->GetAngularVelocity();
|
||||
// Vector3 worldAngularVelocity = Vector3(0, angularVelocity, 0);
|
||||
|
||||
// unsigned char buffer[3 + 12 + 12] = {
|
||||
// PoseMsg,
|
||||
// 0, // objectId;
|
||||
// Pose_LinearVelocity | Pose_AngularVelocity,
|
||||
// };
|
||||
// unsigned char ix = 3;
|
||||
// SendVector3(buffer, &ix, worldVelocity3);
|
||||
// SendVector3(buffer, &ix, worldAngularVelocity);
|
||||
|
||||
// SendBuffer(ix);
|
||||
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = PoseMsg;
|
||||
buffer[ix++] = 0x00;
|
||||
@ -167,8 +143,7 @@ void NetworkSync::SendPose(Roboid *roboid, bool recurse) {
|
||||
SendBuffer(ix);
|
||||
|
||||
if (recurse) {
|
||||
// delay(10);
|
||||
Thing *child = roboid->GetChild(0); // actuation;
|
||||
Thing *child = roboid->GetChild(0);
|
||||
if (child != nullptr)
|
||||
SendPose(child, true);
|
||||
}
|
||||
@ -334,6 +309,19 @@ void NetworkSync::SendText(const char *s) {
|
||||
SendBuffer(ix);
|
||||
}
|
||||
|
||||
void NetworkSync::SendInt(const int x) {
|
||||
String s = String(x);
|
||||
byte length = s.length();
|
||||
|
||||
unsigned char ix;
|
||||
buffer[ix++] = 0xB0;
|
||||
buffer[ix++] = length;
|
||||
for (int urlIx = 0; urlIx < length; urlIx++)
|
||||
buffer[ix++] = s[urlIx];
|
||||
|
||||
SendBuffer(ix);
|
||||
}
|
||||
|
||||
// Low-level functions
|
||||
|
||||
void NetworkSync::SendVector3(unsigned char *data, unsigned char *startIndex,
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
void SendPose(Thing *thing, bool recurse = true);
|
||||
|
||||
virtual void SendText(const char *s);
|
||||
void SendInt(const int x);
|
||||
|
||||
protected:
|
||||
Roboid *roboid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user