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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2025-03-17T10:16:47+00:00</updated>

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

		<entry>
		<author><name><![CDATA[otis]]></name></author>
		<updated>2025-03-17T10:16:47+00:00</updated>

		<published>2025-03-17T10:16:47+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44517#p44517</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44517#p44517"/>
		<title type="html"><![CDATA[Re: Replicate ai generated animation back in pybullet.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44517#p44517"><![CDATA[
To replicate AI-generated animations in PyBullet smoothly, ditch time.sleep() and sync playback to p.stepSimulation() with a fixed timestep like 1/240 Hz,<a href="https://buckshotroulette.com/home" class="postlink"><span style="color:#FFFFFF"><span style="font-size:1%;line-height:116%">Buckshot Roulette</span></span></a> interpolating joint positions between keyframes for fluidity.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14532">otis</a> — Mon Mar 17, 2025 10:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dodge]]></name></author>
		<updated>2023-01-30T01:44:23+00:00</updated>

		<published>2023-01-30T01:44:23+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44221#p44221</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44221#p44221"/>
		<title type="html"><![CDATA[Re: Replicate ai generated animation back in pybullet.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44221#p44221"><![CDATA[
I'm also interested to hear how this can be done<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14515">dodge</a> — Mon Jan 30, 2023 1:44 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[joebiden]]></name></author>
		<updated>2023-01-28T18:28:04+00:00</updated>

		<published>2023-01-28T18:28:04+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44219#p44219</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44219#p44219"/>
		<title type="html"><![CDATA[Re: Replicate ai generated animation back in pybullet.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44219#p44219"><![CDATA[
Replying to my own post because I really need some help. Anything would help, this is going to define how from now on will I record any new found simulations and have them tested in a manner which can be displayed effectively. We're talking about an advancement that I have been looking forward for about a month now.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14514">joebiden</a> — Sat Jan 28, 2023 6:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[joebiden]]></name></author>
		<updated>2023-01-28T09:25:07+00:00</updated>

		<published>2023-01-28T09:25:07+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44218#p44218</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44218#p44218"/>
		<title type="html"><![CDATA[Replicate ai generated animation back in pybullet.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=44218#p44218"><![CDATA[
Wassup fellow programmers I have been working on a project for a while now and decided this is the right time to get some advice, help or anything else idk. Long story short I have created and been training my own AI for a specific simulation of a movement and record that movement onto a JSON file, this would go through generations and generations to create better results and it did, but working with pybullet lead me to know that no matter the time parameters I give it, recorded joint info on its own implemented to replicate the animation would just run through all of the animations in a second. So I recorded time too but python is pretty darn slow to pick up the correct time to execute the exact movement in the exact time it is shown, rounding up the time would give a disaster where the body would just flinch and stop every split second, so after trying linear interpolation, setting the time step and numerous amounts of combinations for calculating time and still nothing worked. I ask you guys because Im sure my task was done at least once by one of you so I want to learn from you, what is your sauce?<br><br>To give you a more of a look into what I'm doing, heres a single 1/5 key out of the json file<br><div class="codebox"><p>Code: </p><pre><code>{"1.2839901447296143": {"0": {"joint_positions": -0.2660407240964722}, "1": {"joint_positions": 0.5304539359064856}, "2": {"joint_positions": -0.44852838864481787}, "3": {"joint_positions": -0.14016010671763662}, "4": {"joint_positions": 0.5558784919638431}, "5": {"joint_positions": 0.463813963178519}, "6": {"joint_positions": 0.1232185850913412}, "7": {"joint_positions": 0.5509734074329725}, "8": {"joint_positions": -0.5095558255751145}, "9": {"joint_positions": 0.08173290868566063}, "10": {"joint_positions": 0.3949344400183078}</code></pre></div>The full one would count all of the 50 joints respectively and such keys would go on into the hundreds.<br><br>The script that tries to replicate this is very simple<br><div class="codebox"><p>Code: </p><pre><code>import pybullet as pimport timeimport json# Connect to the PyBullet physics serverp.connect(p.GUI)p.setRealTimeSimulation(0)# Load the humanoid modelskeleton = p.loadURDF("skeleton.urdf", useFixedBase=False)p.setTimeStep(0.01)# add a ground planeplane_id = p.createCollisionShape(p.GEOM_PLANE)ground = p.createMultiBody(baseCollisionShapeIndex=plane_id, basePosition=[0, 0, 0])# enable collisions between the humanoid model and the ground planep.setCollisionFilterPair(skeleton, ground, -1, -1, 1)# set the gravityp.setGravity(0, 0, -9.8)# load the joint angles from json filewith open("joint_angles.json", "r") as file:    joint_angles = json.load(file)# Initialize a dictionary to store the current joint anglescurrent_joint_angles = {joint_num: 0 for joint_num in range(p.getNumJoints(skeleton))}# Get the start timestart_time = time.time()  +offset = [0, 0, 1]position, orientation = p.getBasePositionAndOrientation(skeleton)new_position = [position[i] + offset[i] for i in range(3)]p.resetBasePositionAndOrientation(skeleton, new_position, orientation)n = 1# Get the list of all time framestime_frames = list(joint_angles.keys())# Iterate through the time frames and set the joint anglsfor i, keyframe_time in enumerate(time_frames):    keyframe_time = float(keyframe_time)    current_time = time.time() - start_time     time_to_sleep = keyframe_time - current_time    while time_to_sleep &gt; 0:        time_to_sleep = keyframe_time - current_time    # Sleep for the calculated amount of time    time.sleep(time_to_sleep)    # Get the joint angles for this time frame    for joint_num, joint_data in joint_angles[str(keyframe_time)].items():        joint_positions = joint_data['joint_positions']        p.setJointMotorControl2(bodyIndex=0, jointIndex=int(joint_num), controlMode=p.POSITION_CONTROL, targetPosition=joint_positions)# Step the simulation    p.stepSimulation()print(time.time() - start_time)p.disconnect()</code></pre></div>Now Im sure this would be enough for you to understand a bit of the logic to try to figure something out yourself  but I know you will might notbe  able to fully replicate what I'm doing since of the sheer amount of data you might need to have to do so, so I want you to just to tell me more about the experience of you doing something similar to this rather than solving this like some overstackflow problem, python scripts are very appreciated. Furthermore the model is a XSensStyleModel generated using their motion capture, which I took from github: <a href="https://github.com/robotology/human-gazebo" class="postlink">https://github.com/robotology/human-gazebo</a> and found it has 50 joints, some are a bit glitchy on their own but it didnt really glitch me when I was doing simulations which I guess mostly because every movement was designed to not exceed their joint angles. <br><br>TLDR: <br>Give me your experience in replicating animations preferably in python (C++ scares me).<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14514">joebiden</a> — Sat Jan 28, 2023 9:25 am</p><hr />
]]></content>
	</entry>
	</feed>
