Skip to content

User_App_DotNet_Urdf_Transfer

Mehmet Emre Çakal edited this page Oct 10, 2024 · 1 revision

4.3 URDF Transfer

URDF (Unified Robot Description Format) files are XML files that describe the physical configuration of a robot. In this section, we'll cover how to transfer URDF files between ROS and your .NET application using ROS#.

4.3.1 Transferring URDF from ROS

Steps:

  1. Initialize the URDF Transfer: Create an instance of the UrdfTransferFromRos class to handle the transfer.
  2. Specify the ROS Topics: Define the topics for the URDF and robot name.
  3. Start the Transfer: Execute the transfer and wait for completion.

Code Example:

using RosSharp.RosBridgeClient.UrdfTransfer;

public static void TransferUrdfFromRosExample(RosSocket rosSocket)
{
    // Initialize the URDF transfer from ROS
    UrdfTransferFromRos urdfTransferFromRos = new UrdfTransferFromRos(
        rosSocket, 
        System.IO.Directory.GetCurrentDirectory(), 
        "robot_state_publisher:robot_description", // "/robot_description" for ROS1 
        "robot_name:pacakge_name" // "/robot/name" for ROS1
    );

    // Start the transfer
    urdfTransferFromRos.Transfer();

    // Wait for the transfer to complete
    urdfTransferFromRos.Status["robotNameReceived"].WaitOne();

    Console.WriteLine("Received URDF for robot: " + urdfTransferFromRos.RobotName);
}
  • UrdfTransferFromRos: A class that handles downloading URDF files from a ROS system to a local directory.
  • robot_description: The ROS topic typically used to publish the robot's URDF.
  • WaitOne: Waits for the URDF transfer to complete before continuing.

4.3.2 Transferring URDF to ROS

Steps:

  1. Initialize the URDF Transfer: Create an instance of the UrdfTransferToRos class.
  2. Specify the Local URDF File: Provide the path to the URDF file you wish to upload to ROS.
  3. Start the Transfer: Execute the transfer and wait for completion.

Code Example:

public static void TransferUrdfToRosExample(RosSocket rosSocket)
{
    string urdfFilePath = "path/to/your/urdf/file.urdf";

    // Initialize the URDF transfer to ROS
    UrdfTransferToRos transferor = new UrdfTransferToRos(
        rosSocket, 
        "Robot", 
        "robot_name", 
        urdfFilePath, 
        "urdf_export_test" // Package name to be exported. This package has to exist beforehand.
    );

    // Start the transfer
    transferor.Transfer();

    // Wait for the transfer to complete
    transferor.Status["robotNamePublished"].WaitOne();

    Console.WriteLine("Published URDF for robot: " + transferor.RobotName);
}

4.3.3 Example Files

In the ROS# .NET solution you will see the RosBridgeClientTest project. For executable implementation examples, see the console examples in this project.


© Siemens AG, 2017-2024

Clone this wiki locally