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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2020-12-07T15:17:12+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Dyu]]></name></author>
		<updated>2020-12-07T15:17:12+00:00</updated>

		<published>2020-12-07T15:17:12+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43211#p43211</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43211#p43211"/>
		<title type="html"><![CDATA[Controlling a robot using Position Control, while taking into account the joint velocities]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43211#p43211"><![CDATA[
Hi,<br>I want to control a robot using Position Control and at the same time restrict the joint velocities to their maximum values.<br>I need to control all joints at once so using <strong class="text-strong">p.setJointMotorControlArray()</strong> is preferable instead of <strong class="text-strong">p.setJointMotorControl2()</strong><br><br>Since <strong class="text-strong">p.setJointMotorControlArray()</strong> does not have a "maxVelocity" parameter, this is what I'm doing to take max velocities into account:<br><div class="codebox"><p>Code: </p><pre><code>target_joint_positions = [x, y, z]current_joint_positions = [x', y', z']joint_velocity_limits = [a, b, c]# Calculate relative positionsjoint_position_difference = target_joint_positions - current_joint_positions# Calculate the time needed to complete the motion -- This will determine how many times to call p.stepSimulation() (1/240 of a second)max_total_time = max(joint_positions_difference / joint_velocity_limits)# Number of times to call p.stepSimulationnum_timesteps = ceil( max_total_time / (1/240) )# Divide the motion into equal steps that will each take less than or 1/240 th of a seconddelta_joint_positions = joint_positions_difference / num_timesteps# Make the robot move to the target positions in an additive mannerfor t in range(1, num_timesteps+1):joint_positions = current_joint_positions + delta_joint_positions * tp.setJointMotorControlArray(id, [0,1,2], p.POSITION_CONTROL, targetPositions=joint_positions)# Step the simulation by 1/240 secondsp.stepSimulation()time.sleep(1/240)</code></pre></div>This does not complete the motion. The joint angles come close to their targets, but not exactly. <br>However, When I switch on <strong class="text-strong">p.setRealTimeSimulation(1)</strong>, It completes the motion. <br>Is there something I haven't understood about <strong class="text-strong">p.stepSimulation()</strong> ? What could be wrong?<br>Thanks!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13785">Dyu</a> — Mon Dec 07, 2020 3:17 pm</p><hr />
]]></content>
	</entry>
	</feed>
