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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2020-01-20T19:59:57+00:00</updated>

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

		<entry>
		<author><name><![CDATA[zhsh]]></name></author>
		<updated>2020-01-20T18:42:37+00:00</updated>

		<published>2020-01-20T18:42:37+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42584#p42584</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42584#p42584"/>
		<title type="html"><![CDATA[Re: Isometric friction for planar pushing]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42584#p42584"><![CDATA[
Update with a simpler example and minimum reproducing code (depends on numpy and matplotlib).<br>This time I'm pushing the block directly in block frame by applying an external force without any pusher.<br>However we still see that the dynamics is strongly correlated with yaw:<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1777" class="postimage" alt="dyaw_wrt_yaw_2.png" onclick="viewableArea(this);" /></dt></dl></div><div class="codebox"><p>Code: </p><pre><code>import loggingimport mathimport pybullet as pimport timeimport numpy as npimport pybullet_datafrom matplotlib import pyplot as pltlogger = logging.getLogger(__name__)logging.basicConfig(level=logging.DEBUG,                    format='[%(levelname)s %(asctime)s %(pathname)s:%(lineno)d] %(message)s',                    datefmt='%m-%d %H:%M:%S')logging.getLogger('matplotlib.font_manager').disabled = Truedef rotate_wrt_origin(xy, theta):    return (xy[0] * math.cos(theta) - xy[1] * math.sin(theta),            xy[0] * math.sin(theta) + xy[1] * math.cos(theta))def angular_diff(a, b):    """Angle difference from b to a (a - b)"""    d = a - b    if d &gt; math.pi:        d -= 2 * math.pi    elif d &lt; -math.pi:        d += 2 * math.pi    return ddef get_dx(px, cx):    dpos = cx[:2] - px[:2]    dyaw = angular_diff(cx[2], px[2])    dx = np.r_[dpos, dyaw]    return dxdef dx_to_dz(px, dx):    dz = np.zeros_like(dx)    # dyaw is the same    dz[2] = dx[2]    dz[:2] = rotate_wrt_origin(dx[:2], px[2])    return dzinit_block_pos = [0.0, 0.0]init_block_yaw = -0.physics_client = p.connect(p.GUI)p.setTimeStep(1. / 240.)p.setRealTimeSimulation(False)p.setAdditionalSearchPath(pybullet_data.getDataPath())blockId = p.loadURDF("./block_big.urdf", tuple(init_block_pos) + (-0.02,),                     p.getQuaternionFromEuler([0, 0, init_block_yaw]))planeId = p.loadURDF("plane.urdf", [0, 0, -0.05], useFixedBase=True)p.resetDebugVisualizerCamera(cameraDistance=0.5, cameraYaw=0, cameraPitch=-85,                             cameraTargetPosition=[0, 0, 1])STATIC_VELOCITY_THRESHOLD = 1e-6def _observe_block(blockId):    blockPose = p.getBasePositionAndOrientation(blockId)    xb = blockPose[0][0]    yb = blockPose[0][1]    roll, pitch, yaw = p.getEulerFromQuaternion(blockPose[1])    return np.array((xb, yb, yaw))def _static_environment():    v, va = p.getBaseVelocity(blockId)    if (np.linalg.norm(v) &gt; STATIC_VELOCITY_THRESHOLD) or (            np.linalg.norm(va) &gt; STATIC_VELOCITY_THRESHOLD):        return False    return Truep.setGravity(0, 0, -10)# p.changeDynamics(blockId, -1, lateralFriction=0.1)p.changeDynamics(planeId, -1, lateralFriction=0.5, spinningFriction=0.3, rollingFriction=0.1)F = 200MAX_ALONG = 0.075 + 0.2for _ in range(100):    p.stepSimulation()N = 100yaws = np.zeros(N)z_os = np.zeros((N, 3))for simTime in range(N):    # observe difference from pushing    px = _observe_block(blockId)    yaws[simTime] = px[2]    p.applyExternalForce(blockId, -1, [F, F, 0], [-MAX_ALONG, MAX_ALONG, 0.025], p.LINK_FRAME)    p.stepSimulation()    while not _static_environment():        for _ in range(100):            p.stepSimulation()    cx = _observe_block(blockId)    # difference in world frame    dx = get_dx(px, cx)    dz = dx_to_dz(px, dx)    z_os[simTime] = dz    logger.info("dx %s dz %s", dx, dz)    time.sleep(0.1)logger.info(z_os.std(0) / np.abs(np.mean(z_os, 0)))plt.scatter(yaws, z_os[:, 2])plt.xlabel('yaw')plt.ylabel('dyaw')plt.show()</code></pre></div>You'll need to place this urdf file in the same directory (save as block_big.urdf):<br><div class="codebox"><p>Code: </p><pre><code>&lt;robot name="block_big" xmlns:xacro="http://www.ros.org/wiki/xacro"&gt;  &lt;link name="base_link"&gt;    &lt;contact&gt;      &lt;lateral_friction value="0.9"/&gt;      &lt;spinning_friction value=".1"/&gt;      &lt;rolling_friction value=".1"/&gt;    &lt;/contact&gt;    &lt;inertial&gt;      &lt;origin rpy="0 0 0" xyz="0 0 0"/&gt;      &lt;mass value="6.0"/&gt;      &lt;inertia ixx="0.1525" ixy="0" ixz="0" iyy="0.1525" iyz="0" izz="0.3025"/&gt;    &lt;/inertial&gt;    &lt;visual&gt;      &lt;origin rpy="0 0 0" xyz="0.0 0.0 0.0"/&gt;      &lt;geometry&gt;        &lt;box size="0.55 0.55 0.05"/&gt;      &lt;/geometry&gt;      &lt;material name="blockmat"&gt;        &lt;color rgba="0.1 0.7 0.1 0.8"/&gt;      &lt;/material&gt;    &lt;/visual&gt;    &lt;collision&gt;      &lt;origin rpy="0 0 0" xyz="0.0 0.0 0.0"/&gt;      &lt;geometry&gt;        &lt;box size="0.55 0.55 0.05"/&gt;      &lt;/geometry&gt;    &lt;/collision&gt;  &lt;/link&gt;&lt;/robot&gt;</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13049">zhsh</a> — Mon Jan 20, 2020 6:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[zhsh]]></name></author>
		<updated>2020-01-20T19:59:57+00:00</updated>

		<published>2020-01-18T18:18:30+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42574#p42574</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42574#p42574"/>
		<title type="html"><![CDATA[Isometric friction for planar pushing]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=42574#p42574"><![CDATA[
<strong class="text-strong">Update</strong>: see next post for minimum reproducable for a simplified experiment!<br><br>I'm trying to do quasi-static planar pushing by position controlling the pusher (brown) with p.createConstraint.<br>The issue I'm having is that the dynamics seem to be different with different yaw of the pusher-block system (keeping their relative positions the same). I'm investigating this by telling the pusher to push perpendicular to the adjacent face for a fixed position for different yaws of the whole system.<br>Control of the pusher is done by <div class="codebox"><p>Code: </p><pre><code>p.changeConstraint(self.pusherConstraint, newPos, maxForce=200)</code></pre></div> then waiting for velocities to die down for quasi-staticness. I've also tried manually interpolating to the goal position by controlling to intermediate waypoints in case the previous method causes the block to leave contact (it doesn't).<br>The configuration of the system:<div class="codebox"><p>Code: </p><pre><code>block dimensions: 0.15 x 0.15 x 0.05mass: 6lateral_friction 1.0spinning_friction: 0.1pusher dimensions: 0.15 x 0.02mass: 10lateral_friction: 1.0spinning_friction: 0.1</code></pre></div>The test I'm doing is to push 0.02 into the block, for 11 different system yaws from 0 to 3.1 (radians). I then look at the change in body frame (block x, block y, block yaw, pusher position along block). I summarize the trials with the standard deviation along each dimension relative to the absolute value of that dimension's mean. For example I get<div class="codebox"><p>Code: </p><pre><code>tensor([0.0285, 0.2691, 0.2714, 0.2669])</code></pre></div>For trials that result in block frame differences of:<div class="codebox"><p>Code: </p><pre><code>tensor([[ 0.0184, -0.0022, -0.0309, -0.0007],        [ 0.0181, -0.0028, -0.0378, -0.0008],        [ 0.0172, -0.0039, -0.0531, -0.0011],        [ 0.0183, -0.0023, -0.0307, -0.0006],        [ 0.0187, -0.0019, -0.0260, -0.0005],        [ 0.0184, -0.0023, -0.0304, -0.0006],        [ 0.0176, -0.0033, -0.0455, -0.0010],        [ 0.0176, -0.0034, -0.0462, -0.0010],        [ 0.0187, -0.0018, -0.0247, -0.0005],        [ 0.0184, -0.0022, -0.0301, -0.0006]])</code></pre></div>These should be the same if friction is isometric right? I've tried making the block bigger, but it doesn't really help.<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1776" class="postimage" alt="Screen Shot 2020-01-18 at 12.54.54 PM.png" onclick="viewableArea(this);" /></dt></dl></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13049">zhsh</a> — Sat Jan 18, 2020 6:18 pm</p><hr />
]]></content>
	</entry>
	</feed>
