agents.components.vla#
Module Contents#
Classes#
This component utilizes Vision-Language-Action (VLA) policies served on the LeRobot Async Policy Server (e.g. SmolVLA, Pi0/Pi0.5, NVIDIA GR00T N1.7, ACT, Diffusion) for robot manipulation and control tasks. |
API#
- class agents.components.vla.VLA(*, inputs: List[agents.ros.Topic], outputs: List[agents.ros.Topic], model_client: agents.clients.lerobot.LeRobotClient, config: agents.config.VLAConfig, component_name: str, **kwargs)#
Bases:
agents.components.model_component.ModelComponentThis component utilizes Vision-Language-Action (VLA) policies served on the LeRobot Async Policy Server (e.g. SmolVLA, Pi0/Pi0.5, NVIDIA GR00T N1.7, ACT, Diffusion) for robot manipulation and control tasks.
The component runs as a ROS2 Action Server exposing the
<component_name>/manipulate_with_vlaaction which takes a natural language task description as its goal. While a goal is active, the component continuously streams observations (mapped joint states and camera images) to the policy server atobservation_sending_rateand publishes the received action chunks as joint commands ataction_sending_rate. Overlapping action chunks from consecutive inferences are merged using the aggregation strategy set in the config (or a custom callable set withset_aggregation_function). Goal termination is configured withset_termination_trigger(after a number of timesteps, on a key press, or on an event).- Parameters:
inputs (list[Topic]) – The input topics for the VLA component. This should be a list of Topic objects, containing exactly one JointState topic and at least one Image (or RGBD) topic. The camera topics should be mapped to the dataset camera names in
camera_inputs_mapof the config.outputs (list[Topic]) – The output topics for the VLA component. This should be a list of Topic objects. JointState, JointTrajectory and JointJog types are handled automatically, covering common input formats for MoveIt Servo and ROS2 Control.
model_client (LeRobotClient) – The model client for the VLA component. This must be an instance of LeRobotClient, connected to a running LeRobot Async Policy Server which serves the policy defined in a LeRobotPolicy model.
config (VLAConfig) – The configuration for the VLA component. This should be an instance of VLAConfig.
joint_names_mapandcamera_inputs_mapare required to map the dataset feature names to the robot’s joints and camera topics.component_name (str) – The name of the VLA component. This should be a string.
Example usage:
joint_states = Topic(name="joint_states", msg_type="JointState") camera = Topic(name="camera/image_raw", msg_type="Image") joint_cmd = Topic(name="joint_cmd", msg_type="JointState") policy = LeRobotPolicy( name="pick_policy", checkpoint="my_hf_user/smolvla_finetuned", policy_type="smolvla", dataset_info_file="https://huggingface.co/datasets/my_hf_user/my_dataset/resolve/main/meta/info.json", ) model_client = LeRobotClient(model=policy, host="127.0.0.1", port=8080) config = VLAConfig( joint_names_map={ "shoulder_pan.pos": "Rotation", "elbow_flex.pos": "Elbow", }, camera_inputs_map={"front": camera}, robot_urdf_file="./my_robot.urdf", ) vla_component = VLA( inputs=[joint_states, camera], outputs=[joint_cmd], model_client=model_client, config=config, component_name="vla", ) vla_component.set_termination_trigger(mode="timesteps", max_timesteps=200)
A task can then be sent to the running component as a ROS2 action goal, e.g. from the command line:
ros2 action send_goal /vla/manipulate_with_vla automatika_embodied_agents/action/VisionLanguageAction "{task: 'pick up the orange'}"- custom_on_activate()#
Custom activation
- custom_on_deactivate()#
Custom deactivation
- set_termination_trigger(mode: Literal[timesteps, pynput.keyboard, event] = 'timesteps', max_timesteps: int = 100, stop_key: str = 'q', stop_event: Optional[agents.ros.Event] = None)#
Set the condition used to determine when an action is done.
- Parameters:
mode – One of ‘timesteps’, ‘keyboard’, ‘event’.
max_timesteps – The number of timesteps after which to stop (used if mode=‘timesteps’ or ‘event’).
stop_key – The key to press to stop the action (used if mode=‘keyboard’).
- signal_done() agents.ros.ActionReturnType#
Signals that the action is complete. Can be used as an action for signaled events
- get_current_task() agents.ros.ActionReturnType#
The task of the goal that is running, as the goal gave it. Fails when no task is running.
- Returns:
Whether a goal is running, with its task
- Return type:
ActionReturnType
- set_aggregation_function(agg_fn: Callable[[numpy.ndarray, numpy.ndarray], numpy.ndarray])#
Set the aggregation function to be used for aggregating generated actions from the robot policy model
- Parameters:
agg_fn (Callable[[np.ndarray, np.ndarray], np.ndarray]) – A callable that takes two numpy arrays as input and returns a single numpy array.
- Raises:
TypeError – If
agg_fnis not a callable or does not match the expected signature.
- main_action_callback(goal_handle: agents.ros.VisionLanguageAction.Goal)#
Callback for the VLA main action server
- Parameters:
goal_handle (VisionLanguageAction.Goal) – Incoming action goal
- Returns:
Action result
- Return type:
VisionLanguageAction.Result