Aligned the Messages
This commit is contained in:
parent
36740cf598
commit
e92edbc381
@ -9,7 +9,7 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte Id = 0xB1;
|
public const byte Id = 0xB1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the message, excluding the binary data
|
/// The length of the message in bytes, excluding the binary data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// For the total size of the message this.bytes.Length should be added to this value.
|
/// For the total size of the message this.bytes.Length should be added to this value.
|
||||||
public const byte length = 4;
|
public const byte length = 4;
|
||||||
|
@ -9,7 +9,7 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte Id = 0x20;
|
public const byte Id = 0x20;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the message
|
/// The length of the message in bytres
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte length = 3;
|
public const byte length = 3;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -41,6 +41,9 @@ namespace RoboidControl {
|
|||||||
if (buffer.Length < DestroyMsg.length)
|
if (buffer.Length < DestroyMsg.length)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
System.Console.WriteLine($"Send DestroyMsg [{this.networkId}/{this.thingId}]");
|
||||||
|
#endif
|
||||||
byte ix = 0;
|
byte ix = 0;
|
||||||
buffer[ix++] = DestroyMsg.Id;
|
buffer[ix++] = DestroyMsg.Id;
|
||||||
buffer[ix++] = this.networkId;
|
buffer[ix++] = this.networkId;
|
||||||
|
@ -11,7 +11,6 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="buffer">The byte array to parse</param>
|
/// <param name="buffer">The byte array to parse</param>
|
||||||
public IMessage(byte[] buffer) {
|
public IMessage(byte[] buffer) {
|
||||||
//Deserialize(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
@ -9,7 +9,7 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte Id = 0x81;
|
public const byte Id = 0x81;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the message
|
/// /// The length of the message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const byte length = 3;
|
public const byte length = 3;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -22,13 +22,13 @@ namespace RoboidControl {
|
|||||||
public byte thingId;
|
public byte thingId;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new message for sending
|
/// Create an investigate message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="networkId">The network ID for the thing</param>
|
/// <param name="networkId">The network ID for the thing</param>
|
||||||
/// <param name="thingId">The ID of the thing</param>
|
/// <param name="thing">The thing for which the details are requested</param>
|
||||||
public InvestigateMsg(byte networkId, byte thingId) {
|
public InvestigateMsg(byte networkId, Thing thing) {
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
this.thingId = thingId;
|
this.thingId = thing.id;
|
||||||
}
|
}
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
|
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
|
||||||
public InvestigateMsg(byte[] buffer) : base(buffer) { }
|
public InvestigateMsg(byte[] buffer) : base(buffer) { }
|
||||||
|
@ -8,7 +8,6 @@ namespace RoboidControl {
|
|||||||
SendAngle8(buffer, ref ix, v.direction.horizontal);
|
SendAngle8(buffer, ref ix, v.direction.horizontal);
|
||||||
SendAngle8(buffer, ref ix, v.direction.vertical);
|
SendAngle8(buffer, ref ix, v.direction.vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spherical ReceiveSpherical(byte[] data, ref byte ix) {
|
public static Spherical ReceiveSpherical(byte[] data, ref byte ix) {
|
||||||
float distance = ReceiveFloat16(data, ref ix);
|
float distance = ReceiveFloat16(data, ref ix);
|
||||||
float horizontal = ReceiveAngle8(data, ref ix);
|
float horizontal = ReceiveAngle8(data, ref ix);
|
||||||
@ -17,11 +16,6 @@ namespace RoboidControl {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendQuat32(byte[] buffer, ref byte ix, SwingTwist s) {
|
|
||||||
Quat32 q32 = Quat32.FromSwingTwist(s);
|
|
||||||
SendQuat32(buffer, ref ix, q32);
|
|
||||||
|
|
||||||
}
|
|
||||||
public static void SendQuat32(byte[] buffer, ref byte ix, Quat32 q) {
|
public static void SendQuat32(byte[] buffer, ref byte ix, Quat32 q) {
|
||||||
int qx = (int)(q.x * 127 + 128);
|
int qx = (int)(q.x * 127 + 128);
|
||||||
int qy = (int)(q.y * 127 + 128);
|
int qy = (int)(q.y * 127 + 128);
|
||||||
@ -48,6 +42,11 @@ namespace RoboidControl {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SendQuat32(byte[] buffer, ref byte ix, SwingTwist s) {
|
||||||
|
Quat32 q32 = Quat32.FromSwingTwist(s);
|
||||||
|
SendQuat32(buffer, ref ix, q32);
|
||||||
|
|
||||||
|
}
|
||||||
public static SwingTwist ReceiveSwingTwist(byte[] data, ref byte ix) {
|
public static SwingTwist ReceiveSwingTwist(byte[] data, ref byte ix) {
|
||||||
Quat32 q32 = ReceiveQuat32(data, ref ix);
|
Quat32 q32 = ReceiveQuat32(data, ref ix);
|
||||||
// UnityEngine.Quaternion q = new(q32.x, q32.y, q32.z, q32.w);
|
// UnityEngine.Quaternion q = new(q32.x, q32.y, q32.z, q32.w);
|
||||||
@ -66,7 +65,6 @@ namespace RoboidControl {
|
|||||||
sbyte value = (sbyte)(angle / 360.0f * 256.0f);
|
sbyte value = (sbyte)(angle / 360.0f * 256.0f);
|
||||||
buffer[ix++] = (byte)value;
|
buffer[ix++] = (byte)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float ReceiveAngle8(byte[] data, ref byte ix) {
|
public static float ReceiveAngle8(byte[] data, ref byte ix) {
|
||||||
float value = (data[ix++] * 180) / 128.0F;
|
float value = (data[ix++] * 180) / 128.0F;
|
||||||
return value;
|
return value;
|
||||||
@ -83,7 +81,6 @@ namespace RoboidControl {
|
|||||||
data[ix++] = (byte)((binary >> 8) & 0xFF);
|
data[ix++] = (byte)((binary >> 8) & 0xFF);
|
||||||
data[ix++] = (byte)(binary & 0xFF);
|
data[ix++] = (byte)(binary & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float ReceiveFloat16(byte[] data, ref byte ix) {
|
public static float ReceiveFloat16(byte[] data, ref byte ix) {
|
||||||
byte msb = data[ix++];
|
byte msb = data[ix++];
|
||||||
byte lsb = data[ix++];
|
byte lsb = data[ix++];
|
||||||
|
@ -40,18 +40,6 @@ namespace RoboidControl {
|
|||||||
this.urlLength = (byte)thing.modelUrl.Length;
|
this.urlLength = (byte)thing.modelUrl.Length;
|
||||||
this.url = thing.modelUrl;
|
this.url = thing.modelUrl;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Create a new message for sending
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="networkId">The network ID of the thing</param>
|
|
||||||
/// <param name="thingId">The ID of the thing</param>
|
|
||||||
/// <param name="url">The URL to send</param>
|
|
||||||
// public ModelUrlMsg(byte networkId, byte thingId, string url) {
|
|
||||||
// this.networkId = networkId;
|
|
||||||
// this.thingId = thingId;
|
|
||||||
// this.urlLength = (byte)url.Length;
|
|
||||||
// this.url = url;
|
|
||||||
// }
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
|
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
|
||||||
public ModelUrlMsg(byte[] buffer) {
|
public ModelUrlMsg(byte[] buffer) {
|
||||||
byte ix = 1;
|
byte ix = 1;
|
||||||
|
@ -66,28 +66,8 @@ namespace RoboidControl {
|
|||||||
/// Create a new message for sending
|
/// Create a new message for sending
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="networkId">The network ID of the thing</param>
|
/// <param name="networkId">The network ID of the thing</param>
|
||||||
/// <param name="thingId">The ID of the thing</param>
|
/// <param name="thing">The thing for which the pose should be sent</param>
|
||||||
/// <param name="position">The position of the thing in local space in meters</param>
|
/// <param name="force">If true, position and orientation are always included, even when they are not updated</param>
|
||||||
/// <param name="orientation">The orientation of the thing in local space</param>
|
|
||||||
public PoseMsg(byte networkId, byte thingId, Spherical position, SwingTwist orientation, Spherical linearVelocity = null, Spherical angularVelocity = null) {
|
|
||||||
this.networkId = networkId;
|
|
||||||
this.thingId = thingId;
|
|
||||||
|
|
||||||
this.poseType = 0;
|
|
||||||
if (this.position != null)
|
|
||||||
this.poseType |= Pose_Position;
|
|
||||||
if (this.orientation != null)
|
|
||||||
this.poseType |= Pose_Orientation;
|
|
||||||
if (this.linearVelocity != null)
|
|
||||||
this.poseType |= Pose_LinearVelocity;
|
|
||||||
if (this.angularVelocity != null)
|
|
||||||
this.poseType |= Pose_AngularVelocity;
|
|
||||||
|
|
||||||
this.position = position;
|
|
||||||
this.orientation = orientation;
|
|
||||||
this.linearVelocity = linearVelocity;
|
|
||||||
this.angularVelocity = angularVelocity;
|
|
||||||
}
|
|
||||||
public PoseMsg(byte networkId, Thing thing, bool force = false) {
|
public PoseMsg(byte networkId, Thing thing, bool force = false) {
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
this.thingId = thing.id;
|
this.thingId = thing.id;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Message providing generic information about a Thing
|
/// Message providing generic details about a Thing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ThingMsg : IMessage {
|
public class ThingMsg : IMessage {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -21,11 +21,11 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public byte thingId;
|
public byte thingId;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Thing.Type of the thing
|
/// The type of thing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte thingType;
|
public byte thingType;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The parent of the thing in the hierarachy. This is null for root Things
|
/// The ID of the parent thing in the hierarchy. This is zero for root things
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte parentId;
|
public byte parentId;
|
||||||
|
|
||||||
@ -44,19 +44,6 @@ namespace RoboidControl {
|
|||||||
this.parentId = 0;
|
this.parentId = 0;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a message for sending
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="networkId">The network ID of the thing</param>
|
|
||||||
/// <param name="thingId">The ID of the thing</param>
|
|
||||||
/// <param name="thingType">The type of thing</param>
|
|
||||||
/// <param name="parentId">The parent of the thing</param>
|
|
||||||
public ThingMsg(byte networkId, byte thingId, byte thingType, byte parentId) {
|
|
||||||
this.networkId = networkId;
|
|
||||||
this.thingId = thingId;
|
|
||||||
this.thingType = thingType;
|
|
||||||
this.parentId = parentId;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Create a message for receiving
|
/// Create a message for receiving
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="buffer">The byte array to parse</param>
|
/// <param name="buffer">The byte array to parse</param>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user