11.3. Usage
11.3.1. Run the xyz Setup
$ ros2 launch gantry xyz_motors.launch.py
This will start the three motors for the x-, y-, and z-axis, respectively.
The configuration files for the motors are found in gantry/config/motor_<axis_name>.yaml
.
11.3.2. Home the Motors
Important
Always make sure that the motors are homed before sending any setpoints!
Note
The motor position is stored inside the motion controller and not inside any code running on the Raspberry Pi or any ROS node. Relaunching any node does not make it necessary to rerun the homing procedure 🥳.
Move the motors to the home position.
The motors provide a service to move to the home position.
$ ros2 service call /gantry/motor_x/start_homing std_srvs/srv/Trigger{}
$ ros2 service call /gantry/motor_y/start_homing std_srvs/srv/Trigger {}
$ ros2 service call /gantry/motor_z/start_homing std_srvs/srv/Trigger {}
Set the current position. Usually this will be 0 but we can also specify arbitrary values either in motor dimensions (i.e. increments) or in physical dimensions ([m]).
$ ros2 service call /gantry/motor_x/set_home_position gantry_msgs/srv/SetHomePosition {}
$ ros2 service call /gantry/motor_y/set_home_position gantry_msgs/srv/SetHomePosition {}
$ ros2 service call /gantry/motor_z/set_home_position gantry_msgs/srv/SetHomePosition {}
Todo
Add an example for non zero values
11.3.3. Smooth Accelerations in Position Mode
The maximum acceleration can be set via the ~/set_max_accel
service.
If the maximum acceleration is higher than what the motor can acutally achieve (it has to move quite a bit of mass) it will overshoot the target position.
For smoother accelerations we can reduce the acceleration to a smaller value.
To get the currently set value run
$ ros2 service call /gantry_motor_x/get_max_accel gantry_msgs/srv/GetFloatDrive {}
$ ros2 service call /gantry_motor_y/get_max_accel gantry_msgs/srv/GetFloatDrive {}
$ ros2 service call /gantry_motor_z/get_max_accel gantry_msgs/srv/GetFloatDrive {}
To set a new value run
$ ros2 service call /gantry_motor_x/set_max_accel gantry_msgs/srv/SetFloatDrive '{motorside_value: 500}'
$ ros2 service call /gantry_motor_y/set_max_accel gantry_msgs/srv/SetFloatDrive '{motorside_value: 500}'
$ ros2 service call /gantry_motor_z/set_max_accel gantry_msgs/srv/SetFloatDrive '{motorside_value: 500}'
Note
We could also set the driveside_value
in SI units instead of value in motor dimensions.
11.3.4. Limit the Motor Velocity in Position Mode
This is equivalent to acceleration limit settings, but the service names are
~/get_max_speed
~/set_max_speed
11.3.5. Run a Single Motor
$ ros2 run gantry single_motor --ros-args \
--params-file <path_to_config_file> \
-r __node:=<motor_name> \
-r __ns:=<namespace>
Note
The path to the config file can be relative or absolute.
Attention
Keep in mind that namespaces have to start with a leading /
.
Setting the node name and the namespace is optional but recommended.
- Example
Assuming we are inside the
gantry
package directory, we can directly run$ ros2 run gantry single_motor --ros-args \ --params-file config/motor_x.yaml \ -r __node:=single_x \ -r __ns:=gantry