Connect Reachy to unity instead of the online simulator

Hello Guys

I wanna connect Reahy to my unity simulation instead of the online simulator.

This Code below can connect to the online simulator.

from reachy import parts, Reachy
r = Reachy(
right_arm=parts.RightArm(io=‘ws’, hand=‘force_gripper’),
left_arm=parts.LeftArm(io=‘ws’, hand=‘force_gripper’),
)!

Can I connect it to the unity 3D?

1 Like

Hi @queenslandrobotic,

You can use this Reachy Unity package: GitHub - pollen-robotics/reachy-unity-package: Unity package for the Reachy robot.
It’s the one we use to build the online simulator.

that’s what I is used.
Do I have to change anything to the scripts?

Hello @queenslandrobotic,

With the Unity package you have a script called “WsIO.cs”.
You need to create an object in your scene and to attach this script to it.
You should then be able to connect to your Unity robot with your Python script using exactly the same code as written in your first post! (Make sure to instantiate your Reachy before clicking “Play” in Unity).

1 Like

Hello

Thank you for your replay.
However, can you see if I made any mistake?
I’ve set up the reachy, and implemented WsIO script as you can see from the picture and it is in play, and I type the coding, the reachy does not respond to it.

Is there any extra step that I needed to do?
Best Regards

The field “Reachy” of your component WsIO is empty in the Inspector.
Try to drag and drop your Reachy GameObject in this field.

Thank you so much.
I’ve successfully controlled the reachy in the simulation.

I wonder is it able to control the head and detection vision/colour?

2 Likes

You can’t control the head using your python script with this simulation version.

Nevertheless you can get the images from the camera. To do so you have to instantiate the head in Reachy:

r = Reachy(
    right_arm=parts.RightArm(io=‘ws’, hand=‘force_gripper’),
    left_arm=parts.LeftArm(io=‘ws’, hand=‘force_gripper’),
    head=parts.Head(io='ws'),
)

Then to get the image of Reachy’s view:

img = r.head.get_image()
1 Like

Thank you for your help, however
I got an error
AttributeError: ‘Head’ object has no attribute ‘get_image’

How can I solve it?

I do not quite understand the meaning of instantiate the head.

Adding a script to the head in inspector?

Hello @queenslandrobotic,

In fact there had been changes in the latest version of reachy for the vision. There is another way to get images from the camera with this version but which is not compatible anymore with the simulation (you will get a black image).

If you want to use Reachy’s view, I advise you come back to a previous release of reachy (version 1.2.3 is fine!), in which you will be able to use r.head.get_image().

For your other question, you just have to declare the head part in your Python script when creating Reachy (as I wrote above in my previous post), and that’s all! You do not have to do anything else :wink:

This is a very interesting thread! If we find the time, we will try an incorporate this with Reinforcement Learning tasks :slight_smile:

3 Likes

hi guys,

this is my second day dealing with Unity :slightly_smiling_face: so please be patient with me.

I am trying to connect Reachy to Unity too, but I have problems with Mesh Filter part. As you see in the following image

when I try to select Reachy in Select Mesh drop-down menu, it is not there.

Could you please help me solve this problem.

I thank you so much in advance for your support and understanding.

Cheers
Erg

1 Like

Just to let everyone know about the solution for the Mesh Filter problem, in case someone else gets the problem:

The best way to import Reachy into Unity is to follow these steps :

  1. Download reachy-articulations-unity2020.unitypackage from the releases page Releases · pollen-robotics/reachy-unity-package · GitHub
  2. From Unity Hub create a new 3D project. In the project, click Assets/Import package/Custom Package... and import reachy-articulations-unity2020.unitypackage.
  3. Then directly drag and drop Reachy prefab in the hierarchy.

You should have the MeshFilter automatically set!

Does this already work with Reachy 2021 as well? I mean, is there a new Unity package available?

Hi @NathanSegers,

We are working on a package for Reachy 2021, but it is not available yet! We will inform you when we release it.

Best regards,
Gaëlle