ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# How do i send joint commands to robot simultaniously in gazebo from ros node

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";
return;
}

// 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->model->GetJointController()->SetVelocityPID(
this->joint->GetScopedName(), this->pid);

// Set the joint's target velocity. This target velocity is just
// for demonstration purposes.
this->model->GetJointController()->SetVelocityTarget(
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.

edit retag close merge delete

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?

( 2016-12-26 09:15:30 -0600 )edit

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?

( 2016-12-27 08:09:36 -0600 )edit

Sort by » oldest newest most voted

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).

more

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.

( 2017-01-02 07:58:26 -0600 )edit

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.

( 2017-01-02 08:04:39 -0600 )edit

Ok, got it, thanks for informing me about them.

( 2017-01-02 08:23:51 -0600 )edit