Position control for robot base?

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
victoriax
Posts: 2
Joined: Mon Jun 04, 2018 6:50 pm

Position control for robot base?

Post by victoriax » Mon Jun 04, 2018 7:16 pm

Hi, new user trying to get started with pyBullet here. What's the best way to move a robot's base to a specified target location?

For context, I have a "floating" robot (I'm only modeling the hand, as I want a simple example that doesn't involve inverse kinematics) and I want to move this robot hand to a specified location via a direct trajectory, possibly pushing other objects out of the way as it moves.

I found a few viable approaches from the pyBullet GitHub examples, but I have reservations about each of them:
  • VR examples, such as vrhand.py (https://github.com/bulletphysics/bullet ... /vrhand.py), move floating hands around with changeConstraint(), but if I understand correctly this is to account for receiving input in frames, and not the intended way to simulate continuous motion.
  • Non-VR examples of robot motion, such as robotcontrol.py (https://github.com/bulletphysics/bullet ... control.py), use setJointMotorControl2() and velocity control to move robots/vehicles around, but I'd really like position control instead. While setJointMotorControl2() has an option for position control instead of velocity control, it seems to control joint position relative to the robot base, rather than moving the robot base itself.
  • Other examples use applyExternalForce() to move the robot base, as in externalTorqueControlledSphere.py (https://github.com/bulletphysics/bullet ... dSphere.py), but I really prefer position control to force control, as I worry that implementing my own PID controller (or a similar controller) will be finicky.
Which of these three approaches is preferred? Is there some other approach I'm not aware of? Thanks in advance!

keithmgould
Posts: 12
Joined: Thu May 31, 2018 5:21 pm

Re: Position control for robot base?

Post by keithmgould » Tue Jun 05, 2018 7:49 pm

I'm also new.

I _think_ what you want is just resetBasePositionAndOrientation(). Find more detail in the quick-start guide:

https://docs.google.com/document/d/10sX ... og8ua34um1

victoriax
Posts: 2
Joined: Mon Jun 04, 2018 6:50 pm

Re: Position control for robot base?

Post by victoriax » Wed Jun 06, 2018 2:09 pm

keithmgould wrote:
Tue Jun 05, 2018 7:49 pm

I _think_ what you want is just resetBasePositionAndOrientation(). Find more detail in the quick-start guide:

https://docs.google.com/document/d/10sX ... og8ua34um1
The guide says resetBasePositionAndOrientation() "will override the effect of all physics simulation" which means it cannot be used as part of a simulation where the object being moved around is able to push other objects out of the way -- or at least that's the behavior I'm observing. Am I missing something?

User avatar
Erwin Coumans
Site Admin
Posts: 4106
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Position control for robot base?

Post by Erwin Coumans » Wed Jun 06, 2018 3:49 pm

Indeed, you should not call resetBasePositionAndOrientation during the simulation, since it is an abrupt change that ignore and violates all dynamics, and likely give bad simulations and artifacts. If you reset the simulation (right after loading the URDF file or when teleporting a robot back to its original location, to start a new experiment), you can call resetBasePositionAndOrientation.

Using the changeConstraint (as in vrHand) is likely the best to move the hand, and then animate the constraint target.

Just call the changeConstraint with the desired position/orientation right before you call 'stepSimulation' . There will be a small delay to reach the actual position/orientation, but this is a good way to avoid discontinuities inside the physics engine.

Good luck!
Erwin

keithmgould
Posts: 12
Joined: Thu May 31, 2018 5:21 pm

Re: Position control for robot base?

Post by keithmgould » Fri Jun 08, 2018 4:51 pm

Ah, I missed that it was happening *during* the simulation. Sorry for the bad advice! Hope you have it all sorted now :)

Post Reply