Skip to content
Russell Craig edited this page May 11, 2018 · 2 revisions

Welcome to the UnityStanfordROS wiki!

Using this project

  • Ensure you have ROS Kinetic Full Desktop installed
  • Ensure you have the correct Unity Editor version installed (2018.1.0f2)
  • Clone this repository
  • Using a Terminal, cd into the <repo>/ros folder
  • catkin_make
    • This builds the ROS workspace and custom node
  • source devel/setup.bash
    • This sets internal path values so ROS knows where to find your workspace
  • roslaunch stanford_msgs stanford.launch
    • This spins up ros and the custom node
  • Open the Unity editor and load the project
  • Open the Scenes/SampleScene example scene
  • Press Play
  • Press the "Init ROS" button
    • This establishes the connection to ROS along with initializing the example publisher and subscriber
  • Press the "Publish Vector3" button
    • This publishes a geometry_msgs/Vector3 message, you can verify this using rostopic echo in a terminal
    • The custom node receives this message and publishes a new message with altered data
    • Unity then receives the new message and outputs to console

Modifying the Custom Node

  • The source file is located at: <repo>/ros/src/stanford_msgs/src/example_custom_node.cpp
  • If you modify it to use other packages/messages, you will most likely need to update CMakeLists.txt and package.xml
  • When done modifying, navigate back to <repo>/ros and use catkin_make to rebuild

Adding New or Modifying Existing ROS.Net Messages

  • Create/choose a folder inside <ROSNetFolder>/common_msgs
  • Add your message definition files (.msg) to the folder, or modify existing ones
  • Open the ROS_dotNET.sln solution in Visual Studio
  • Rebuild the solution
  • New/updated C# messages are now located in <ROSNetFolder>/Messages/<folderName>
  • Copy generated/updated folders into <YourUnityProjectFolder>/Assets/ROS/Plugins/Messages
  • If you added new messages, you need to add their enum entry to <YourUnityProjectFolder>/Assets/ROS/Plugins/Messages/MessageTypes.cs
    • Or simply copy <ROSNetFolder>/Messages/MessageTypes.cs and overwrite <YourUnityProjectFolder>/Assets/ROS/Plugins/Messages/MessageTypes.cs

Adding ROS.Net to a Unity Project

  • Clone: https://github.com/uml-robotics/ROS.NET
  • Open ROS_dotNET.sln solution in Visual Studio
  • Rebuild the solution
  • Copy these folders to <YourUnityProjectFolder>/Assets/ROS/Plugins/
    • Messages
    • ROS_Comm
    • XmlRpc_Wrapper
  • In each of the above folders, delete the following:
    • bin/
    • obj/
    • Properties/
    • *.sln
    • *.csproj
    • respective .meta files for above
  • For convenience, you can also copy the entire ROS.Net folder into the Unity project
    • Copy it into the main project folder adjacent to Assets, Packages, ProjectSettings, etc
    • To include it in your Unity project source control, remove the .git folder and .gitignore file from the ROS.Net folder