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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2018-11-11T14:30:05+00:00</updated>

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

		<entry>
		<author><name><![CDATA[richardbloemenkamp]]></name></author>
		<updated>2018-11-11T14:30:05+00:00</updated>

		<published>2018-11-11T14:30:05+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41577#p41577</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41577#p41577"/>
		<title type="html"><![CDATA[Re: Rotate Object to Face Origin/Point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41577#p41577"><![CDATA[
I would do the same as you using the spherical coordinates and then transform to quaternion. I found however that with the Euler angles the order of the angle operations is important (first roll around the world-x, then yaw around the world-z, finally pitch around the world-y). In addition for the r2d2.urdf below, the x-direction is sideways, such that for the robot-pitch, I had to use the roll-angle to first rotate the robot around its y-axis and then add yaw. <br><br>Below the code I used:<br><div class="codebox"><p>Code: </p><pre><code>import pybullet as pimport timeimport numpy as npp.connect(p.GUI)p.createCollisionShape(p.GEOM_PLANE)p.resetDebugVisualizerCamera( cameraDistance=2, cameraYaw=10, cameraPitch=-20, cameraTargetPosition=[0.0, 0.0, 0.25])cubeStartPos = [0,0,1]cubeStartOrientation = p.getQuaternionFromEuler([0,0,0])boxId = p.loadURDF("r2d2.urdf",cubeStartPos, cubeStartOrientation)x=1y=0.5r_hor=np.sqrt(x*x+y*y)  #4.12 z=.7rollini = np.arctan2(z,r_hor) #0.4516 rad Needs roll because urdf x-direction points sidewaysphiini = np.arctan2(y,x)   #0.245 radiansthetaini = 0roll=-rolliniphi=phiini-np.pi-np.pi/2  #-np.pi/2 because urdf x-direction points sidewaystheta=thetainiq=p.getQuaternionFromEuler((roll,theta,phi))print(q)p.resetBasePositionAndOrientation(boxId,(x,y,z),q)t0=time.time()t=time.time()while ((t-t0)&lt;5):    t=time.time()p.disconnect()</code></pre></div>I hope this is of help.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13031">richardbloemenkamp</a> — Sun Nov 11, 2018 2:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[carcamdou]]></name></author>
		<updated>2018-11-07T13:05:19+00:00</updated>

		<published>2018-11-07T13:05:19+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41570#p41570</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41570#p41570"/>
		<title type="html"><![CDATA[Rotate Object to Face Origin/Point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=41570#p41570"><![CDATA[
Hello All! <br><br>I'm completely new to pybullet, and I've been having some trouble figuring things out. I read through the quickstart guide, but it doesn't seem to have anything along these lines. <br><br>I am interested in loading a URDF object and having it move around a sphere centered at the origin, always facing towards the origin. I have no problems getting a random (x,y,z) coordinate to place the position of the object, but figuring out how to get the quaternion is a bit of a problem for me. At the moment, I'm using spherical coordinates for the position and using from_spherical_coords(theta, phi) from this library (<a href="https://github.com/moble/quaternion" class="postlink">https://github.com/moble/quaternion</a>) to get the equivalent quaternion. I know this isn't right (both because it isn't working, and because it doesn't make much sense.<br><br>TLDR: If I loadURDF an object into the scene, how to do I figure out the quaternion needed to point its face at the origin (or an arbitrary point!)<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13077">carcamdou</a> — Wed Nov 07, 2018 1:05 pm</p><hr />
]]></content>
	</entry>
	</feed>
