ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to move a ur3 robot arm by using actions?

asked 2019-11-04 07:01:25 -0500

ROSDeveloper1996 gravatar image

updated 2019-11-05 01:25:31 -0500

gvdhoorn gravatar image

Dear community,

  1. I'm absolutely new to ROS, so please excuse my technically perhaps not always quite correct expressions.
  2. I'm running ROS Kinetic on Ubuntu 16.04 LTS and cloned the "universal robot" package from the following GitHub repository: (
  3. After "building" my Catkin workspace by typing catkin_make everything worked fine so far and I could successfully launch a simulation of an ur3 robot in Gazebo by typing roslaunch ur_gazebo ur3.launch into a new terminal.
  4. What i wanted to do now, was to control the total of six joints of the ur3 without using MoveIt. So i did some research and found the following Link: Moving the arm using the Joint Trajectory Action So basically I wanted to try to control the ur3 in the Gazebo simulation via an action client. Since the description in the link above did not exactly fit to my robot, I tried to adapt the simple_trajectory.cpp file written there to the ur3 robot.

My "adapted" code file (without the included headers) now looks like shown below.

(The libraries I included by writing #include are the following: <ros/ros.h>; <control_msgs/FollowJointTrajectoryAction.h> and <actionlib/client/simple_action_client.h)

typedef actionlib::SimpleActionClient <control_msgs::FollowJointTrajectoryAction> TrajClient;

class Ur3Arm
        // Action client for the follow joint trajectory action used to trigger the arm movement action
        TrajClient* traj_client_;

        // Initialize the action client and wait for action server to come up.
            // Tell the action client that we want to spin a thread by default:
            traj_client_ = new TrajClient("arm_controller/follow_joint_trajectory_action", true);

            // Wait for the action server to come up
                ROS_INFO("Wait for the follow_joint_trajectory_action server");

        // Clean up the action client
        // -> Destructor of class Ur3Arm

            delete traj_client_;

        // Send the command to start a given trajectory

        void startTrajectory(control_msgs::FollowJointTrajectoryGoal goal)
            // When to start the trajectory: 1s from now
            goal.trajectory.header.stamp = ros::Time::now() + ros::Duration(1.0);

        // Generates a simple trajectory with two waypoints, used as an example
        /* Note that this trajectory contains two waypoints, joined together as a single trajectory.
           Alternatively, each of these waypoints could be in its own trajectory - a trajectory can have one
           or more waypoints depending on the desired application.

        control_msgs::FollowJointTrajectoryGoal armExtensionTrajectory()
            // The goal variable:
            control_msgs::FollowJointTrajectoryGoal goal;

            // First, the joint names, which apply to all waypoints

            // In this simple case there asre only two waypoints in this goal trajectory

            // First trajectory waypoint

                        int ind = 0; // Represents the number of the actual waypoint

                        // Positions:

                        goal.trajectory.points[ind].positions[0] = 0.0;
                        goal.trajectory.points[ind].positions[1] = 0.0;
                        goal.trajectory.points[ind].positions[2] = 0.0;
                        goal.trajectory.points[ind].positions[3] = 0.0;
                        goal.trajectory.points ...
edit retag flag offensive close merge delete


Please do not post answers, unless you are answering your own questions.

For interacting with other posters, please use comments, or edit your original question to add a section to it. Use the edit button/link for that.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-05 01:26:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-04 20:22:25 -0500

jschornak gravatar image

Make sure that the action name you use when you create the client matches the name of the action provided by the server. Since the action topics that were listed when you used rostopic list are all under /arm_controller/follow_joint_trajectory, there are two things wrong with this line:

traj_client_ = new TrajClient("arm_controller/follow_joint_trajectory_action", true);
  1. Instead of follow_joint_trajectory_action, you should use follow_joint_trajectory to match the name advertised by the server.
  2. If you begin a ROS topic name without a slash (/) then the name will be evaluated as a relative name under the node's namespace. Because the node with the client is named robot_driver, as currently written the action client is looking for an action named /robot_driver/arm_controller/follow_joint_trajectory_action, which doesn't exist. There's a wiki page with an overview of ROS naming rules here.

After fixing these issues the line where you create the action client should look like this:

    traj_client_ = new TrajClient("/arm_controller/follow_joint_trajectory", true);
edit flag offensive delete link more

Question Tools



Asked: 2019-11-04 07:01:25 -0500

Seen: 927 times

Last updated: Nov 05 '19