<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13379" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2022-02-16T14:45:22+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13379</id>

		<entry>
		<author><name><![CDATA[francevezzi]]></name></author>
		<updated>2022-02-16T14:45:22+00:00</updated>

		<published>2022-02-16T14:45:22+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43862#p43862</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43862#p43862"/>
		<title type="html"><![CDATA[Fixed joint constraint pendulum problem]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43862#p43862"><![CDATA[
Hello everyone,<br><br>My aim is to create a simple mid-air suspended oscillating pendulum.<br>Here is the URDF code:<br><div class="codebox"><p>Code: </p><pre><code>&lt;?xml version="1.0" ?&gt;&lt;robot name="pendolo"&gt; &lt;link name="base"&gt;    &lt;visual&gt;      &lt;origin rpy="0 0 0" xyz="0 0 0"/&gt;      &lt;geometry&gt;        &lt;box size="0.001 0.001 0.001"/&gt;      &lt;/geometry&gt;    &lt;/visual&gt;    &lt;!-- added so pybullet doesn't complain and set mass 1 diagintertia 1--&gt;    &lt;inertial&gt;      &lt;origin rpy="0 0 0" xyz="0 0 0"/&gt;      &lt;mass value="0.00001"/&gt;      &lt;inertia ixx="1e-5" ixy="0" ixz="0" iyy="1e-5" iyz="0" izz="1e-5"/&gt;    &lt;/inertial&gt;  &lt;/link&gt;  &lt;joint name="floating_base" type="fixed"&gt;    &lt;origin rpy="0 0 0" xyz="0 0 0"/&gt;    &lt;parent link="base"/&gt;    &lt;child link="supporto"/&gt;  &lt;/joint&gt;  &lt;link name="supporto"&gt;      &lt;inertial&gt;          &lt;origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/&gt;          &lt;mass value="0.001"/&gt;          &lt;inertia ixx="0.0001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.0001"/&gt;      &lt;/inertial&gt;      &lt;visual name=""&gt;          &lt;origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/&gt;          &lt;geometry&gt;              &lt;box size="0.0 0.0 0.0"/&gt;          &lt;/geometry&gt;          &lt;material name=""&gt;              &lt;color rgba="1.0 0.0 0.0 1.0"/&gt;              &lt;texture filename=""/&gt;          &lt;/material&gt;      &lt;/visual&gt;      &lt;collision&gt;        &lt;origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/&gt;          &lt;geometry&gt;              &lt;box size="0.0001 0.0001 0.0001"/&gt;          &lt;/geometry&gt;      &lt;/collision&gt;  &lt;/link&gt;          &lt;joint name="pendulum_joint" type="revolute"&gt;        &lt;origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/&gt;        &lt;parent link="supporto"/&gt;        &lt;child link="sbarra"/&gt;        &lt;axis xyz="0.0 1.0 0.0"/&gt;        &lt;limit lower="-10.0" upper="10.0" effort="0.0" velocity="0.0"/&gt;    &lt;/joint&gt;  &lt;link name="sbarra"&gt;      &lt;inertial&gt;          &lt;origin xyz="0.0 0.0 -0.5" rpy="0.0 0.0 0.0"/&gt;          &lt;mass value="1.0"/&gt;          &lt;inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/&gt;      &lt;/inertial&gt;      &lt;visual name=""&gt;          &lt;origin xyz="0.0 0.0 -0.5" rpy="0.0 0.0 0.0"/&gt;          &lt;geometry&gt;              &lt;box size="0.1 0.1 1"/&gt;          &lt;/geometry&gt;          &lt;material name=""&gt;              &lt;color rgba="1.0 0.0 0.0 1.0"/&gt;              &lt;texture filename=""/&gt;          &lt;/material&gt;      &lt;/visual&gt;      &lt;collision&gt;        &lt;origin xyz="0.0 0.0 -0.5" rpy="0.0 0.0 0.0"/&gt;          &lt;geometry&gt;              &lt;box size="0.1 0.1 1"/&gt;          &lt;/geometry&gt;      &lt;/collision&gt;  &lt;/link&gt;  &lt;/robot&gt;</code></pre></div>If I use a constraint to fix the joint base to be in a certain position it works and the pendulum is suspended exactly where I want.<br>Now if I use <div class="codebox"><p>Code: </p><pre><code> resetJointState</code></pre></div> to change pendulum initial angle it starts to oscillate in an unstable way, even with no gravity. Besides the pendulum rotate on further axis.<br>Here is the code to reproduce the issue:<div class="codebox"><p>Code: </p><pre><code>import pybulletimport timeimport pybullet_dataimport pybullet_utils.bullet_client as bcimport numpy as npp = bc.BulletClient(connection_mode=pybullet.GUI)p.setAdditionalSearchPath(pybullet_data.getDataPath())# p.setGravity(0,0,-10)planeId = p.loadURDF("plane.urdf")startPos = [0,0,1.5]startOrientation = p.getQuaternionFromEuler([0,0,0])pendId = p.loadURDF("pendulum.urdf", startPos, startOrientation)p.resetJointState(pendId, 1, -np.pi/4, 0)p.createConstraint(pendId, -1, -1, -1,                   p.JOINT_FIXED,                   [0,0,0],                   [0,0,0],                   [0,0,2],                   childFrameOrientation=[0,0,0,1])for i in range (100000):    p.stepSimulation()    time.sleep(1./240.)p.disconnect()</code></pre></div>Besides, if the position of the constrain is [0,0,1.5] exactly as the initial one of the pendulum the system behaves as desired.<br><br>Can anyone explain why this weird behavior ?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14260">francevezzi</a> — Wed Feb 16, 2022 2:45 pm</p><hr />
]]></content>
	</entry>
	</feed>
