Giter Site home page Giter Site logo

Comments (3)

qgallouedec avatar qgallouedec commented on August 16, 2024

Hi @yzhao334 , thank you for reporting this bug.

Can you provide me a minimal code to reproduce this bug? (it's a good practice when you open issues on GitHub)

I tried to reset the environment and the robot comes back to its initial position every time:

import gym
import panda_gym

env=gym.make('PandaReach-v1')

# initial reset
obs = env.reset()
print(obs['observation']) 
#[ 3.84396701e-02 -2.19447219e-12  1.97400143e-01  0.00000000e+00 -0.00000000e+00  0.00000000e+00]

# make a litlle move 
obs, _, _, _ = env.step([0.5, 0.5, 0.5])
print(obs['observation']) 
#[0.05003328 0.0178855  0.21331219 0.25930479 0.34940061 0.3846675 ]

# reset
obs = env.reset()
print(obs['observation'])
# [ 3.84396701e-02 -2.19447219e-12  1.97400143e-01  0.00000000e+00 -0.00000000e+00  0.00000000e+00]

from panda-gym.

yzhao334 avatar yzhao334 commented on August 16, 2024

Hi @qgallouedec, thanks a lot for replying. I was enabling real time simulation of pybullet for realistic object movement, such as dropping the cube when not grasping properly. I have found that the default setting does not show this issue, but the robot does not return to the default initial position when real time simulation is enabled.

I am attaching the code as below.

import gym
import panda_gym
import pybullet as p

env=gym.make('PandaPickAndPlace-v1',render=True)

# enable real time simulation for more realistic object interaction
p.setRealTimeSimulation(True)

# initial reset
obs = env.reset()
print(obs['observation']) 

# make an obvious move 
for _ in range(30):
    obs, _, _, _ = env.step([0.5, -0.5*5.0/3.0, 0, 0])
print(obs['observation']) 

# reset
obs = env.reset()
print(obs['observation'])

from panda-gym.

qgallouedec avatar qgallouedec commented on August 16, 2024

To make the rendering more realistic, you should not use p.setRealTimeSimulation(True) but env.render() after each env.step(action):

for _ in range(30):
    obs, _, _, _ = env.step([0.5, -0.5*5.0/3.0, 0, 0])
    env.render() # waits just the right amount of time to make the render realistic
print(obs['observation']) 

Explanation :
By default, pybullet waits for p.stepSimulation() to step the simulation. I use it in this package. If you run p.setRealTimeSimulation(True), pybullet won't wait for p.stepSimulation() to step the simulation. It will step whenever it wants (see Quickstart guide). And this is not what we want, since it makes the behaviour random (depending on the power of your computer among other things).
Instead, to have a realistic rendering, we simply make a pause that corresponds to the simulation step. This pause is made when you call env.render(). (See the source code)

from panda-gym.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.