hello-robot / stretch_ros2

ROS 2 packages for the Stretch mobile manipulators from Hello Robot Inc.
https://docs.hello-robot.com/0.2/stretch-tutorials/ros2/
51 stars 19 forks source link

Make prominent note about using robot params at the ROS2 level + example code #109

Open hello-binit opened 3 months ago

hello-binit commented 3 months ago

Did you know you don't need to hard code robot joint limits and effort values or ascertain them experimentally? They are all available from the stretch_body.robot_params class. You may import this class in your ROS2 launch file and/or nodes without interfering with the stretch_driver node (You cannot import the stretch_body.robot directly because the hardware cannot communicate with two robot processes simultaneously).

Let's note this in the docs. Let's create an example to show this.

import stretch_body.robot_params

user_params, robot_params = stretch_body.robot_params.RobotParams().get_params()
# robot_params is a massive dictionary of "robot parameters", assembled from a mix of Python dictionaries and YAML files, that customize the behavior of the robot and its software.
# user_params are robot parameters customized by the user. robot_params actually includes the customizations in user_params, so you can ignore that variable.

print(robot_params['robot']['model_name']) # get the Stretch model
print(robot_params['robot']['serial_no']) # get the Stretch serial number
print(robot_params['robot']['tool']) # get the tool attached to Stretch

print(robot_params['lift']['range_m']) # get the lift range in meters
print(robot_params['lift']['motion']['default']) # get the lift default motion profile
print(robot_params['lift']['motion']['default']) # get the lift default motion profile
print(robot_params['arm']['range_m']) # get the lift range in meters

print(robot_params['wrist_yaw']) # get wrist_yaw parameters

# I recommend opening iPython to explore the dictionary and see what parameters it has.

A few of these robot parameters are documented here: https://github.com/hello-robot/stretch_body/blob/master/docs/robot_parameters.md

However, many are not. If you find a parameter you'd like to see documented, please contact us.