Ask Your Question
0

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

asked 2016-12-25 12:24:47 -0500

dinesh gravatar image

updated 2016-12-27 05:42:31 -0500

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 flag offensive close merge delete

Comments

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?

gvdhoorn gravatar image gvdhoorn  ( 2016-12-26 09:15:30 -0500 )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?

gvdhoorn gravatar image gvdhoorn  ( 2016-12-27 08:09:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-01-02 07:29:11 -0500

gvdhoorn gravatar image

updated 2017-01-02 07:30:02 -0500

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

edit flag offensive delete link more

Comments

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.

dinesh gravatar image dinesh  ( 2017-01-02 07:58:26 -0500 )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.

gvdhoorn gravatar image gvdhoorn  ( 2017-01-02 08:04:39 -0500 )edit

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

dinesh gravatar image dinesh  ( 2017-01-02 08:23:51 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-12-25 12:24:47 -0500

Seen: 1,394 times

Last updated: Jan 02 '17