Add SendInt
This commit is contained in:
parent
7dfd2b0004
commit
c299bb0018
@ -32,9 +32,7 @@ void NetworkSync::ReceiveNetworkId() {
|
|||||||
#ifdef RC_DEBUG
|
#ifdef RC_DEBUG
|
||||||
printf("_Received network Id %d\n", this->networkId);
|
printf("_Received network Id %d\n", this->networkId);
|
||||||
#endif
|
#endif
|
||||||
// delay(100);
|
|
||||||
PublishModel(roboid);
|
PublishModel(roboid);
|
||||||
// delay(100);
|
|
||||||
if (roboid->childCount > 0)
|
if (roboid->childCount > 0)
|
||||||
PublishRelativeThing(roboid->GetChild(0), true);
|
PublishRelativeThing(roboid->GetChild(0), true);
|
||||||
}
|
}
|
||||||
@ -136,28 +134,6 @@ void NetworkSync::DestroyObject(InterestingThing *thing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NetworkSync::SendPose(Roboid *roboid, bool recurse) {
|
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;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = PoseMsg;
|
buffer[ix++] = PoseMsg;
|
||||||
buffer[ix++] = 0x00;
|
buffer[ix++] = 0x00;
|
||||||
@ -167,8 +143,7 @@ void NetworkSync::SendPose(Roboid *roboid, bool recurse) {
|
|||||||
SendBuffer(ix);
|
SendBuffer(ix);
|
||||||
|
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
// delay(10);
|
Thing *child = roboid->GetChild(0);
|
||||||
Thing *child = roboid->GetChild(0); // actuation;
|
|
||||||
if (child != nullptr)
|
if (child != nullptr)
|
||||||
SendPose(child, true);
|
SendPose(child, true);
|
||||||
}
|
}
|
||||||
@ -334,6 +309,19 @@ void NetworkSync::SendText(const char *s) {
|
|||||||
SendBuffer(ix);
|
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
|
// Low-level functions
|
||||||
|
|
||||||
void NetworkSync::SendVector3(unsigned char *data, unsigned char *startIndex,
|
void NetworkSync::SendVector3(unsigned char *data, unsigned char *startIndex,
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
void SendPose(Thing *thing, bool recurse = true);
|
void SendPose(Thing *thing, bool recurse = true);
|
||||||
|
|
||||||
virtual void SendText(const char *s);
|
virtual void SendText(const char *s);
|
||||||
|
void SendInt(const int x);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Roboid *roboid;
|
Roboid *roboid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user