Demo Scripts
This section describes the demo scripts that come with the Trossen Arm driver.
What You Need
To get started, please make sure you have gone through the Configuration.
Scripting Philosophy
A high level overview of scripting with the Trossen Arm driver is given here. The driver is designed to be flexible and easy to use for a wide range of applications.
// Include the header files
#include "libtrossen_arm/trossen_arm.hpp"
int main(int argc, char** argv)
{
// Create a driver object
trossen_arm::TrossenArmDriver driver;
// Configure the driver
driver.configure(...);
// Beginning of an action
// Get the modes of all joints if needed
// Here xxxs are the modes of all the joints where xxx can be
// - trossen_arm::Mode::position
// - trossen_arm::Mode::velocity
// - trossen_arm::Mode::external_effort
// - trossen_arm::Mode::effort
auto xxxs = driver.get_modes();
// Set the mode[s] of the joint[s]
// Here yyy can be arm, gripper, all, or joint where
// - all includes all the joints
// - arm includes all joints but the gripper joint
// - gripper includes just the gripper joint
// - joint includes a specific zero-indexed joint
driver.set_yyy_mode[s](xxx);
// Start moving the joint[s]
// Some logic
// Command the joint[s]
//
// A joint command includes
// - goal[s]
// - time to reach the goal[s]
// - whether to block until reaching goal[s]
// - optionally the goal derivative[s]
// where yyy and zzz must be compatible with the mode set above
//
// Alternatively, if the arm joints all have one of the following modes
// - trossen_arm::Mode::position
// pose of the tool frame measured in the base frame
// - trossen_arm::Mode::velocity
// linear and angular velocities of the tool frame measured in the base frame
// - trossen_arm::Mode::external_effort
// linear and angular efforts to be applied at the tool frame
// measured in the base frame while compensating for gravity and friction
// We can also command the arm joints to move in Cartesian space
// The Cartesian command includes an additional argument: interpolation space
// - trossen_arm::InterpolationSpace::joint
// Interpolate from start to goal state in joint space
// - trossen_arm::InterpolationSpace::cartesian
// Interpolate from start to goal state in Cartesian space
driver.set_yyy_zzz[s](...); | driver.set_cartesian_zzzs(...);
// Get the robot outputs if needed
// The robot output includes
// - joint space states
// - positions
// - velocities
// - external_efforts
// - efforts
// - compensation_efforts
// - rotor_temperatures
// - driver_temperatures
// - Cartesian space states
// - positions
// - velocities
// - external_efforts
trossen_arm::RobotOutput robot_output = driver.get_robot_output();
// Some more logic
// Stop moving the joint[s]
// End of an action
// More actions if needed
}
# Import the driver
import trossen_arm
if __name__ == "__main__":
# Create a driver object
driver = trossen_arm.TrossenArmDriver()
# Configure the driver
driver.configure(...)
# Beginning of an action
# Get the modes of all joints if needed
# Here xxxs are the modes of all the joints where xxx can be
# - trossen_arm.Mode.position
# - trossen_arm.Mode.velocity
# - trossen_arm.Mode.external_effort
# - trossen_arm.Mode.effort
xxxs = driver.get_modes()
# Set the mode[s] of the joint[s]
# Here yyy can be arm, gripper, all, or joint where
# - all includes all the joints
# - arm includes all joints but the gripper joint
# - gripper includes just the gripper joint
# - joint includes a specific zero-indexed joint
driver.set_yyy_mode[s](xxx)
# Start moving the joint[s]
# Some logic
# Command the joint[s]
#
# A joint command includes
# - goal[s]
# - time to reach the goal[s]
# - whether to block until reaching goal[s]
# - optionally the goal derivative[s]
# where yyy and zzz must be compatible with the mode set above
#
# Alternatively, if the arm joints all have one of the following modes
# - trossen_arm.Mode.position
# pose of the tool frame measured in the base frame
# - trossen_arm.Mode.velocity
# linear and angular velocities of the tool frame measured in the base frame
# - trossen_arm.Mode.external_effort
# linear and angular efforts to be applied at the tool frame
# measured in the base frame while compensating for gravity and friction
# We can also command the arm joints to move in Cartesian space
# The Cartesian command includes an additional argument: interpolation space
# - trossen_arm.InterpolationSpace.joint
# Interpolate from start to goal state in joint space
# - trossen_arm.InterpolationSpace.cartesian
# Interpolate from start to goal state in Cartesian space
driver.set_yyy_zzz[s](...) | driver.set_cartesian_zzzs(...)
# Get the robot outputs if needed
# The robot output includes
# - joint space states
# - positions
# - velocities
# - external_efforts
# - efforts
# - compensation_efforts
# - rotor_temperatures
# - driver_temperatures
# - Cartesian space states
# - positions
# - velocities
# - external_efforts
robot_output: trossen_arm.RobotOutput = driver.get_robot_output()
# Some more logic
# Stop moving the joint[s]
# End of an action
# More actions if needed
Demos
After understanding the scripting philosophy, specific demos are provided to ground the concepts. Demos of three levels of complexity are provided with the driver.
Basics
The basic demos show the must-know functionalities to get the arm up and running.
cartesian_position
This script demonstrates how to perform position control in Cartesian space.
configure_cleanup
This script demonstrates how to configure and cleanup the driver. This is useful for switching between different arms without creating a new driver object. This script also demonstrates how to access the driver’s states and configurations.
gravity_compensation
This script demonstrates how to do gravity compensation. This is useful for manually moving the arm to teach a trajectory or record specific positions.
gripper_torque
This script demonstrates how to open and close the gripper.
set_mode
This script demonstrates how to set the mode of the robot.
simple_move
This script demonstrates how to move a robot to different positions.
mixed_interpolation_space
This script tests transitions of the interpolation space.
Intermediate
The intermediate demos give examples on commonly-used configurations and application-specific control loops.
cartesian_external_effort
This script demonstrates how to use external effort control in Cartesian space to do impedance control.
cartesian_velocity
This script demonstrates how to use velocity control in Cartesian space to do admittance control.
configuration_in_yaml
This script demonstrates how to exchange persistent configurations via a YAML file.
error_recovery
This script demonstrates how to recover from an error in the driver.
move
This script demonstrates how to write a control loop to move the robot to different positions and record the states.
move_two
This script demonstrates how to move two robots to different positions using interpolation.
set_factory_reset_flag
This script demonstrates how to reset all configuration options to their default values.
set_ip_method
This script demonstrates how to set the IP method to DHCP or MANUAL.
set_manual_ip
This script demonstrates how to set the manual IP address.
teleoperation
This script demonstrates how to teleoperate the robots with force feedback.
Advanced
The advanced demos show configurations that should be used with full understanding the implications.
set_joint_characteristics
This script demonstrates how to set the joint characteristics in the EEPROM, using the effort corrections as an example.
What’s Next
Hopefully, the provided demos have put you at a good starting point for developing your own applications. For more details on the driver API, please refer to the Trossen Arm Driver API.