This package demonstrates and tests the connection between Unity and ROS by integrating the pose of a sphere and joint states of a UR5e in Unity with trajectory planning in ROS. The goal is to establish seamless communication between the Unity environment and ROS for robotic motion planning and visualization. This connection will enable more complex projects and research in the future.
- Publishes the pose of a sphere and joint states of a robot from Unity to ROS.
- Subscribes to the Unity-published data and calculates a trajectory using the MoveIt planning interface.
- Sends the calculated trajectory back to Unity to move the robot towards the sphere's position (one joint state at a time).
- Includes a launch script to start the MoveIt
move_group
instance, Gazebo simulation, and RViz visualization of the robot.
- Unity: Ensure Unity
v2020.3.11f1
is installed on your system. - ROS Noetic (or compatible version): The package is designed for ROS Noetic.
- ros_tcp_endpoint: This package allows Unity to communicate with ROS through TCP. Install it as described below.
To install all the package dependencies, run the following command in your ROS workspace:
rosdep install --from-paths src --ignore-src -r -y
The example Unity project is located at:
include/oculus/UR5e_Test/Assets
The Unity scene to use is called Ros Connection Test.
- Install the ROS-TCP-Connector in your Unity project. This allows Unity to communicate with ROS over TCP. Ensure that it is properly configured to connect with your ROS master.
- Ensure that the Unity project is set up to communicate with the ROS topics published by the nodes in this package.
Purpose: Logs the sphere's pose and the robot's joint states from Unity once the "Publish" button is pressed in the Unity scene.
Published Topics:
/weld_pose
(geometry_msgs/Pose): Pose of the sphere in Unity./ur_joint_states
(sensor_msgs/JointState): Current joint states of the robot in Unity.
Purpose: Subscribes to the sphere's pose and robot's joint states, computes a trajectory using MoveIt, and sends the trajectory back to Unity.
Subscribed Topics:
/sphere_pose
: Pose of the sphere in Unity./ur_joint_state
: Current joint states of the robot in Unity.
Published Topics:
/unity_joint_commands
(sensor_msgs/JointState): Joint States for the robot to move towards the sphere.
-
Start the Listening Node
rosrun weldingrobot unity_listener
This will:
- Start logging the pose and joint states published from Unity.
-
Start the MoveIt instance and Gazebo with RViz:
roslaunch weldingrobot ur5e_lab.gazebo.launch
This will:
- Start the MoveIt move_group.
- Launch Gazebo with the robot model.
- Open RViz for visualization.
-
Run the Trajectory Planning Node:
rosrun weldingrobot unity_sphere_follow
- Open Unity and load the example project at
include/oculus/UR5e_Test/Assets
. - Open the Ros Connection Test scene.
- Press the "Publish" button to start sending pose and joint state data to ROS.
- RViz: Displays the robot and its planned trajectory in real-time.
- Gazebo: Simulates the robot's movements based on the planned trajectory.
- Unity: Reflects the robot's pose updates and moves the robot towards the sphere.
- Move trajectory segmentation inside unity, instead of publishing joints individually.
- Jogging of end-effector movement using moveit Servo for real-time sphere following.
- Add error handling for communication delays or connection failures.
- Extend support to more complex environments and robotic configurations.
- Improve trajectory calculation with constraints like obstacles and time optimization.
If you encounter issues:
- Ensure that Unity's TCP connector is properly configured with the ROS master URI and IP address.
- Verify that all required ROS topics are being published and subscribed correctly.
- Check for any errors in the logs of the Unity and ROS nodes.