Velocity Control
set_velocity_source()
Python
set_velocity_source(source: int) -> bool
Sets the velocity command source. Must be set to 2 (Navigation) before calling set_velocity(), otherwise velocity commands are silently ignored.
| Value | Source | Description |
|---|---|---|
| 0 | Joystick | Joystick control |
| 1 | Handheld | Handheld device (APP) |
| 2 | Navigation | Client control |
Returns: True on success, False on timeout.
Example
Python
client.set_velocity_source(2) # switch to client control
get_velocity_source()
Python
get_velocity_source() -> int
Returns the current velocity command source value.
get_velocity_source_name()
Python
get_velocity_source_name() -> str
Returns the current velocity command source name string, e.g. "Navigation".
set_velocity()
Python
set_velocity(vx: float, vy: float, yaw: float, duration: float = 1.0)
Publishes a velocity command to the robot. The command is valid for duration seconds; the robot decelerates to a stop after it expires.
| Parameter | Type | Description |
|---|---|---|
vx | float | Linear velocity in X direction (forward positive, m/s) |
vy | float | Linear velocity in Y direction (left positive, m/s) |
yaw | float | Angular velocity around Z axis (left-turn positive, rad/s) |
duration | float | Command validity duration (s), default 1.0 |
Example
Python
client.set_velocity_source(2)
client.set_fsm_state(3) # switch to RL Locomotion
time.sleep(1.0)
client.set_velocity(0.5, 0.0, 0.0, 3.0) # move forward at 0.5 m/s for 3 s
time.sleep(3.0)
client.set_velocity(0.0, 0.0, 0.0, 1.0) # stop