sim2bot.Robot.set_velocity¶
set_velocity(qd: Sequence[float], robot: int = 0) -> None
¶
Stream a joint-velocity target to one robot.
Parameters:
-
qd(Sequence[float]) –Joint velocities in radians per second and discovered joint order.
-
robot(int, default:0) –Robot index returned by
describe.
Returns:
-
None–The velocity target is sent asynchronously.
Raises:
-
RuntimeError–If the client is not connected.
-
ConnectionClosed–If the WebSocket closes while sending the command.
-
OSError–If the selected transport cannot send the command.
Notes
Velocity control has a 500 ms safety watchdog. Refresh the command faster than that while motion should continue; stale targets expire. Commands may be sent faster than the browser applies them, in which case the newest value wins.
Warning
This command does not generate collision-free motion. Stop streaming
or call stop before leaving a control
loop.
Examples:
Stream a small velocity for 250 ms, then hold::
sim.set_velocity([0.1] + [0.0] * 6)
time.sleep(0.25)
sim.stop()
Source code in sim2bot/client.py
Practical examples¶
Examples use objects discovered from the current scene rather than hard-coded robot metadata.
Send a short velocity pulse
Refresh inside a control loop
Guidance¶
Usage tip
Use a finally block that calls stop() around long-running velocity-control loops.
Important behavior
Velocity targets expire after 500 ms. This protects against stale commands but is not a certified emergency stop.
Common error
Sending one velocity command and then waiting longer than 500 ms will not produce continuous motion.