[SOLVED] [pybullet] Resetting multibody messes up simulation

Post Reply
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

[SOLVED] [pybullet] Resetting multibody messes up simulation

Post by benelot »

Hello,

I produced a simple snake multibody (a chain of 5 links) and I am working ok a reinforcement learning setup to make it move. Therefore I need to reset the multibody, but when I use the standard resetBasePositionAndOrientation, this greatly messes up my multibody. It usually gets instable and flies around. Is this insufficient to reset the whole body?Do I need to reset anything else? I will have to work on the stability later as I intend to increase the chain length to around 20 parts.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: [pybullet] Resetting multibody messes up simulation

Post by benelot »

Problem solved. It is that I rotated the inertial of the urdf body.

If your base has an orientation != Quaternion(0,0,0,1) when placed into the world such as this one:

Code: Select all

	<link name="link_8">
		<collision>
		  <geometry>
		    <cylinder length="0.2" radius="0.025"/>
		  </geometry>
		  <origin rpy="0 1.57075 0" xyz="-0.1 0 0"/>
		</collision>
		<visual>
		  <geometry>
		    <cylinder length="0.2" radius="0.025"/>
		  </geometry>
		  <origin rpy="0 1.57075 0" xyz="-0.1 0 0"/>
		</visual>
		<inertial>
		  <origin rpy="0 1.57075 0" xyz="-0.1 0 0"/> <<<<==== HERE I rotated the intertial
		  <mass value="0.2"/>
		  <inertia ixx="0.00006" ixy="0" ixz="0" iyy="0.00006" iyz="0" izz="0.00006"/>
		</inertial>
	  </link>
resetting the multibody to some position and a Quaternion(0,0,0,1) causes it to be oriented wrongly. It can be solved by storing the initial orientation via getBasePositionAndOrientation(...) and resetting to that, or by not rotating the inertial.
Post Reply