Hardware Interface¶
Robot Controller¶
Control the robot’s motion and get data. This interface relies on the Universal_Robots_ROS_Driver package to control UR robots using the builtin ROS controllers.
-
class
hardware_interface.
RobotController
(robot_name='', debug=False)¶ Hardware interface that can control a robot via ROS controllers
- Parameters
robot_name (str) – Name of the robot. This name must match the prefix of the robot’s controller topics
debug (bool) – Turn on debugging print statements
-
balance_ft
()¶ Zero the internal F/T offsets
-
balance_pose
()¶ Zero the internal pose offsets
-
get_offsets
()¶ Get the internal F/T and Pose offsets
- Returns
offsets – Offset dict with “force”, “torque”, “position”, and “orientation” keys
- Return type
dict
-
get_twist
(linear, angular)¶ Build a twist message from vectors
- Parameters
linear (list) – The linear twist components [x,y,z]
angular (list) – The angular twist components [x,y,z]
- Returns
twist – The resulting twist message
- Return type
geometry_msgs/Twist
-
load_controller
(controller)¶ Load a ROS controller
- Parameters
controller (str) – Name of the controller to load
- Returns
response – Service response from the controller manager
- Return type
str
-
play_program
()¶ Start the program on the teach pendant. This ony works if you are in remote control mode
- Returns
result – The result of the service call
- Return type
srv
-
set_controller
(controller)¶ Set which ROS controller is started, and stop all others
- Parameters
controller (str) – Name of the controller to start
- Returns
response – Service response from the controller manager
- Return type
str
-
set_jog
(linear, angular)¶ Set the Jog speed
- Parameters
linear (list) – The linear twist components [x,y,z]
angular (list) – The angular twist components [x,y,z]
-
set_offsets
(offsets)¶ Set the internal F/T and Pose offsets
- Parameters
offsets (dict) – Offset dict with “force”, “torque”, “position”, and “orientation” keys
-
set_pose
(pose, time=5.0)¶ Set the pose of the robot
- Parameters
pose (dict) – The pose dictionary with position and orientation components
time (float) – Time to take (in seconds)
-
set_speed_slider
(fraction)¶ Set the speed slider fraction
- Parameters
fraction (float) – Slider fraction to set (0.02 to 1.00)
- Returns
result – The result of the service call
- Return type
srv
-
shutdown
()¶ Shutdown gracefully
-
stop_program
()¶ Stop the program on the teach pendant. This ony works if you are in remote control mode
- Returns
result – The result of the service call
- Return type
srv
-
switch_controller
(start_controllers, stop_controllers, strictness=1, start_asap=False, timeout=0)¶ Switch ROS controllers
- Parameters
start_controllers (list) – Names of the controllers to start
stop_controllers (list) – Names of the controllers to stop
strictness (int) – Strictness of controller switching
start_asap (bool) – Decide whether controllers should be started immediately
timeout (int) – Timeout (in seconds)
- Returns
response – Service response from the controller manager
- Return type
str
-
unload_controller
(controller)¶ Unload a ROS controller
- Parameters
controller (str) – Name of the controller to unload
- Returns
response – Service response from the controller manager
- Return type
str
-
update_tool_pose
(data)¶ Update the internal value of the tool pose. Saves a copy of the cartesian position (in m) and euler angle orientation (in rad). The pose is then balanced via offsets. The balanced wrench is published in the
/tf_balanced
topic.- Parameters
data (tf2_msgs/TFMessage) – Wrench message
-
update_wrench
(data)¶ Update the internal value of the wrench. The wrench is converted from the tool frame to the world frame, then balanced via offsets. The balanced wrench is published in the
/wrench_balanced
topic.- Parameters
data (geometry_msgs/Wrench) – Wrench message
Data Logger¶
Log data to syncronized files. Given a filename and a map of topics (see armstron/config/data_to_save.yaml), log data from ROS topics to CSV files.
-
class
hardware_interface.
DataLogger
(filename, config, overwrite=False)¶ Log data to csv files.
- Parameters
filename (str) – Filename to save to. Note: files will be saved with suffixes corresponding to the name of the data being saved
config (dict) – Configuration, including the topic map
- Raises
ValueError – If the topic_map is invalid
-
pause
()¶ Pause logging.
-
resume
()¶ Resume logging.
-
shutdown
()¶ Shutdown gracefully.
-
start
()¶ Start logging data.
-
stop
()¶ Stop logging data.