OpenSimulationInterface.CSharp 1.1.0

dotnet add package OpenSimulationInterface.CSharp --version 1.1.0                
NuGet\Install-Package OpenSimulationInterface.CSharp -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenSimulationInterface.CSharp" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenSimulationInterface.CSharp --version 1.1.0                
#r "nuget: OpenSimulationInterface.CSharp, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

  1. Make sure to have python 3 installed on your machine.

  2. Clone the repository (recursive).

git clone --recursive https://github.com/thempen/open-simulation-interface-csharp.git
  1. 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>
  1. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 85 8/2/2024
1.0.3 109 6/17/2024
1.0.2 113 5/17/2024
1.0.1 87 5/17/2024