2.8 KiB
ROS–Unity Initial Setup
The minimum requirements for a ROS–Unity integration.
ROS Environment
-
Download and copy the TCP Endpoint package to the
src
folder in your Catkin workspace. -
Navigate to your Catkin workspace and run
catkin_make && source devel/setup.bash
. Ensure there are no errors. -
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.
-
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 asHost Name
on the RosConnect component in Unity.
- The ROS machine IP, i.e.
-
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. -
Update the
ROS_IP
below with the appropriate address and copy the contents into theparams.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. -
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
- Launch Unity and create a new scene.
- 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.