Rosanswers logo

Is their any tutorial or link to understand how i can send the joint trajectory commands to a robot at same time. I try to understand this jointtrajectory plugin but its too complicated for me right now and it looks like it is not meant for standalone ros indigo and gazebo.

simultaniously means at the same time how can i send the joint velocity commands, position commands to the robot in one cycle. All the tutorials i've seen i've seen how can i send these commands for individual joint or link. But i have no idea in c++, how can i send the velocity or position commands to the multiple joints at one single cycle. Till now i'm using below code to send velocity command to a single joint:

public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
  // Safety check
  if (_model->GetJointCount() == 0)
    std::cerr << "Invalid joint count, Velodyne plugin not loaded\n";

  // Store the model pointer for convenience.
  this->model = _model;

  // Get the first joint. We are making an assumption about the model
  // having one joint that is the rotational joint.
  this->joint = _model->GetJoints()[0];

  // Setup a P-controller, with a gain of 0.1.
  this->pid = common::PID(0.1, 0, 0);

  // Apply the P-controller to the joint.
      this->joint->GetScopedName(), this->pid);

  // Set the joint's target velocity. This target velocity is just
  // for demonstration purposes.
      this->joint->GetScopedName(), 10.0);

Here the joint with index 0 has been sent a velocity command, i want to send this command to other joint s also but at same time by using some JointTrajectory msgs or something. Here when i try to send this command to each joint by using for look it doesn't seems to work. In this tutorial they have shown how this can be done with python and a gazebo_ros_joint_trajectory_plugin, but i dont know python, and the plugin is little complicated for me to understand since it has functions inherited from so many parent classes.
For example my robot has two joints at position A and B, now i want to move them both at position C and D at certain velocity or move them at one direction at certain velocity but simultaniously not just one by using setposition function described in gazebo api, so i'm little confused right now how exactly i can do it.

Originally posted by dinesh on ROS Answers with karma: 932 on 2016-12-25

Post score: 0

Original comments

Comment by gvdhoorn on 2016-12-26:
Please explain clearly what you mean with "how I can send the joint trajectory commands to a robot at the same time". Which "robot", and what are "the joint trajectory commands"?

Maybe this is an xy-problem: what is it that you actually want to do?

Comment by gvdhoorn on 2016-12-27:
Are you asking how to do this from a Gazebo plugin, or are you trying to control a Gazebo robot from outside Gazebo from ROS?


1 Answer 1


Rosanswers logo

JointState msgs in ROS are typically only used for reporting the state of joints, not for commanding them / sending new setpoints (I know of some exceptions, but am not sure whether I would call that a 'recommended' practice).

For executing trajectories, you'll want to look into setting up a FollowJointTrajectory action server-client pair. See control_msgs for the action definition (specifically: FollowJointTrajectory). See joint_trajectory_action for an old / the PR2 implementation (you probably don't want to use that node, but it does help to understand JointTrajectory action server interaction).

For newer setups, I would perhaps look at ros_control, and then specifically at the joint_trajectory_controller. That exposes the required interfaces, and also allows you to work with Gazebo simulated robots and real hardware (almost) seamlessly (through gazebo_ros_control).

Originally posted by gvdhoorn with karma: 86574 on 2017-01-02

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by dinesh on 2017-01-02:
Ok, but i can use trajectory_msgs/jointtrajectory also for this task, where from ros node i can send the trajectory/each points to the gazebo model plugin and than control robot in gazebo. Which is better to use.

Comment by gvdhoorn on 2017-01-02:
It depends: if you want to receive status information (on the progress of your trajectory execution fi), then an Action interface better encapsulates that. If you're fine with fire-and-forget semantics, then using the topic could be enough.

Comment by dinesh on 2017-01-02:
Ok, got it, thanks for informing me about them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.