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):

/hrim_actuator_rotaryservo_000000000001/goal
/hrim_actuator_rotaryservo_000000000001/power
/hrim_actuator_rotaryservo_000000000001/state
/hrim_actuator_rotaryservo_000000000001/state_comm
/hrim_actuator_rotaryservo_000000000001/status
/hrim_actuator_rotaryservo_000000000001/trajectory
/hrim_actuator_rotaryservo_0000000000012/goal
/hrim_actuator_rotaryservo_0000000000012/state
/hrim_actuator_rotaryservo_0000000000012/trajectory

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

/hrim_actuator_rotaryservo_000000000001/id
/hrim_actuator_rotaryservo_000000000001/module_3d
/hrim_actuator_rotaryservo_000000000001/module_urdf
/hrim_actuator_rotaryservo_000000000001/specs
/hrim_actuator_rotaryservo_000000000001/specs_comm

ros2 service list -t can be used to also list each service's used interface in a {service_name} [{service_type}] manner

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

ros2 service call /hrim_actuator_rotaryservo_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 /hrim_actuator_rotaryservo_000000000001/goal hrim_actuator_rotaryservo_msgs/GoalRotaryServo "{position: 3.14, velocity: 1.466}"
ros2 topic pub -1 /hrim_actuator_rotaryservo_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.