<?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/13262" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2023-02-14T08:23:05+00:00</updated>

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

		<entry>
		<author><name><![CDATA[lorde]]></name></author>
		<updated>2023-02-14T08:23:05+00:00</updated>

		<published>2023-02-14T08:23:05+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44250#p44250</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44250#p44250"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44250#p44250"><![CDATA[
I am also interested in this!<br><a href="https://melonplayground.co/" class="postlink"><span style="color:#FFFFFF"><span style="font-size:1%;line-height:116%">melon playground</span></span></a><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14540">lorde</a> — Tue Feb 14, 2023 8:23 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-09-11T18:34:40+00:00</updated>

		<published>2021-09-11T18:34:40+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43602#p43602</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43602#p43602"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43602#p43602"><![CDATA[
Setting the inverse inertia diagonal to zeros is fine: it produces an object that will never ever rotate from external forces, which is often what you want for a character.  With dynamic characters I typically push them around with velocity adjustments, allow them to rotate about the vertical axis, but slam their rotation and zero their angular velocity every step, which is effectively the same thing.  Another way to put it is: my characters are dynamic in the linear dimensions but kinematic in the angular.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Sat Sep 11, 2021 6:34 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[justjayel]]></name></author>
		<updated>2021-09-11T15:20:37+00:00</updated>

		<published>2021-09-11T15:20:37+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43601#p43601</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43601#p43601"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43601#p43601"><![CDATA[
<blockquote class="uncited"><div>If you're trying to make a tall think character always stand up maybe you should use the "zero inverse inertia tensor diagonal" trick.  This would allow you to use whatever friction you want.  In other words, if your character should only ever rotate about its local vertical Y-axis, then you can set the X- and Z-components of its local inverse inertia tensor diagonal to zero like so:<div class="codebox"><p>Code: </p><pre><code>btVector3 inv_inertia = body-&gt;getInvInertiaDiagLocal();inv_inertia.setX(0.0f);inv_inertia.setZ(0.0f);body-&gt;setInvInertiaDiagLocal(inv_inertia);</code></pre></div>Effectively this is like setting its local angular mass to infinity on those two axes --&gt; torques will never be able to budge it except around its one pivot axis.</div></blockquote>Your solution worked.<br><br>Now if I set the friction on both objects to non-zero and apply a little velocity to the player in either X or Z direction it spins slowly in a circle around the Y axis. Would anyone know why?<br><br>On a different note, is there anywhere with a bit more in depth tutorials or documentation? Is it just the examples?<br><br><br>EDIT: <br>I fixed the spinning by setting the inverse inertia on the Y axis to zero as well. Not sure if that is the correct way. But I guess that is fine for a character rather than an actual object?<div class="codebox"><p>Code: </p><pre><code>inv_inertia.setY(0.0f);</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14076">justjayel</a> — Sat Sep 11, 2021 3:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-09-01T15:06:35+00:00</updated>

		<published>2021-09-01T15:06:35+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43582#p43582</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43582#p43582"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43582#p43582"><![CDATA[
If you're trying to make a tall think character always stand up maybe you should use the "zero inverse inertia tensor diagonal" trick.  This would allow you to use whatever friction you want.  In other words, if your character should only ever rotate about its local vertical Y-axis, then you can set the X- and Z-components of its local inverse inertia tensor diagonal to zero like so:<div class="codebox"><p>Code: </p><pre><code>btVector3 inv_inertia = body-&gt;getInvInertiaDiagLocal();inv_inertia.setX(0.0f);inv_inertia.setZ(0.0f);body-&gt;setInvInertiaDiagLocal(inv_inertia);</code></pre></div>Effectively this is like setting its local angular mass to infinity on those two axes --&gt; torques will never be able to budge it except around its one pivot axis.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Wed Sep 01, 2021 3:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[justjayel]]></name></author>
		<updated>2021-09-01T14:38:32+00:00</updated>

		<published>2021-09-01T14:38:32+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43581#p43581</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43581#p43581"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43581#p43581"><![CDATA[
Hi drleviathan,<br><br>Seems you were right, the setFriction() method worked! Stops my character object from sinking. Thanks!!<br><br>The gradual incremental velocity I don't think helped, but its great for simulating a bit of realism, I will definitely look into using it!<br><br>Thanks again!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14076">justjayel</a> — Wed Sep 01, 2021 2:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-08-30T14:54:21+00:00</updated>

		<published>2021-08-30T14:54:21+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43577#p43577</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43577#p43577"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43577#p43577"><![CDATA[
For stability your <strong class="text-strong">substep_period</strong> should be fixed.  I believe the default behavior in Bullet is fixed <strong class="text-strong">step_period = 1/60</strong> sec with 1 substep per step.<br><br>Yes, for most applications the <strong class="text-strong">blend_timescale</strong> would be a constant.  You would tweak it to get the responsiveness you want and then nail it down as a compile time constant.<br><br>I wonder if the X/Y ratio threshold is actually caused by the tall box starting to tip over because of friction at the contacts.  For curiosity's sake maybe try setting all frictions (floor and dynamic object) to be zero to see if the the transition between behaviors goes away.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Mon Aug 30, 2021 2:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[justjayel]]></name></author>
		<updated>2021-08-29T23:47:19+00:00</updated>

		<published>2021-08-29T23:47:19+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43574#p43574</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43574#p43574"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43574#p43574"><![CDATA[
Hi drleviathan, <br>Can substep_period and blend_timescale be any static values within your description? I'll try this a bit later when I have more time. <br><br><br>I quickly checked my issue again on the HelloWorld demo and it seems like the issue is somewhat related to the ratio of the collision shape; seems like tall slim objects will fall through the ground and stay there. Ratios less than a 0.3 between X and Y seems to run into this issue. E.g.:<ul><li>X: 1, Y: 4 - fails</li></ul><ul><li>X: 1.2, Y: 4 - works</li> </ul><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14076">justjayel</a> — Sun Aug 29, 2021 11:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-08-29T15:59:23+00:00</updated>

		<published>2021-08-29T15:59:23+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43571#p43571</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43571#p43571"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43571#p43571"><![CDATA[
Slamming the linear velocity of a dynamic object to an arbitrary value is a Bad Idea in general because it could override velocities from collisions that would otherwise help resolve interpenetration.<br><br>One way to avoid breaking the simulation is to use <strong class="text-strong">applyForce()</strong> instead of<strong class="text-strong"> setLinearVelocity()</strong> because the force will be accumulated until the substep and then introduced during the constraint solver step, which allows collisions to negate forces that would violate their constraint parameters.  However forces are difficult to tune and compute for obtaining the effect you want which is why I usually do it a different way.<br><br>Blend toward the <strong class="text-strong">target_velocity</strong> every substep like so:<div class="codebox"><p>Code: </p><pre><code>// blend_timescale is the exponential timescale time it takes for the object to change its velocity// toward the target.  After one period the object will decrease the delta to 1/e of what it was.// The shorter the timescale the faster it adjusts, for very long timescales the// object takes forever to respond.  It cannot be shorter than the substep_period (else instability).// For best results it should be not less than two or three substep_periods, but typically for human// interaction timescales you can allow the period to be something closer to half a second.// This is your easy one-knob tuning adjustment to make the object's responsiveness just right.btScalar blend_timescale = 2.0; // seconds// blendbtScalar del = substep_period / blend_timescale;btVector3 new_velocity = (1.0 - del) * current_velocity + del * target_velocity;// slambody-&gt;setLinearVelocity(new_velocity);</code></pre></div>If you set the <strong class="text-strong">blend_timescale</strong> to a reasonable value then you give the collision constraints time to successfully push the object out of penetration.<br><br>Note, this method is mass agnostic.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Sun Aug 29, 2021 3:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[justjayel]]></name></author>
		<updated>2021-08-29T12:11:59+00:00</updated>

		<published>2021-08-29T12:11:59+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43570#p43570</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43570#p43570"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43570#p43570"><![CDATA[
I've tried setting the margin (at 0.05f and higher) after creating the collision shape and before adding it into the btDiscreteDynamicsWorld and it doesn't work. <br><div class="codebox"><p>Code: </p><pre><code>btCollisionShape* colliderShape = new btBoxShape(btVector3(inputs[0], inputs[1], inputs[2]));colliderShape-&gt;setMargin(0.5f);btRigidBody* rb = // create the rigid bodydynamicsWorld-&gt;addRigidBody(rb, 1, 1);</code></pre></div><br>For the main issue it doesn't occur if I am setting the linear velocity constantly for less than 60 frames. But I don't think that a viable workaround. <div class="codebox"><p>Code: </p><pre><code>if(i &gt; 50 &amp;&amp; i &lt; 110){btVector3 newVelocity = btVector3(2.0f, 0, 0);playerRb-&gt;setLinearVelocity(newVelocity);}</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14076">justjayel</a> — Sun Aug 29, 2021 12:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ed_welch]]></name></author>
		<updated>2021-08-29T10:32:01+00:00</updated>

		<published>2021-08-29T10:32:01+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43569#p43569</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43569#p43569"/>
		<title type="html"><![CDATA[Re: Object falls a third of its height through the ground]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43569#p43569"><![CDATA[
Try setting a small amount of margin on both objects:<br>pCollisionShape-&gt;setMargin(0.05f);<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11234">ed_welch</a> — Sun Aug 29, 2021 10:32 am</p><hr />
]]></content>
	</entry>
	</feed>
