OpenSimulationInterface.CSharp
1.1.0
dotnet add package OpenSimulationInterface.CSharp --version 1.1.0
NuGet\Install-Package OpenSimulationInterface.CSharp -Version 1.1.0
<PackageReference Include="OpenSimulationInterface.CSharp" Version="1.1.0" />
paket add OpenSimulationInterface.CSharp --version 1.1.0
#r "nuget: OpenSimulationInterface.CSharp, 1.1.0"
// Install OpenSimulationInterface.CSharp as a Cake Addin #addin nuget:?package=OpenSimulationInterface.CSharp&version=1.1.0 // Install OpenSimulationInterface.CSharp as a Cake Tool #tool nuget:?package=OpenSimulationInterface.CSharp&version=1.1.0
OpenSimulationInterface.CSharp
This repository contains the build pipeline to generate C# code for the OpenSimulationInterface (OSI) protocol buffers.
The generated code is packed as a NuGet package OpenSimulationInterface.CSharp
and published on NuGet.
Building the Project locally
Make sure to have python 3 installed on your machine.
Clone the repository (recursive).
git clone --recursive https://github.com/thempen/open-simulation-interface-csharp.git
- Add the following code to the
.csproj
file to generate the C# files from the.proto
files. This makes sure, that the required version dependencies are installed and the C# files are generated from the.proto
files before building the project.
<Target Name="ProtobufCompile" BeforeTargets="BeforeBuild">
<Exec Command="python setup.py ./open-simulation-interface/osi_version.proto.in ./open-simulation-interface/VERSION ./open-simulation-interface/osi_version.proto" />
<Exec Command="protoc --proto_path=%userprofile%\.nuget\packages\google.protobuf.tools\3.26.1\tools --proto_path=open-simulation-interface --csharp_out=. open-simulation-interface\*.proto" />
</Target>
- Build the project.
Usage
After installing the OpenSimulationInterface.CSharp
package, you can use the generated classes in your C# projects. Here is an example:
using Osi3;
using Google.Protobuf;
public class Program
{
static void Main(string[] args)
{
// Create an instance of GroundTruth and initialize properties
GroundTruth groundTruth = new GroundTruth
{
Version = new InterfaceVersion
{
VersionMajor = 3,
VersionMinor = 7,
VersionPatch = 0
},
Timestamp = new Timestamp
{
Seconds = 1234567890,
Nanos = 123456789
},
HostVehicleId = new Identifier
{
Value = 12345
},
// Add other properties as needed
};
// Serialize to protobuf binary
byte[] serializedData = groundTruth.ToByteArray();
Console.WriteLine($"Serialized GroundTruth to {serializedData.Length} bytes.");
// Deserialize from protobuf binary
GroundTruth? deserializedData = GroundTruth.Parser.ParseFrom(serializedData);
Console.WriteLine($"Deserialized GroundTruth with version " +
$"{deserializedData.Version.VersionMajor}" +
$".{deserializedData.Version.VersionMinor}" +
$".{deserializedData.Version.VersionPatch}.");
Console.ReadKey(); // Prevent console from closing
}
}
Contributing
Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.
Acknowledgments
Special thanks to the Center of CARISSMA Institute of Automated Driving (C-IAD) of Technische Hochschule Ingolstadt for their support and contributions to this project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Google.Protobuf (>= 3.26.1)
- Google.Protobuf.Tools (>= 3.26.1)
-
net7.0
- Google.Protobuf (>= 3.26.1)
- Google.Protobuf.Tools (>= 3.26.1)
-
net8.0
- Google.Protobuf (>= 3.26.1)
- Google.Protobuf.Tools (>= 3.26.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.