Merge commit '8369450d222e304da8eb2d9e345bd8dd894c917f' into V2

This commit is contained in:
Pascal Serrarens 2025-02-24 12:57:01 +01:00
commit c42c253362
11 changed files with 66 additions and 162 deletions

View File

@ -61,7 +61,7 @@ PROJECT_BRIEF =
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
PROJECT_LOGO = //intranet/home/Afbeeldingen/PasserVR/Logos/Logo3NameRight100.png
PROJECT_LOGO = //intranet/home/Afbeeldingen/PasserVR/Logos/PasserLife/PasserLifeLogoLeft_300.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is

View File

@ -1,6 +1,3 @@
using System.IO;
using System.Threading.Tasks;
namespace Passer.RoboidControl {
/// <summary>

View File

@ -1,6 +1,3 @@
using System.IO;
using System.Threading.Tasks;
namespace Passer.RoboidControl {
/// <summary>
@ -44,28 +41,6 @@ namespace Passer.RoboidControl {
buffer[ix++] = this.thingId;
return ix;
}
// public override void Deserialize(byte[] buffer) {
// uint ix = 0;
// this.networkId = buffer[ix++];
// this.thingId = buffer[ix++];
// }
//public static bool Send(Participant client, CoreThing thing) {
// InvestigateMsg msg = new(thing.networkId, thing.id);
// return SendMsg(client, msg);
//}
// public static async Task<bool> Receive(Stream dataStream, Participant client, byte packetSize) {
// if (packetSize != length)
// return false;
// byte[] buffer = await Receive(dataStream, packetSize);
// InvestigateMsg msg = new InvestigateMsg(buffer);
// //UnityEngine.Debug.Log($"Receive investigate [{msg.networkId}/{msg.thingId}]");
// client.messageQueue.Enqueue(msg);
// return true;
// }
}
}

View File

@ -1,6 +1,3 @@
using System.Threading.Tasks;
using System.IO;
namespace Passer.RoboidControl {
/// <summary>
@ -23,34 +20,6 @@ namespace Passer.RoboidControl {
/// <param name="buffer">The buffer to serilize into</param>
/// <returns>The length of the message in the buffer</returns>
public virtual byte Serialize(ref byte[] buffer) { return 0; }
//public virtual void Deserialize(byte[] buffer) { }
// public bool SendTo(Participant client) {
// Serialize(ref client.buffer);
// return client.SendBuffer(client.buffer.Length);
// }
// public static bool SendMsg(Participant client, IMessage msg) {
// msg.Serialize(ref client.buffer);
// return client.SendBuffer(client.buffer.Length);
// }
// public static bool PublishMsg(Participant client, IMessage msg) {
// msg.Serialize(ref client.buffer);
// return client.PublishBuffer(client.buffer.Length);
// }
// public static async Task<byte[]> Receive(Stream dataStream, byte packetSize) {
// byte[] buffer = new byte[packetSize - 1]; // without msgId
// int byteCount = dataStream.Read(buffer, 0, packetSize - 1);
// while (byteCount < packetSize - 1) {
// // not all bytes have been read, wait and try again
// await Task.Delay(1);
// byteCount += dataStream.Read(buffer, byteCount, packetSize - 1 - byteCount);
// }
// return buffer;
// }
}
}

View File

@ -1,22 +1,52 @@
namespace Passer.RoboidControl {
/// <summary>
/// Message for communicating the URL for a model of the thing
/// </summary>
public class ModelUrlMsg : IMessage {
/// <summary>
/// The message ID
/// </summary>
public const byte Id = 0x90; // (144) Model URL
/// <summary>
/// The length of the message without th URL itself
/// </summary>
public const byte length = 4;
/// <summary>
/// The network ID of the thing
/// </summary>
public byte networkId;
/// <summary>
/// The ID of the thing
/// </summary>
public byte thingId;
/// <summary>
/// The URL of the model
/// </summary>
public string url = null;
/// <summary>
/// Create a new message for sending
/// </summary>
/// <param name="networkId">The network ID of the thing</param>
/// <param name="thing">The thing for which to send the model URL</param>
public ModelUrlMsg(byte networkId, Thing thing) {
this.networkId = networkId;
this.thingId = thing.id;
this.url = thing.modelUrl;
}
public ModelUrlMsg(byte networkId, byte thingId, string url, float scale = 1) {
/// <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.url = url;
}
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
public ModelUrlMsg(byte[] buffer) {
byte ix = 1;
this.networkId = buffer[ix++];
@ -26,6 +56,7 @@ namespace Passer.RoboidControl {
url = System.Text.Encoding.UTF8.GetString(buffer, (int)ix, strlen);
}
/// @copydoc Passer::RoboidControl::IMessage::Serialize
public override byte Serialize(ref byte[] buffer) {
if (this.url == null)
return 0;

View File

@ -9,7 +9,7 @@ namespace Passer.RoboidControl {
/// </summary>
public const byte Id = 0x91; // 145
/// <summary>
/// The length of the message
/// The length of the message without the name string
/// </summary>
public const byte length = 4;
/// <summary>

View File

@ -3,6 +3,8 @@ namespace Passer.RoboidControl {
/// <summary>
/// A participant messages notifies other participants of its presence
/// </summary>
/// When received by another participant, it can be followed by a NetworkIdMsg
/// to announce that participant to this client such that it can join privately
public class ParticipantMsg : IMessage {
/// <summary>
/// The message ID
@ -20,7 +22,7 @@ namespace Passer.RoboidControl {
/// <summary>
/// Create a new message for sending
/// </summary>
/// <param name="networkId"></param>
/// <param name="networkId">The network ID known by the participant</param>
public ParticipantMsg(byte networkId) {
this.networkId = networkId;
}

View File

@ -1,5 +1,3 @@
using System.IO;
using System.Threading.Tasks;
using Passer.LinearAlgebra;
namespace Passer.RoboidControl {
@ -27,7 +25,7 @@ namespace Passer.RoboidControl {
public byte thingId;
/// <summary>
/// bitpattern stating which pose components are available
/// Bit pattern stating which pose components are available
/// </summary>
public byte poseType;
/// <summary>
@ -60,7 +58,7 @@ namespace Passer.RoboidControl {
/// </summary>
public Spherical linearVelocity = Spherical.zero;
/// <summary>
/// The angular veloicty of the thing in local space
/// The angular velocity of the thing in local space
/// </summary>
public Spherical angularVelocity = Spherical.zero;
@ -105,59 +103,7 @@ namespace Passer.RoboidControl {
LowLevelMessages.SendSpherical(buffer, ref ix, this.angularVelocity);
return ix;
}
// public override void Deserialize(byte[] buffer) {
// byte ix = 0;
// this.networkId = buffer[ix++];
// this.thingId = buffer[ix++];
// this.poseType = buffer[ix++];
// if ((poseType & Pose_Position) != 0)
// this.position = LowLevelMessages.ReceiveSpherical(buffer, ref ix);
// if ((poseType & Pose_Orientation) != 0)
// this.orientation = LowLevelMessages.ReceiveSwingTwist(buffer, ref ix);
// if ((poseType & Pose_LinearVelocity) != 0)
// this.linearVelocity = LowLevelMessages.ReceiveSpherical(buffer, ref ix);
// if ((poseType & Pose_AngularVelocity) != 0)
// this.angularVelocity = LowLevelMessages.ReceiveSpherical(buffer, ref ix);
// }
// public static bool Send(Participant client, byte thingId, Spherical position, SwingTwist orientation) {
// PoseMsg msg = new PoseMsg(client.networkId, thingId, position, orientation);
// return SendMsg(client, msg);
// }
// public static async Task<bool> Receive(Stream dataStream, Participant client, byte packetSize) {
// byte[] buffer = await Receive(dataStream, packetSize);
// PoseMsg msg = new PoseMsg(buffer);
// // Do no process poses with nwid == 0 (== local)
// if (msg.networkId == 0)
// return true;
// client.messageQueue.Enqueue(msg);
// return true;
// }
// public static bool SendTo(Participant participant, Thing thing) {
// if (participant == null || thing == null)
// return false;
// byte ix = 0;
// participant.buffer[ix++] = PoseMsg.Id;
// participant.buffer[ix++] = participant.networkId;
// participant.buffer[ix++] = thing.id;
// participant.buffer[ix++] = thing.poseUpdated;
// if ((thing.poseUpdated & Pose_Position) != 0 && thing.position != null)
// LowLevelMessages.SendSpherical(participant.buffer, ref ix, thing.position);
// if ((thing.poseUpdated & Pose_Orientation) != 0 && thing.orientation != null)
// LowLevelMessages.SendQuat32(participant.buffer, ref ix, thing.orientation);
// if ((thing.poseUpdated & Pose_LinearVelocity) != 0 && thing.linearVelocity != null)
// LowLevelMessages.SendSpherical(participant.buffer, ref ix, thing.linearVelocity);
// if ((thing.poseUpdated & Pose_AngularVelocity) != 0 && thing.angularVelocity != null)
// LowLevelMessages.SendSpherical(participant.buffer, ref ix, thing.angularVelocity);
// return participant.SendBuffer(ix);
// }
}
}

View File

@ -1,10 +1,7 @@
using System.IO;
using System.Threading.Tasks;
namespace Passer.RoboidControl {
/// <summary>
/// Message for sending generic text.
/// Message for sending generic text
/// </summary>
public class TextMsg : IMessage {
/// <summary>
@ -43,19 +40,6 @@ namespace Passer.RoboidControl {
buffer[ix++] = (byte)this.text[textIx];
return ix;
}
// public override void Deserialize(byte[] buffer) {
// uint ix = 0;
// uint strlen = buffer[ix++];
// this.text = System.Text.Encoding.UTF8.GetString(buffer, (int)ix, (int)strlen);
// }
// public static async Task<bool> Receive(Stream dataStream, Participant client, byte packetSize) {
// byte[] buffer = await Receive(dataStream, packetSize);
// TextMsg msg = new TextMsg(buffer);
// client.messageQueue.Enqueue(msg);
// return true;
// }
}
}

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Passer.RoboidControl {
/// <summary>
/// A reference to a participant, possible on a remote location
/// A reference to a participant, possibly on a remote location
/// </summary>
public class RemoteParticipant {
/// <summary>
@ -28,7 +28,7 @@ namespace Passer.RoboidControl {
/// <summary>
/// Create a new remote participant
/// </summary>
/// <param name="ipAddress">The ip address of the participant</param>
/// <param name="ipAddress">The IP address of the participant</param>
/// <param name="port">The UDP port of the participant</param>
public RemoteParticipant(string ipAddress, int port) {
this.ipAddress = ipAddress;
@ -43,7 +43,7 @@ namespace Passer.RoboidControl {
/// <summary>
/// Get a thing with the given ids
/// </summary>
/// <param name="networkId">The networkId of the thing</param>
/// <param name="networkId">The network ID of the thing</param>
/// <param name="thingId">The ID of the thing</param>
/// <returns>The thing when it is found, null in other cases.</returns>
public Thing Get(byte networkId, byte thingId) {

View File

@ -12,6 +12,28 @@ namespace Passer.RoboidControl {
#region Types
#endregion Types
#region Properties
public delegate void ChangeHandler();
public delegate void SphericalHandler(Spherical v);
public delegate void ThingHandler(Thing t);
/// <summary>
/// The participant to which this thing belongs
/// </summary>
public RemoteParticipant participant;
/// <summary>
/// The network ID of this thing.
/// </summary>
public byte networkId;
/// <summary>
/// The ID of this thing
/// </summary>
public byte id;
/// <summary>
/// Predefined thing types
/// </summary>
@ -37,27 +59,6 @@ namespace Passer.RoboidControl {
/// </summary>
public byte type;
#endregion Types
#region Properties
/// <summary>
/// The participant to which this thing belongs
/// </summary>
public RemoteParticipant participant;
public delegate void ChangeHandler();
public delegate void SphericalHandler(Spherical v);
/// <summary>
/// The network ID of this thing.
/// </summary>
public byte networkId;
/// <summary>
/// The ID of this thing
/// </summary>
public byte id;
/// <summary>
/// Event which is triggered when the parent changes
/// </summary>
@ -96,7 +97,7 @@ namespace Passer.RoboidControl {
/// <summary>
/// Remove the given thing as a child of this thing
/// </summary>
/// <param name="child"></param>
/// <param name="child">The child to remove</param>
public void RemoveChild(Thing child) {
children.Remove(child);
}
@ -271,7 +272,6 @@ namespace Passer.RoboidControl {
#endregion Update
public delegate void ThingHandler(Thing t);
/// <summary>
/// Event triggered when a new thing has been created
/// </summary>