# Robot Behaviors Different Between Orbit and Issac Sim

I am using the following code to move a mobile robot, the point is the robot movement is perfect in Issac Sim, in which when I listen to the robot’s velocity, it is moving at the velocity as commanded.

But when I used exactly the same usd in Orbit, something is wrong. The robot’s velocity cannot achieve the target velocity unless the target velocity is very big.

I suspect is the robot cfg file making this difference. Anything I should take care of when setting the cfg file?
Or any other reasons?

Thank you.

Here is the code:
from pxr import Usd, UsdGeom, Gf, UsdPhysics
import omni.usd

stage = omni.usd.get_context().get_stage()

prim = stage.GetPrimAtPath(“/World/Cube”)

rbo_api = UsdPhysics.RigidBodyAPI(prim)

if rbo_api:
velocity = Gf.Vec3f(500.0, 0.0, 0.0)
xform = UsdGeom.Xform(prim)
localToWorld = xform.ComputeLocalToWorldTransform(Usd.TimeCode.Default())
transform = Gf.Transform(localToWorld)
rotation = transform.GetRotation()
scale = Gf.Vec3f(transform.GetScale())
velocity = rotation.TransformDir(velocity)
velocity = Gf.CompMult(scale, velocity)

``````rbo_api.GetVelocityAttr().Set(velocity)
``````

Hi!

Is there any particular reason to do this via the USD and not the physics API? Can you share the code for Isaac Sim vs Orbit so that we can figure out where the issue might be popping from.

Thank you so much. Actually, I just noticed that it is not about the Sim and Orbit, they both are Sim, with a bit different scripting.

Now the problem changed. When listening to the velocities, they can achieve the target, but the travelled distances are different between Script 1 and Script 2, with the travelled distances in Script 1 being correct and Srcipt 2 being wrong.

The reason I am using this code:

1. I want to skip the driver and directly control the robot
2. I want to apply the velocity to the local frame rather than the global frame

And, this is the only code I know can achieve the requirements. If you have a better idea, I would like to know.
Thank you so much!

Here is the code for Script 1:

``````usd_path = "/home/bernard/Documents/HSR/My_Code/vec_5.usd"

robot = ArticulationView(prim_paths_expr = '/World/robot1/base_link', enable_dof_force_sensors = True)

stage = omni.usd.get_context().get_stage()
robot_base = UsdPhysics.RigidBodyAPI(prim)

world = World()  #physics_dt=0.1, rendering_dt=0.1 === it make robot flies.

world.reset()
robot.initialize()

def linear_vec(linear_velocity):
velocity = linear_velocity
xform = UsdGeom.Xform(prim)
localToWorld = xform.ComputeLocalToWorldTransform(Usd.TimeCode.Default())
transform = Gf.Transform(localToWorld)
rotation = transform.GetRotation()
scale = Gf.Vec3f(transform.GetScale())
velocity = rotation.TransformDir(velocity)
velocity = Gf.CompMult(scale, velocity)
robot_base.GetVelocityAttr().Set(velocity)
print(robot.get_linear_velocities())

world.reset()

while simulation_app.is_running():
# deal with pause/stop
if world.is_playing():
if world.current_time_step_index  > 1000 and world.current_time_step_index  < 1100:
linear_vec(Gf.Vec3f(0.1, 0.1, 0.0))

world.step(render=True)

simulation_app.close()
``````

Here is the code for Script 2:

``````usd_path = "/home/bernard/Documents/HSR/My_Code/vec_5.usd"

robot = ArticulationView(prim_paths_expr = '/World/robot1/base_link', enable_dof_force_sensors = True)

stage = omni.usd.get_context().get_stage()
robot_base = UsdPhysics.RigidBodyAPI(prim)

def design_scene():
# Ground-plane
kit_utils.create_ground_plane("/World/defaultGroundPlane")

def linear_vec(linear_velocity):
velocity = linear_velocity
xform = UsdGeom.Xform(prim)
localToWorld = xform.ComputeLocalToWorldTransform(Usd.TimeCode.Default())
transform = Gf.Transform(localToWorld)
rotation = transform.GetRotation()
scale = Gf.Vec3f(transform.GetScale())
velocity = rotation.TransformDir(velocity)
velocity = Gf.CompMult(scale, velocity)
robot_base.GetVelocityAttr().Set(velocity)
print(robot.get_linear_velocities())

def main():
sim = SimulationContext()

design_scene()
# Play the simulator
sim.reset()
# Acquire handles
# Initialize handles
robot.initialize()

while simulation_app.is_running():
if sim.is_playing():
if sim.current_time_step_index > 1000 and sim.current_time_step_index < 1100:
linear_vec(Gf.Vec3f(0.1, 0.1, 0.0))

sim.step()

if __name__ == "__main__":
# Run the main function
main()
# Close the simulator
simulation_app.close()
``````

hello, may I know if there is any feedback on this?
Thank you.

I have forwarded this issue to the Isaac Sim team since this isn’t Orbit related. They’ll get back to you soon I hope.

Ok, thank you so much.