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?

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:

2 Likes