benelot / pybullet-gym

Open-source implementations of OpenAI Gym MuJoCo environments for use with the OpenAI Gym Reinforcement Learning Research Platform.
https://pybullet.org/
Other
814 stars 124 forks source link

Why are there references to extra "non-existent" links? #52

Closed roman-aguilera closed 3 years ago

roman-aguilera commented 4 years ago

I am using the 2D walker example but I notice this problem happens with other environments as well.

I am trying to change the instantaneous base velocity for a single link using:

env_instance.env._p.resetBaseVelocity(env_instance.env.robot.parts['thigh'].bodyPartIndex, linearVelocity = [0,0,0], angularVelocity=[0,0,0], physicsClientId = env_instance.env._p._client)

However when I type in the following:

import gym
import pybulletgym
env_instance = gym.make("Walker2DPyBulletEnv-v0", render=True)
env_instance.reset()
env_instance.env.robot.parts

The output gives a list of 17 links, but there should be about 8 max (including the floor):

{'link0_2': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc8e20438>, 'torso': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b710>, 'link0_3': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b5f8>, 'link0_4': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b6a0>, 'link0_6': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b780>, 'thigh': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b860>, 'link0_8': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b908>, 'leg': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b9e8>, 'link0_10': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657ba58>, 'foot': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bb38>, 'link0_12': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bbe0>, 'thigh_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bba8>, 'link0_14': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bcc0>, 'leg_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bd68>, 'link0_16': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bdd8>, 'foot_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657be80>, 'floor': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bef0>}
benelot commented 4 years ago

From the top of my head , it is an internal mechanism of pybullet to lock the robot body in space to only allow certain movements (i.e. in the 2D case, the robot should not move in 3D). There is the big question if these should be hidden, but for now they are not.

On Tue, Jun 23, 2020 at 4:20 AM Roman Aguilera notifications@github.com wrote:

I am using the 2D walker example but I notice this problem happens with other environments as well.

I am trying to change the instantaneous base velocity for a single link using:

env_instance.env._p.resetBaseVelocity(env_instance.env.robot.parts['thigh'].bodyPartIndex, linearVelocity = [0,0,0], angularVelocity=[0,0,0], physicsClientId = env_instance.env._p._client)

However when I type in the following:

import gym import pybulletgym env_instance = gym.make("Walker2DPyBulletEnv-v0", render=True) env_instance.reset() env_instance.env.robot.parts

The output gives a list of 17 links, but there should be about 8 max (including the floor):

{'link0_2': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc8e20438>, 'torso': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b710>, 'link0_3': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b5f8>, 'link0_4': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b6a0>, 'link0_6': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b780>, 'thigh': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b860>, 'link0_8': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b908>, 'leg': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657b9e8>, 'link0_10': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657ba58>, 'foot': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bb38>, 'link0_12': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bbe0>, 'thigh_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bba8>, 'link0_14': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bcc0>, 'leg_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bd68>, 'link0_16': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bdd8>, 'foot_left': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657be80>, 'floor': <pybulletgym.envs.roboschool.robots.robot_bases.BodyPart object at 0x7f1dc657bef0>}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benelot/pybullet-gym/issues/52, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXXXK4K3VKIRGKBUBCWRO3RYAGNLANCNFSM4OFGX4FA .

roman-aguilera commented 4 years ago

Thank you!