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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2023-11-14T16:13:06+00:00</updated>

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

		<entry>
		<author><name><![CDATA[gjaegy]]></name></author>
		<updated>2023-11-14T16:13:06+00:00</updated>

		<published>2023-11-14T16:13:06+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44477#p44477</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44477#p44477"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44477#p44477"><![CDATA[
I've played with the masses a lot, and no, this didn't really fixed the instability/wobbling issue (but I guess it had an impact on the gap).<br><br>So I'll keep my existing solution for now <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2399">gjaegy</a> — Tue Nov 14, 2023 4:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2023-11-14T15:54:19+00:00</updated>

		<published>2023-11-14T15:54:19+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44476#p44476</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44476#p44476"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44476#p44476"><![CDATA[
Oh hey, you're right!  And <strong class="text-strong">btDiscreteDynamicsWorld::saveKinematicState()</strong> is called once per step rather than per substep.  This means idea <strong class="text-strong">(1)</strong> would NOT solve your original problem, and also reintroduces the original mystery: Why would the first constraint relax so much?<br><br>I understand you tried different masses for the kinematic helicopter and the problem persisted, but was the problem also invariant?  That is, changing the mass ratio didn't grow or shrink the gap?  If the constraint solver thinks the helicopter should "respond" to the tension on it (but it doesn't because it is kinematic) then I could see how the constraint would relax too much, but if this were the case then I would expect increasing the relative mass of the helicopter would inform the constraint solver to reduce the gap, but I assume you fiddled with the mass ratios and would have noticed if this were happening.<br><br>I'm stumped, but at least you have a workaround, which looks good to me BTW.  It sounds like an explicit enforcement of a particular "fixed" constraint and would help the constraint solver reach a more correct solution for the rest of them.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Nov 14, 2023 3:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gjaegy]]></name></author>
		<updated>2023-11-14T07:30:54+00:00</updated>

		<published>2023-11-14T07:30:54+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44475#p44475</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44475#p44475"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44475#p44475"><![CDATA[
I see... :/<br><br>I just had a look at the code. Actually, the current implementation of btDiscreteDynamicsWorld::synchronizeSingleMotionState() starts with the following line:<blockquote class="uncited"><div>if (body-&gt;getMotionState() &amp;&amp; !body-&gt;isStaticOrKinematicObject())</div></blockquote>That means, kinematic objects are not updated in that call at all in the current implementation.<br><br>That seems to be done in btDiscreteDynamicsWorld::saveKinematicState(), which is currently already called before the internalSingleStepSimulation() call.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2399">gjaegy</a> — Tue Nov 14, 2023 7:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2023-11-14T01:02:27+00:00</updated>

		<published>2023-11-14T01:02:27+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44474#p44474</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44474#p44474"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44474#p44474"><![CDATA[
<blockquote class="uncited"><div>So, shouldn't that swapped order be the default implementation actually ?</div></blockquote>Yes, I would think so, since it would fix the problem you were seeing while introducing minimal undesired behavior changes.  However, I doubt Erwin would accept such a change if a PR was created.  There is already a <a href="https://github.com/bulletphysics/bullet3/pulls" class="postlink">large backlog of submitted PRs</a> (count=117 as I type this), many of which look good.  He probably doesn't have enough time/resources to test the proposed changes.  Perhaps the pressure will build until someone with the time and inclination decides to fork Bullet and manage a modern version.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Nov 14, 2023 1:02 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gjaegy]]></name></author>
		<updated>2023-11-13T20:14:26+00:00</updated>

		<published>2023-11-13T20:14:26+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44473#p44473</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44473#p44473"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44473#p44473"><![CDATA[
<blockquote class="uncited"><div>It isn't that we would be calling btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates() before stepping the simulation. Rather, we would just be swapping the order of sub-parts that happen during the step.</div></blockquote>I got that point, didn't express myself very well.<br><br>So, shouldn't that swapped order be the default implementation actually ?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2399">gjaegy</a> — Mon Nov 13, 2023 8:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2023-11-13T16:37:37+00:00</updated>

		<published>2023-11-13T16:37:37+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44472#p44472</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44472#p44472"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44472#p44472"><![CDATA[
<blockquote class="uncited"><div>...what are the consequences of adding/moving that btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates() call prior to stepping the simulation... ?</div></blockquote>It isn't that we would be calling <strong class="text-strong">btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates()</strong> before stepping the simulation.  Rather, we would just be swapping the order of sub-parts that happen during the step.  The kinematic advance would happen prior to solving constraints, integrating dynamic objects forward, and execution of <strong class="text-strong">Actions</strong>.  Kinematic objects are usually not governed by the simulation itself, but by motion dictated from outside logic (e.g. by whatever the <strong class="text-strong">KinematicMotionState</strong> is doing) so it doesn't really matter to them whether they are updated first or second.  Dynamic objects, on the other hand, can be moved by collisions with kinematic which means... in the modified system dynamic objects will use the current substep's notion of kinematic transform+velocity rather than those from the previous substep.  I can't think of likely ways this would break a game simulation however perhaps I lack imagination.<br><br>An example of a kinematic object that cares about simulation state would be something like the <strong class="text-strong">btKinematicCharacterController</strong>, which can "bump" into obstacles in the world.  However, its collision logic happens as part of an <strong class="text-strong">Action</strong> rather than a <strong class="text-strong">MotionState</strong>, so I would expect it to work as normal.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Mon Nov 13, 2023 4:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gjaegy]]></name></author>
		<updated>2023-11-13T08:01:04+00:00</updated>

		<published>2023-11-13T08:01:04+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44471#p44471</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44471#p44471"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44471#p44471"><![CDATA[
Hi drleviathan,<br><br>Thanks a lot for your answer, I appreciate it. <br><br>Actually, I had to deliver so managed to find a solution by basically getting rid of the constraint between the kinematic object and the first (top) chain element. I'm now updating the position/orientation of the first chain manually, in addition to the angular and linear velocities, according to the kinematic object position/orientation and velocities, after each physics update step. Which might basically lead to the same results as your suggestions (mathematically), I guess.<br><br>This solutions works well, at least, it produces a nice and smooth simulation, even with a standard 16.6ms time step (which is great).<br><br>I will however consider your two options since they look a bit cleaner. It now makes things clearer and explain the effects I was seeing. I didn't see that btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates() call in the code and miss that one completely.<br><br>Option 1 sounds the easiest/quickest to implement indeed, however, I was wondering what are the consequences of adding/moving that btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates() call prior to stepping the simulation (by consequences, I mean difference with simulation results, not tiny performance hit from the added call) ?<br><br>Thanks again for taking the time to answer !<br><br>Cheers,<br>Greg<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2399">gjaegy</a> — Mon Nov 13, 2023 8:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2023-11-12T16:15:15+00:00</updated>

		<published>2023-11-12T16:15:15+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44468#p44468</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44468#p44468"/>
		<title type="html"><![CDATA[Re: Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44468#p44468"><![CDATA[
The problem is: for each substep constraints are solved prior to moving kinematic objects.  If  you examine the implementation of <strong class="text-strong">btDiscreteDynamicsWorld::stepSimulation()</strong> you'll see for each substep: <strong class="text-strong">btDiscreteDynamicsWorld::internalSingleStepSimulation()</strong> is called before <strong class="text-strong">btDiscreteDhnaicsWorld::synchronizeMotionStates()</strong>.  The constraints are solved in the former, kinematic objects are moved in the latter.<br><br>A solution is definitely NOT to swap the order of those two calls.  The MotionStates of dynamic objects need to be synchronized AFTER they move.<br><br>I can think of two solutions to try:<br><br><strong class="text-strong">(1)</strong> Hack your bullet library like so: add <strong class="text-strong">btDiscreteDynamicsWorld::synchronizeKinematicMotionsStates()</strong> which works as named.  Call it before <strong class="text-strong">btDiscreteDynamicsWorld::internalSingleStepSimulation()</strong>.  You probably don't even need to modify <strong class="text-strong">btDiscreteDhnaicsWorld::synchronizeMotionStates()</strong> since any movement it would apply to the kinematic rigid body would just be redundant, however if you have A LOT of kinematic objects moving around then you would have an opportunity to optimize out the redundant work.  BTW for the record (e.g. for future audience who might not know)... in whatever MotionState you're using to move your kinematic objects be sure to also set their velocities to agree with whatever is their changing transform --&gt; for more correct collision results when dynamic objects hit them.<br><br><strong class="text-strong">(2)</strong> Write a custom Action to dynamically offset the constraint's kinematic-object-relative transform each substep.  In other words: derive from <strong class="text-strong">btActionInterface</strong> and implement <strong class="text-strong">Action::updateAction()</strong> to measure the future world-frame position of the parent kinematic object, measure the difference, transform that into the correct local-frame, and then adjust the constraints corresponding offset transform accordingly.  For each kinematic object that has a constraint hanging off of it: instantiate your Action, give it enough context to get its work done (e.g pointers to the relevant kinematic object and constraint) and add it to the world.  This method would require you to get the math right, which is always tricky.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Sun Nov 12, 2023 4:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[gjaegy]]></name></author>
		<updated>2023-10-18T08:30:10+00:00</updated>

		<published>2023-10-18T08:30:10+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44459#p44459</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44459#p44459"/>
		<title type="html"><![CDATA[Constraints between kinematic and dynamic rigid bodies]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44459#p44459"><![CDATA[
Hi,<br><br>I'm facing an issue with a chain of dynamic rigid bodies, linked together with 6DOFSpring2 constraints, and linked to a kinematic rigid body using the same constraint type. I've spent days trying to solve it, unsuccessfully, so I thought I would ask for some help :/<br><br>When the dynamic object (the helicopter) is not moving, everything looks perfect:<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1996" class="postimage" alt="kinematic_static.jpg" onclick="viewableArea(this);" /></dt></dl></div>However, as soon as the kinematic object moves, the chain seems to "detach" from the kinematic object, and seems to travel further from what one would expect (1 or 2 meters too far). The constraint seems to relax quite heavily (while the constraints used to link dynamic rigid bodies look fine):<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1997" class="postimage" alt="kinematic_moving.jpg" onclick="viewableArea(this);" /></dt></dl></div>I've tried to change the mass of all objects (1:1 ratio, other ratio, 0 for kinematic, non-zero for kinematic, other solver, smaller time step), however, whatever I've tried, the issue is still present. The faster the helicopter moves, the bigger the "gap". <br><br>According to the debug draw, the constraints seems to be located at a fairly right position, but the rigid bodies are not. They seem to move faster forwards than the kinematic object itself (i.e. the offset is always in the movement direction).<br><br>Any idea how I could reduce that gap ? Thanks a lot !<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2399">gjaegy</a> — Wed Oct 18, 2023 8:30 am</p><hr />
]]></content>
	</entry>
	</feed>
