From 3f51ae506089558f2a36e05425da82044945d7e5 Mon Sep 17 00:00:00 2001 From: Piotr Zyskowski Date: Tue, 23 Jan 2024 15:12:13 +0100 Subject: [PATCH 1/4] protobuf update to support runtime time scale change --- .../Proto/SimulationApiSchema.cs | 473 +++++++++++++++--- .../Proto/simulation_api_schema.proto | 16 + 2 files changed, 433 insertions(+), 56 deletions(-) diff --git a/Assets/ScenarioSimulatorConnector/Proto/SimulationApiSchema.cs b/Assets/ScenarioSimulatorConnector/Proto/SimulationApiSchema.cs index 54892c303..fe180d28a 100644 --- a/Assets/ScenarioSimulatorConnector/Proto/SimulationApiSchema.cs +++ b/Assets/ScenarioSimulatorConnector/Proto/SimulationApiSchema.cs @@ -126,58 +126,64 @@ static SimulationApiSchemaReflection() { "YWplY3RvcnlSZXF1ZXN0EgwKBG5hbWUYASABKAkSPgoKdHJhamVjdG9yeRgC", "IAEoCzIqLnRyYWZmaWNfc2ltdWxhdG9yX21zZ3MuUG9seWxpbmVUcmFqZWN0", "b3J5IlEKIEZvbGxvd1BvbHlsaW5lVHJhamVjdG9yeVJlc3BvbnNlEi0KBnJl", - "c3VsdBgBIAEoCzIdLnNpbXVsYXRpb25fYXBpX3NjaGVtYS5SZXN1bHQi6AgK", - "EVNpbXVsYXRpb25SZXF1ZXN0Ej4KCmluaXRpYWxpemUYASABKAsyKC5zaW11", - "bGF0aW9uX2FwaV9zY2hlbWEuSW5pdGlhbGl6ZVJlcXVlc3RIABJBCgx1cGRh", - "dGVfZnJhbWUYAiABKAsyKS5zaW11bGF0aW9uX2FwaV9zY2hlbWEuVXBkYXRl", - "RnJhbWVSZXF1ZXN0SAASUAoUc3Bhd25fdmVoaWNsZV9lbnRpdHkYAyABKAsy", - "MC5zaW11bGF0aW9uX2FwaV9zY2hlbWEuU3Bhd25WZWhpY2xlRW50aXR5UmVx", - "dWVzdEgAElYKF3NwYXduX3BlZGVzdHJpYW5fZW50aXR5GAQgASgLMjMuc2lt", - "dWxhdGlvbl9hcGlfc2No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S5zaW11bGF0aW9uX2FwaV9zY2hlbWEuVXBkYXRl", + "U3RlcFRpbWVSZXNwb25zZUgAQgoKCHJlc3BvbnNlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::BuiltinInterfaces.BuiltinInterfacesReflection.Descriptor, global::GeometryMsgs.GeometryMsgsReflection.Descriptor, global::TrafficSimulatorMsgs.TrafficSimulatorMsgsReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { @@ -216,8 +222,10 @@ static SimulationApiSchemaReflection() { new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.UpdateTrafficLightsResponse), global::SimulationApiSchema.UpdateTrafficLightsResponse.Parser, new[]{ "Result" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.FollowPolylineTrajectoryRequest), global::SimulationApiSchema.FollowPolylineTrajectoryRequest.Parser, new[]{ "Name", "Trajectory" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.FollowPolylineTrajectoryResponse), global::SimulationApiSchema.FollowPolylineTrajectoryResponse.Parser, new[]{ "Result" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.SimulationRequest), global::SimulationApiSchema.SimulationRequest.Parser, new[]{ "Initialize", "UpdateFrame", "SpawnVehicleEntity", "SpawnPedestrianEntity", "SpawnMiscObjectEntity", "DespawnEntity", "UpdateEntityStatus", "AttachLidarSensor", "AttachDetectionSensor", "AttachOccupancyGridSensor", "UpdateTrafficLights", "FollowPolylineTrajectory", "AttachPseudoTrafficLightDetector" }, new[]{ "Request" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.SimulationResponse), global::SimulationApiSchema.SimulationResponse.Parser, new[]{ "Initialize", "UpdateFrame", "SpawnVehicleEntity", "SpawnPedestrianEntity", "SpawnMiscObjectEntity", "DespawnEntity", "UpdateEntityStatus", "AttachLidarSensor", "AttachDetectionSensor", "AttachOccupancyGridSensor", "UpdateTrafficLights", "FollowPolylineTrajectory", "AttachPseudoTrafficLightDetector" }, new[]{ "Response" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.UpdateStepTimeRequest), global::SimulationApiSchema.UpdateStepTimeRequest.Parser, new[]{ "SimulationStepTime" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.UpdateStepTimeResponse), global::SimulationApiSchema.UpdateStepTimeResponse.Parser, new[]{ "Result" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.SimulationRequest), global::SimulationApiSchema.SimulationRequest.Parser, new[]{ "Initialize", "UpdateFrame", "SpawnVehicleEntity", "SpawnPedestrianEntity", "SpawnMiscObjectEntity", "DespawnEntity", "UpdateEntityStatus", "AttachLidarSensor", "AttachDetectionSensor", "AttachOccupancyGridSensor", "UpdateTrafficLights", "FollowPolylineTrajectory", "AttachPseudoTrafficLightDetector", "UpdateStepTime" }, new[]{ "Request" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::SimulationApiSchema.SimulationResponse), global::SimulationApiSchema.SimulationResponse.Parser, new[]{ "Initialize", "UpdateFrame", "SpawnVehicleEntity", "SpawnPedestrianEntity", "SpawnMiscObjectEntity", "DespawnEntity", "UpdateEntityStatus", "AttachLidarSensor", "AttachDetectionSensor", "AttachOccupancyGridSensor", "UpdateTrafficLights", "FollowPolylineTrajectory", "AttachPseudoTrafficLightDetector", "UpdateStepTime" }, new[]{ "Response" }, null, null, null) })); } #endregion @@ -6676,6 +6684,281 @@ public void MergeFrom(pb::CodedInputStream input) { } + /// + ///* + /// Requests updating simulation step time. + /// + public sealed partial class UpdateStepTimeRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UpdateStepTimeRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::SimulationApiSchema.SimulationApiSchemaReflection.Descriptor.MessageTypes[35]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeRequest(UpdateStepTimeRequest other) : this() { + simulationStepTime_ = other.simulationStepTime_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeRequest Clone() { + return new UpdateStepTimeRequest(this); + } + + /// Field number for the "simulation_step_time" field. + public const int SimulationStepTimeFieldNumber = 1; + private double simulationStepTime_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double SimulationStepTime { + get { return simulationStepTime_; } + set { + simulationStepTime_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as UpdateStepTimeRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(UpdateStepTimeRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(SimulationStepTime, other.SimulationStepTime)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (SimulationStepTime != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SimulationStepTime); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (SimulationStepTime != 0D) { + output.WriteRawTag(9); + output.WriteDouble(SimulationStepTime); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (SimulationStepTime != 0D) { + size += 1 + 8; + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(UpdateStepTimeRequest other) { + if (other == null) { + return; + } + if (other.SimulationStepTime != 0D) { + SimulationStepTime = other.SimulationStepTime; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 9: { + SimulationStepTime = input.ReadDouble(); + break; + } + } + } + } + + } + + /// + ///* + /// Response of updating simulation step time. + /// + public sealed partial class UpdateStepTimeResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UpdateStepTimeResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::SimulationApiSchema.SimulationApiSchemaReflection.Descriptor.MessageTypes[36]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeResponse(UpdateStepTimeResponse other) : this() { + result_ = other.result_ != null ? other.result_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public UpdateStepTimeResponse Clone() { + return new UpdateStepTimeResponse(this); + } + + /// Field number for the "result" field. + public const int ResultFieldNumber = 1; + private global::SimulationApiSchema.Result result_; + /// + /// Result of [UpdateStepTimeRequest](#UpdateStepTimeRequest) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::SimulationApiSchema.Result Result { + get { return result_; } + set { + result_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as UpdateStepTimeResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(UpdateStepTimeResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Result, other.Result)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (result_ != null) hash ^= Result.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (result_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Result); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (result_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Result); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(UpdateStepTimeResponse other) { + if (other == null) { + return; + } + if (other.result_ != null) { + if (result_ == null) { + Result = new global::SimulationApiSchema.Result(); + } + Result.MergeFrom(other.Result); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (result_ == null) { + Result = new global::SimulationApiSchema.Result(); + } + input.ReadMessage(Result); + break; + } + } + } + } + + } + /// ///* /// Universal message for Request @@ -6688,7 +6971,7 @@ public sealed partial class SimulationRequest : pb::IMessage [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::SimulationApiSchema.SimulationApiSchemaReflection.Descriptor.MessageTypes[35]; } + get { return global::SimulationApiSchema.SimulationApiSchemaReflection.Descriptor.MessageTypes[37]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6745,6 +7028,9 @@ public SimulationRequest(SimulationRequest other) : this() { case RequestOneofCase.AttachPseudoTrafficLightDetector: AttachPseudoTrafficLightDetector = other.AttachPseudoTrafficLightDetector.Clone(); break; + case RequestOneofCase.UpdateStepTime: + UpdateStepTime = other.UpdateStepTime.Clone(); + break; } _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); @@ -6898,6 +7184,17 @@ public SimulationRequest Clone() { } } + /// Field number for the "update_step_time" field. + public const int UpdateStepTimeFieldNumber = 14; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::SimulationApiSchema.UpdateStepTimeRequest UpdateStepTime { + get { return requestCase_ == RequestOneofCase.UpdateStepTime ? (global::SimulationApiSchema.UpdateStepTimeRequest) request_ : null; } + set { + request_ = value; + requestCase_ = value == null ? RequestOneofCase.None : RequestOneofCase.UpdateStepTime; + } + } + private object request_; /// Enum of possible cases for the "request" oneof. public enum RequestOneofCase { @@ -6915,6 +7212,7 @@ public enum RequestOneofCase { UpdateTrafficLights = 11, FollowPolylineTrajectory = 12, AttachPseudoTrafficLightDetector = 13, + UpdateStepTime = 14, } private RequestOneofCase requestCase_ = RequestOneofCase.None; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6954,6 +7252,7 @@ public bool Equals(SimulationRequest other) { if (!object.Equals(UpdateTrafficLights, other.UpdateTrafficLights)) return false; if (!object.Equals(FollowPolylineTrajectory, other.FollowPolylineTrajectory)) return false; if (!object.Equals(AttachPseudoTrafficLightDetector, other.AttachPseudoTrafficLightDetector)) return false; + if (!object.Equals(UpdateStepTime, other.UpdateStepTime)) return false; if (RequestCase != other.RequestCase) return false; return Equals(_unknownFields, other._unknownFields); } @@ -6974,6 +7273,7 @@ public override int GetHashCode() { if (requestCase_ == RequestOneofCase.UpdateTrafficLights) hash ^= UpdateTrafficLights.GetHashCode(); if (requestCase_ == RequestOneofCase.FollowPolylineTrajectory) hash ^= FollowPolylineTrajectory.GetHashCode(); if (requestCase_ == RequestOneofCase.AttachPseudoTrafficLightDetector) hash ^= AttachPseudoTrafficLightDetector.GetHashCode(); + if (requestCase_ == RequestOneofCase.UpdateStepTime) hash ^= UpdateStepTime.GetHashCode(); hash ^= (int) requestCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); @@ -7040,6 +7340,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(106); output.WriteMessage(AttachPseudoTrafficLightDetector); } + if (requestCase_ == RequestOneofCase.UpdateStepTime) { + output.WriteRawTag(114); + output.WriteMessage(UpdateStepTime); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -7087,6 +7391,9 @@ public int CalculateSize() { if (requestCase_ == RequestOneofCase.AttachPseudoTrafficLightDetector) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(AttachPseudoTrafficLightDetector); } + if (requestCase_ == RequestOneofCase.UpdateStepTime) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(UpdateStepTime); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -7177,6 +7484,12 @@ public void MergeFrom(SimulationRequest other) { } AttachPseudoTrafficLightDetector.MergeFrom(other.AttachPseudoTrafficLightDetector); break; + case RequestOneofCase.UpdateStepTime: + if (UpdateStepTime == null) { + UpdateStepTime = new global::SimulationApiSchema.UpdateStepTimeRequest(); + } + UpdateStepTime.MergeFrom(other.UpdateStepTime); + break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); @@ -7307,6 +7620,15 @@ public void MergeFrom(pb::CodedInputStream input) { AttachPseudoTrafficLightDetector = subBuilder; break; } + case 114: { + global::SimulationApiSchema.UpdateStepTimeRequest subBuilder = new global::SimulationApiSchema.UpdateStepTimeRequest(); + if (requestCase_ == RequestOneofCase.UpdateStepTime) { + subBuilder.MergeFrom(UpdateStepTime); + } + input.ReadMessage(subBuilder); + UpdateStepTime = subBuilder; + break; + } } } } @@ -7325,7 +7647,7 @@ public sealed partial class SimulationResponse : pb::IMessageField number for the "update_step_time" field. + public const int UpdateStepTimeFieldNumber = 14; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::SimulationApiSchema.UpdateStepTimeResponse UpdateStepTime { + get { return responseCase_ == ResponseOneofCase.UpdateStepTime ? (global::SimulationApiSchema.UpdateStepTimeResponse) response_ : null; } + set { + response_ = value; + responseCase_ = value == null ? ResponseOneofCase.None : ResponseOneofCase.UpdateStepTime; + } + } + private object response_; /// Enum of possible cases for the "response" oneof. public enum ResponseOneofCase { @@ -7552,6 +7888,7 @@ public enum ResponseOneofCase { UpdateTrafficLights = 11, FollowPolylineTrajectory = 12, AttachPseudoTrafficLightDetector = 13, + UpdateStepTime = 14, } private ResponseOneofCase responseCase_ = ResponseOneofCase.None; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7591,6 +7928,7 @@ public bool Equals(SimulationResponse other) { if (!object.Equals(UpdateTrafficLights, other.UpdateTrafficLights)) return false; if (!object.Equals(FollowPolylineTrajectory, other.FollowPolylineTrajectory)) return false; if (!object.Equals(AttachPseudoTrafficLightDetector, other.AttachPseudoTrafficLightDetector)) return false; + if (!object.Equals(UpdateStepTime, other.UpdateStepTime)) return false; if (ResponseCase != other.ResponseCase) return false; return Equals(_unknownFields, other._unknownFields); } @@ -7611,6 +7949,7 @@ public override int GetHashCode() { if (responseCase_ == ResponseOneofCase.UpdateTrafficLights) hash ^= UpdateTrafficLights.GetHashCode(); if (responseCase_ == ResponseOneofCase.FollowPolylineTrajectory) hash ^= FollowPolylineTrajectory.GetHashCode(); if (responseCase_ == ResponseOneofCase.AttachPseudoTrafficLightDetector) hash ^= AttachPseudoTrafficLightDetector.GetHashCode(); + if (responseCase_ == ResponseOneofCase.UpdateStepTime) hash ^= UpdateStepTime.GetHashCode(); hash ^= (int) responseCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); @@ -7677,6 +8016,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteRawTag(106); output.WriteMessage(AttachPseudoTrafficLightDetector); } + if (responseCase_ == ResponseOneofCase.UpdateStepTime) { + output.WriteRawTag(114); + output.WriteMessage(UpdateStepTime); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -7724,6 +8067,9 @@ public int CalculateSize() { if (responseCase_ == ResponseOneofCase.AttachPseudoTrafficLightDetector) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(AttachPseudoTrafficLightDetector); } + if (responseCase_ == ResponseOneofCase.UpdateStepTime) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(UpdateStepTime); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -7814,6 +8160,12 @@ public void MergeFrom(SimulationResponse other) { } AttachPseudoTrafficLightDetector.MergeFrom(other.AttachPseudoTrafficLightDetector); break; + case ResponseOneofCase.UpdateStepTime: + if (UpdateStepTime == null) { + UpdateStepTime = new global::SimulationApiSchema.UpdateStepTimeResponse(); + } + UpdateStepTime.MergeFrom(other.UpdateStepTime); + break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); @@ -7944,6 +8296,15 @@ public void MergeFrom(pb::CodedInputStream input) { AttachPseudoTrafficLightDetector = subBuilder; break; } + case 114: { + global::SimulationApiSchema.UpdateStepTimeResponse subBuilder = new global::SimulationApiSchema.UpdateStepTimeResponse(); + if (responseCase_ == ResponseOneofCase.UpdateStepTime) { + subBuilder.MergeFrom(UpdateStepTime); + } + input.ReadMessage(subBuilder); + UpdateStepTime = subBuilder; + break; + } } } } diff --git a/Assets/ScenarioSimulatorConnector/Proto/simulation_api_schema.proto b/Assets/ScenarioSimulatorConnector/Proto/simulation_api_schema.proto index 5fe413508..7f1c3f80d 100644 --- a/Assets/ScenarioSimulatorConnector/Proto/simulation_api_schema.proto +++ b/Assets/ScenarioSimulatorConnector/Proto/simulation_api_schema.proto @@ -324,6 +324,20 @@ message FollowPolylineTrajectoryResponse { Result result = 1; } +/** + * Requests updating simulation step time. + **/ +message UpdateStepTimeRequest { + double simulation_step_time = 1; +} + +/** + * Response of updating simulation step time. + **/ +message UpdateStepTimeResponse { + Result result = 1; // Result of [UpdateStepTimeRequest](#UpdateStepTimeRequest) +} + /** * Universal message for Request **/ @@ -342,6 +356,7 @@ message SimulationRequest { UpdateTrafficLightsRequest update_traffic_lights = 11; FollowPolylineTrajectoryRequest follow_polyline_trajectory = 12; AttachPseudoTrafficLightDetectorRequest attach_pseudo_traffic_light_detector = 13; + UpdateStepTimeRequest update_step_time = 14; } } @@ -364,5 +379,6 @@ message SimulationResponse { UpdateTrafficLightsResponse update_traffic_lights = 11; FollowPolylineTrajectoryResponse follow_polyline_trajectory = 12; AttachPseudoTrafficLightDetectorResponse attach_pseudo_traffic_light_detector = 13; + UpdateStepTimeResponse update_step_time = 14; } } From 3e2bed06794e1766cba528e1e16b7582c203b15f Mon Sep 17 00:00:00 2001 From: Piotr Zyskowski Date: Thu, 1 Feb 2024 19:54:29 +0100 Subject: [PATCH 2/4] supporting step time in AWSIM --- .../Script/ScenarioSimulatorRequestProcessor.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs index 0ab6fc01d..d6c8873bd 100644 --- a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs +++ b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs @@ -252,6 +252,9 @@ public SimulationResponse Process(SimulationRequest request) case SimulationRequest.RequestOneofCase.AttachPseudoTrafficLightDetector: response.AttachPseudoTrafficLightDetector = UpdateTrafficLights(request.AttachPseudoTrafficLightDetector); break; + case SimulationRequest.RequestOneofCase.UpdateStepTime: + response.UpdateStepTime = UpdateStepTime(request.UpdateStepTime); + break; default: Debug.Log("Case " + request.RequestCase.ToString() + " not yet supported"); break; @@ -594,6 +597,19 @@ private AttachPseudoTrafficLightDetectorResponse UpdateTrafficLights(AttachPseud }; return attachPseudoTrafficLightDetectorResponse; } + + private UpdateStepTimeResponse UpdateStepTime(UpdateStepTimeRequest request) + { + var updateStepTimeResponse = new UpdateStepTimeResponse() + { + Result = new Result() + { + Success = true, + Description = "AWSIM does not need to update step time" + } + }; + return updateStepTimeResponse; + } #endregion #region [Helpers] From 1182b664ad095ac7eaac42b024e5f6734e83644f Mon Sep 17 00:00:00 2001 From: Piotr Zyskowski Date: Sun, 4 Feb 2024 20:50:46 +0100 Subject: [PATCH 3/4] utilizing step time received in zmq --- .../Script/ScenarioSimulatorRequestProcessor.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs index d6c8873bd..c9ebe3a32 100644 --- a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs +++ b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs @@ -145,8 +145,8 @@ private TrafficLight.BulbData fromProto(SimulationApiSchema.TrafficLight proto) // time private float realtimeFactor = 1f; + private float stepTime = 0.33f; private double fixedDeltaTime; - private double prevUpdateFrameTime = 0d; // step execution - fixedUpdate frame counter @@ -271,13 +271,12 @@ public SimulationResponse Process(SimulationRequest request) private InitializeResponse Initialize(InitializeRequest request) { realtimeFactor = (float)request.RealtimeFactor; + stepTime = (float)request.StepTime; if(stepExecution) { realtimeFactor *= (1f / stepDurationInPercentage); } - // set previous time and soruce time to current time from request - prevUpdateFrameTime = request.InitializeTime; BuiltinInterfaces.Time currentRosTime = request.InitializeRosTime; timeSource.SetTime(currentRosTime.Sec, currentRosTime.Nanosec); @@ -311,9 +310,6 @@ private UpdateFrameResponse UpdateFrame(UpdateFrameRequest request) // calculate how many frames to update if (stepExecution) { - double elapsedSec = Math.Abs(Math.Abs(request.CurrentSimulationTime) - Math.Abs(prevUpdateFrameTime)); - prevUpdateFrameTime = request.CurrentSimulationTime; - // start time flow mainContext.Send(_ => { @@ -324,7 +320,7 @@ private UpdateFrameResponse UpdateFrame(UpdateFrameRequest request) } }, null); - int waitTime = Mathf.CeilToInt((float) (elapsedSec * 1000.0 * stepDurationInPercentage)); + int waitTime = Mathf.CeilToInt((float) (stepTime * 1000.0 * stepDurationInPercentage)); Thread.Sleep(waitTime); // freez time flow @@ -600,6 +596,7 @@ private AttachPseudoTrafficLightDetectorResponse UpdateTrafficLights(AttachPseud private UpdateStepTimeResponse UpdateStepTime(UpdateStepTimeRequest request) { + stepTime = (float)request.SimulationStepTime; var updateStepTimeResponse = new UpdateStepTimeResponse() { Result = new Result() From b41cba7a8498e5dbe5e9898f4925434ac9bf6246 Mon Sep 17 00:00:00 2001 From: Piotr Zyskowski Date: Sun, 4 Feb 2024 21:47:29 +0100 Subject: [PATCH 4/4] code cleanup --- .../ScenarioSimulatorRequestProcessor.cs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs index c9ebe3a32..3ec67b41a 100644 --- a/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs +++ b/Assets/ScenarioSimulatorConnector/Script/ScenarioSimulatorRequestProcessor.cs @@ -143,21 +143,12 @@ private TrafficLight.BulbData fromProto(SimulationApiSchema.TrafficLight proto) private bool isInitialized = false; // has the initialize request been received - // time - private float realtimeFactor = 1f; - private float stepTime = 0.33f; - private double fixedDeltaTime; - - - // step execution - fixedUpdate frame counter - - private int fixedUpdateCount = 0; - private int targetFixedUpdateCount = 0; - private bool isFixedUpdating = false; + // time - both of values below should be overwritten in Initialize ZeroMQ call + private float realtimeFactor = 0f; + private float stepTime = 0f; #endregion - // ------ METHODS ------ // #region [Life Cycle] @@ -174,8 +165,6 @@ public void Initialize() mainContext = SynchronizationContext.Current; - fixedDeltaTime = Time.fixedDeltaTime; - Time.timeScale = stepExecution? 0f : 1f; entityPrefabDic = new Dictionary(); @@ -315,7 +304,6 @@ private UpdateFrameResponse UpdateFrame(UpdateFrameRequest request) { lock (lockOnFrameUpdate) { - //isFixedUpdating = true; Time.timeScale = realtimeFactor; } }, null); @@ -602,7 +590,7 @@ private UpdateStepTimeResponse UpdateStepTime(UpdateStepTimeRequest request) Result = new Result() { Success = true, - Description = "AWSIM does not need to update step time" + Description = "Updated step time in AWSIM" } }; return updateStepTimeResponse;