您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

2.8 KiB

ROS–Unity Initial Setup

The minimum requirements for a ROS–Unity integration.

ROS Environment

  1. Download and copy the TCP Endpoint package to the src folder in your Catkin workspace.

  2. Navigate to your Catkin workspace and run catkin_make && source devel/setup.bash. Ensure there are no errors.

  3. Open a new terminal, navigate to your Catkin workspace, and run:

    source devel/setup.bash
    roscore &
    

Once ROS Core has started, it will print started core service [/rosout] to the terminal window.

  1. Note that in the server_endpoint, the script fetches parameters for the TCP connection. You will need to know the IP address of your ROS machine as well as the IP address of the machine running Unity.

    • The ROS machine IP, i.e. ROS_IP should be the same value as the one set as Host Name on the RosConnect component in Unity.
  2. The ROS parameter values can be set using a YAML file. Create a params.yaml file in your package, e.g. ./config/params.yaml. Open the file for editing.

  3. Update the ROS_IP below with the appropriate address and copy the contents into the params.yaml file.

    ROS_IP: <your ROS IP>
    ROS_TCP_PORT: 10000
    rosdistro: 'melodic'
    

    e.g.

    ROS_IP: 192.168.50.149
    ROS_TCP_PORT: 10000
    rosdistro: 'melodic'
    

    Ensure that the ROS_TCP_PORT is set to 10000.

  4. Set these newly defined parameters by running rosparam load, e.g.:

    rosparam load PATH/TO/config/params.yaml
    

    Alternatively, this YAML can be loaded from a launch file, e.g.:

    <launch>
        <rosparam file="$(find <PACKAGE_NAME>)/config/params.yaml" command="load"/>
    </launch>
    

Read more about rosparam YAML options here.

Read more about the ROS Parameter Server here.

Unity Scene

  1. Launch Unity and create a new scene.
  2. Open Package Manager and click the + button at the top left corner. Select "add package from git URL" and enter "https://github.com/Unity-Technologies/ROS-TCP-Connector.git" to install the ROS TCP Connector package.

Messages being passed between Unity and ROS need to be serialized exactly as ROS serializes them internally. This is achieved with the RosMessageGeneration utility, which generates C# classes, including serialization and deserialization functions, based on ROS message files. Adding the ROS TCP Connector package should have created a new Unity menu option, “RosMessageGeneration”, which we will use to generate these messages later.