Skip to main content

Velocity Control

set_velocity_source()​

Python
set_velocity_source(source: int) -> bool

Sets the velocity command source. Before calling set_velocity(), set the source to 2 (Navigation) and confirm by reading back, otherwise velocity commands are ignored by AuroraCore (the client gets no error; the robot log records Ignore velocity command because current velocity source is not 'Navigation').

ValueSourceDescription
0JoystickJoystick control
1HandheldHandheld device (APP)
2NavigationNavigation velocity source; used by AuroraClient velocity publishing

Returns: True means the service accepted the request. Still confirm with get_velocity_source() before sending non-zero velocity.

Example

Python
import os
import time

os.environ.setdefault("FASTDDS_BUILTIN_TRANSPORTS", "UDPv4") # required on the robot

from fourier_aurora_client import AuroraClient

client = AuroraClient.get_instance(domain_id=123, robot_name="grw")
try:
time.sleep(1.0)
if not client.set_velocity_source(2):
raise RuntimeError("velocity source request not accepted")

deadline = time.monotonic() + 2.0
while client.get_velocity_source() != 2:
if time.monotonic() >= deadline:
raise RuntimeError("velocity source did not switch to Navigation (2)")
time.sleep(0.05)
print(f"current source: {client.get_velocity_source()} ({client.get_velocity_source_name()})")
finally:
client.set_velocity_source(0) # hand control back to the joystick
client.close()

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 GR-W wheeled base. The command is published once and stays valid on the server for duration seconds, then expires automatically (e.g. a command with duration=0.5 decelerates within about 0.3 s after expiry). The GR-W velocity-control workflow uses state 3 (grw_policy_task); re-confirm state and velocity source after entering other states.

ParameterTypeDescription
vxfloatLinear velocity in X direction (forward positive, m/s)
vyfloatLinear velocity in Y direction (left positive, m/s)
yawfloatAngular velocity around Z axis (left-turn positive, rad/s)
durationfloatCommand validity duration (s), default 1.0

Example

Python
import os
import time

os.environ.setdefault("FASTDDS_BUILTIN_TRANSPORTS", "UDPv4") # required on the robot

from fourier_aurora_client import AuroraClient

client = AuroraClient.get_instance(domain_id=123, robot_name="grw")
try:
time.sleep(1.0)
if not client.set_fsm_state(3):
raise RuntimeError("state change request not accepted")
deadline = time.monotonic() + 4.0
while client.get_fsm_state() != 3:
if time.monotonic() >= deadline:
raise RuntimeError("state did not switch to grw_policy_task")
time.sleep(0.05)

if not client.set_velocity_source(2):
raise RuntimeError("velocity source request not accepted")
deadline = time.monotonic() + 2.0
while client.get_velocity_source() != 2:
if time.monotonic() >= deadline:
raise RuntimeError("velocity source did not switch to Navigation (2)")
time.sleep(0.05)

client.set_velocity(0.1, 0.0, 0.0, 1.0) # move forward ~10 cm at low speed
time.sleep(1.0)

client.set_velocity(0.0, 0.0, 0.0, 1.0) # stop
finally:
client.set_velocity(0.0, 0.0, 0.0, 1.0) # safety-net zero velocity
client.set_velocity_source(0) # hand control back to the joystick
client.close()