ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Transfer trajectory from ROS to Unity

asked 2020-12-16 06:46:14 -0600

yemre0642 gravatar image


I work on ROS melodic and Unity 2019. I created the trajectory for my robot in ROS and I visualize the path in Rviz. How can I transfer the trajectory to Unity? Have you done this before? or I am open any suggestions?

edit retag flag offensive close merge delete


This is kind of an old post and i am not answering any questions , but where you able to find the solution?

panserzap gravatar image panserzap  ( 2021-05-05 10:35:43 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-05-05 11:24:45 -0600

abhishek47 gravatar image

updated 2021-05-05 12:33:09 -0600

Have you looked at Unity blogs: Robotics simulation in Unity? Section 3, Connecting your simulation to ROS states:

Now that the robot is in the Unity Editor, we should test our motion-planning algorithm, running in a set of ROS nodes. To support this, we need to set up a communication interface between Unity and ROS. Unity needs to pass messages to ROS that contain state information — namely, the poses of the robot, target object, and target location — along with a planning request to the mover service. In turn, ROS needs to return a trajectory message to Unity corresponding to the motion plan (i.e., the sequence of joint positions required to complete the pick-and-place task).

I haven't myself tried this out but the Unity package ROS-TCP-Connector and ROS package ROS-TCP-Endpoint look useful to establish the bridge between Unity and ROS. On the Unity side, a C# script could make a service request, in response to which, ROS sends back the trajectory:

[..] makes a service request to the MoveIt motion planner. The service request includes the current pose of the robot, the pose of the target object, and the target location. When MoveIt receives the planning request, it attempts to compute a motion plan. If successful, the service returns the plan, i.e., a sequence of joint positions [..]

Depending on your use, you may not even need a service. Set up a publisher on the ROS side and a subscriber on the Unity side, and after the trajectory is computed ROS simply publishes it.

edit flag offensive delete link more


Yes, that is what I am currently looking at. Unity package ROS-TCP-Connector and ROS package ROS-TCP-Endpoint will probably be up for the task. Well more specifically, I have to get the trajectory from ROS and visualize it in Unity. Then a simulation must take place in Unity, where the robot follows the given trajectory.

Thank you for taking the time to provide me with information.

panserzap gravatar image panserzap  ( 2021-05-05 13:55:10 -0600 )edit

Question Tools



Asked: 2020-12-16 06:46:14 -0600

Seen: 716 times

Last updated: May 05 '21