Skip to content

commandrobot

Marco Esposito edited this page May 22, 2023 · 10 revisions

Command the robot

ROSSmartServo subscribes to the following topics for the following command modes:

  • Position control in joint space on /iiwa/command/JointPosition
  • Position control in cartesian space on /iiwa/command/CartesianPose
  • Velocity control in joint space on /iiwa/command/JointVelocity
  • Joint/Velocity commands on /iiwa/command/JointPositionVelocity the robot will reach the given destination at the given velocity

Joint commands are sent using the JointPosition message defined in iiwa_msgs.
While Cartesian commands are sent using the classic PoseStamped message defined in the geometry_msgs package from ROS.

C++ Example

ROSSmartServo allows a transition between the command modes, just send the right message to the right topic.
From code, we can simply create a ROS Publisher that publishes the required message on the topic you want to use.
You can check the ROS Tutorials for that.

Additionally, we provide a helper class in iiwa_ros - surprisingly called iiwaRos in a moment of wild imagination - that handles all the functionalities you might need.
For example, you could directly use iiwaRos in your own ROS package to publish on any of the mentioned topics and command the robot:

iiwa_msgs::JointPosition my_joint_position = iiwa_ros:: jointQuantityFromDouble(0.0);  // This will create a JointQuantity will seven zeros
iiwa_ros::iiwaRos my_iiwa_ros_object;
[...]
my_iiwa_ros_object.init(); // this initializes all the subscribers, publishers and services, it has to be called after you are sure a ros::init() was called.
[...]
my_iiwa_ros_object.setJointPosition(my_joint_position) // The robot will go to "home" position. i.e. all joints at 0.

iiwaRos has a bunch of useful methods to use the ROS topics (to read and command the robot) and the ROS services (to change control mode, change velocity/acceleration and get the time left to destination). You can check out its methods.

Clone this wiki locally