ROS# Documentation

repository·master·Indexed 22 days ago

https://github.com/siemens/ros-sharp

An open-source set of C# libraries and tools enabling communication between .NET applications, specifically Unity, and the Robot Operating System (ROS). Version 2.2.0 provides a ROS bridge via RosBridgeClient, a URDF parser, and the MessageGeneration library and ConsoleTool for creating strongly-typed C# classes from ROS messages, services, and actions. It is available as a Unity Package Manager (UPM) package or via NuGet for standalone .NET projects.

Tokens
1.8K
Snippets
2
Records
16
Agent score
78%

What's inside ROS#

  1. Understand the ROS# Library Components

    master

    The ROS# .NET solution (RosSharp.sln) is composed of several specialized libraries that enable communication and data handling between .NET applications and ROS:

    • RosBridgeClient: The primary .NET API used to communicate with ROS via the rosbridge_suite.
    • MessageGeneration: A library used to generate C# source code representing ROS messages, services, and actions.
    • MessageGenerationConsoleTool: A command-line interface (CLI) tool for generating C# source code for ROS messages, services, and actions.
    • Urdf: A parser for URDF (Unified Robot Description Format) files designed for .NET applications.
  2. Use UrdfImporter to parse URDF files in .NET

    master
    The UrdfImporter library provides a parser for URDF (Unified Robot Description Format) files designed for use in .NET applications. It allows developers to load and interpret robot descriptions defined in URDF format within a .NET environment.
  3. Generate C# source code for ROS messages, services, and actions

    master

    The MessageGeneration library is a .NET library designed to automate the creation of C# source code that represents ROS message, service, and action types. This allows Unity or other .NET applications to communicate with ROS using strongly-typed C# classes instead of raw byte streams.

    For detailed instructions on how to handle new or custom message types, refer to the official ROS# Wiki page on New Message Types.

  4. Understand the ROS# Repository Structure

    master

    The repository is organized into distinct areas depending on whether you are working in Unity or a pure .NET environment:

    Unity Integration (com.siemens.ros-sharp/)

    This directory contains the UPM package.

    • Runtime/: Core ROS# .NET scripts and components for Unity.
    • Editor/: Unity editor scripts for UI extensions.
    • Plugins/: External dependencies with specific versions.
    • Samples~/: Example scenes and code (must be imported via the Package Manager window).

    Core Libraries (Libraries/)

    Contains the underlying .NET logic used by both Unity and standalone .NET projects.

    • RosBridgeClient/: Core library for communicating with ROS via WebSockets.
    • MessageGeneration/: Tools to generate C# classes from ROS message definitions (supports ROS1 and ROS2).
    • Urdf/: Library for parsing URDF files and creating Unity GameObjects.
    • PostBuildEvents/: OS-specific scripts for post-build processes.

    Demonstration (ROS Packages/)

    Contains ROS packages used for tutorials, testing, and demonstrations.

  5. Migration from ROS# <2.0.0 to ROS# 2.0.0+

    master

    If you are upgrading from an older version of ROS# (prior to 2.0.0), note the change in how libraries are distributed:

    • Older versions (<2.0.0): Required pre-compiled plugin DLLs (MessageGeneration.dll, RosBridgeClient.dll, and UrdfImporter.dll) to be placed in the Unity Plugins/ folder.
    • Current versions (2.0.0+): The project now distributes source code instead of DLLs. This change was implemented to prevent compatibility issues in Unity 2022 LTS caused by outdated C# dependencies in pre-compiled Visual Studio DLLs.

    In current versions, Unity generates the necessary DLLs itself using the assembly definition files included within the Unity package, ensuring better compatibility with the Unity editor's build system.

  6. Install ROS# for .NET Projects via NuGet

    master

    For non-Unity .NET applications, you can install the required ROS# packages individually from the NuGet Gallery. This allows you to use ROS# libraries in any compatible .NET environment.

    https://www.nuget.org/profiles/MartinBischoff
  7. Install ROS# for Unity via Unity Package Manager

    master

    To integrate ROS# into a Unity project, use the Unity Package Manager (UPM) to add the package directly from the Git repository. This method installs the custom Unity UPM package located in the com.siemens.ros-sharp directory, which includes the .NET solution, Unity-specific scripts, and samples.

    1. In the Unity Editor, open the Package Manager.
    2. Click the "Add package from git URL" option (usually located at the top left corner).
    3. Paste the following URL: https://github.com/siemens/ros-sharp.git?path=/com.siemens.ros-sharp
    https://github.com/siemens/ros-sharp.git?path=/com.siemens.ros-sharp
  8. Use the File Server for URDF transfers

    master

    The File Server package allows for transferring URDF (Unified Robot Description Format) files between ROS and Unity. This is useful for synchronizing robot models across different simulation environments.

    Key tasks include:

    • Transferring a URDF from ROS to Unity.
    • Transferring a URDF from Unity to ROS.
  9. Import ROS# Samples in Unity

    master

    The ROS# package includes example scenes and reference code located in the Samples~ directory. These are not automatically added to your project assets to avoid clutter. To use them:

    1. Open the Package Manager window in Unity.
    2. Locate the ROS# package in the list.
    3. Find the Samples section within the package details.
    4. Click Import to bring the sample assets into your project's Assets folder.