# HRIM usage scenario

First set up your environment following these steps.

Then, after sourcing your workspace:

source /opt/ros/crystal/setup.bash
source ~/ros2_mara_ws/install/setup.bash

Launch a simulation with a T4.9 joint:

ros2 launch hans_modular_gazebo hans_t9_4.launch.py

And source your workspace again in another terminal to interact with thew ROS2 topics.

On this second terminal, when listing all ros2 topics (ros2 topic list) a list like the following will appear (more topics than these should appear):

/hros_actuation_servomotor_000000000001/goal
/hros_actuation_servomotor_000000000001/power
/hros_actuation_servomotor_000000000001/state
/hros_actuation_servomotor_000000000001/state_comm
/hros_actuation_servomotor_000000000001/status
/hros_actuation_servomotor_000000000001/trajectory
/hros_actuation_servomotor_0000000000012/goal
/hros_actuation_servomotor_0000000000012/state
/hros_actuation_servomotor_0000000000012/trajectory

And listing available services (ros2 service list) will show a list like the following (more services than these should appear):

/hros_actuation_servomotor_000000000001/id
/hros_actuation_servomotor_000000000001/module_3d
/hros_actuation_servomotor_000000000001/module_urdf
/hros_actuation_servomotor_000000000001/specs
/hros_actuation_servomotor_000000000001/specs_comm

We can check out the /hros_actuation_servomotor_000000000001/specs service to get a list of the component's capabilities by calling it with an empty call:

ros2 service call /hros_actuation_servomotor_000000000001/specs hrim_actuator_rotaryservo_srvs/SpecsRotaryServo

It's response will look like (formatted for readability):

response:
hrim_actuator_rotaryservo_srvs.srv.SpecsRotaryServo_Response(
control_type = 4,
range_min = -3.14,
range_max = 3.14,
precision = 8.722222e-05,
rated_speed = 1.46607657,
reachable_speed = 1.46607657,
rated_torque = 9.0,
reachable_torque = 13.0,
temperature_range_min = -10.0,
temperature_range_max = 50.0
)

One of these values is an enumeration value (control_type), its possible values are:

uint8 CONTROL_TYPE_NONE=0
uint8 CONTROL_TYPE_POSITION=1
uint8 CONTROL_TYPE_EFFORT=2
uint8 CONTROL_TYPE_VELOCITY=3
uint8 CONTROL_TYPE_POSITION_VELOCITY=4
uint8 CONTROL_TYPE_POSITION_EFFORT=5
uint8 CONTROL_TYPE_VELOCITY_EFFORT=6
uint8 CONTROL_TYPE_POSITION_VELOCITY_EFFORT=7

You can know what these values are from the command line by showing the definition of the SpecsRotaryServo service interface:

ros2 srv show hrim_actuator_rotaryservo_srvs/SpecsRotaryServo

So from the specs response above we know the servomotor capabilities are the following:

• Can be controlled by both position and/or velocity.
• Its position limits are -/+ 3.14.
• Its max speed is 1.4660766124725342 (lets say 1.466).

Knowing this, let's move it! The following commands will rotate the joints at max speed to the maximum and minimum positions, respectively:

ros2 topic pub -1 /hros_actuation_servomotor_000000000001/goal hrim_actuator_rotaryservo_msgs/GoalRotaryServo "{position: 3.14, velocity: 1.466}"
ros2 topic pub -1 /hros_actuation_servomotor_000000000001/goal hrim_actuator_rotaryservo_msgs/GoalRotaryServo "{position: -3.14, velocity: 1.466}"

This same process, albeit with different interfaces depending on the component, is applicable across all HRIM-supporting components; the specs services define the capabilities of a component, to which the system can adapt automatically as they are accesible for it in a machine-readable manner.