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

Revision history [back]

click to hide/show revision 1
initial version

I [..] send velocity commands [..] using the following command:

rostopic pub -1 /joint_states sensor_msgs/JointState '{header: auto, name: ['FLJ','FLJ'], position: [0,0], velocity: [1,0], effort: [0,0]}'

but the robot is not moving...Why?

The issue is with the way you've formatted the command.

Note how you start the message contents with a single quote (ie: ') and end it with one.

But in the middle, you also use single quotes for the names of the joints. That can't work, as the shell (ie: bash) will assume you'll use ' to demarcate the arguments to rostopic. So in the end, this is what the command line ends up being:

  • rostopic
  • pub
  • -1
  • /joint_states sensor_msgs/JointState
  • '{header: auto, name: ['
  • FLJ
  • ',' (ie: a comma in quotes)
  • FLJ
  • '], position: [0,0], velocity: [1,0], effort: [0,0]}'

that's probably not what you intended to do.

Summarising: you cannot embed single quotes in the YAML you want to pass to rostopic pub.

Two options:

  1. don't quote at all: if there are no spaces in the names, you could forgo quoting completely (YAML actually doesn't require strings to be quoted, it just helps avoid ambiguity)
  2. use double quotes (ie: "') for the joint names

I [..] send velocity commands [..] using the following command:

rostopic pub -1 /joint_states sensor_msgs/JointState '{header: auto, name: ['FLJ','FLJ'], position: [0,0], velocity: [1,0], effort: [0,0]}'

but the robot

There is not moving...Why?

The issue is a problem with the way you've formatted the command.

command. Note how you start the message contents with a single quote (ie: ') and end it with one.

But in the middle, you also use single quotes for the names of the joints. That can't work, as the shell (ie: bash) will assume you'll use ' to demarcate the arguments to rostopic. So in the end, this is what the command line ends up being:

  • rostopic
  • pub
  • -1
  • /joint_states /joint_states
  • sensor_msgs/JointState
  • '{header: auto, name: ['
  • FLJ
  • ',' (ie: a comma in quotes)
  • FLJ
  • '], position: [0,0], velocity: [1,0], effort: [0,0]}'

that's probably not what you intended to do.

Summarising: you cannot embed single quotes in the YAML you want to pass to rostopic pub.

Two options:

  1. don't quote at all: if there are no spaces in the names, you could forgo quoting completely (YAML actually doesn't require strings to be quoted, it just helps avoid ambiguity)
  2. use double quotes (ie: "') for the joint names

But, this most likely won't help with:

but the robot is not moving...Why?

JointState messages are meant to report on current state, not to command desired state. The /joint_states topic also typically only carries current state, not commands.

We don't know how you've setup your Gazebo simulation, so you could have configured it such that it does accept JointState messages as commands, but you would have to check that yourself.

I [..] send velocity commands [..] using the following command:

rostopic pub -1 /joint_states sensor_msgs/JointState '{header: auto, name: ['FLJ','FLJ'], position: [0,0], velocity: [1,0], effort: [0,0]}'

There is a problem with the way you've formatted the command. Note how you start the message contents with a single quote (ie: ') and end it with one.

But in the middle, you also use single quotes for the names of the joints. That can't work, as the shell (ie: bash) will assume you'll use ' to demarcate the arguments to rostopic. So in the end, this is what the command line ends up being:

  • rostopic
  • pub
  • -1
  • /joint_states
  • sensor_msgs/JointState
  • '{header: auto, name: ['
  • FLJ
  • ',' (ie: a comma in quotes)
  • FLJ
  • '], position: [0,0], velocity: [1,0], effort: [0,0]}'

that's probably not what you intended to do.

Summarising: you cannot embed single quotes in the YAML you want to pass to rostopic pub.

Two options:

  1. don't quote at all: if there are no spaces in the names, you could forgo quoting completely (YAML actually doesn't require strings to be quoted, it just helps avoid ambiguity)
  2. use double quotes (ie: "') for the joint names

But, this most likely won't help with:

but the robot is not moving...Why?

JointState messages are meant to report on current state, not to command desired state. The /joint_states topic also typically only carries current state, not commands.

We don't know how you've setup your Gazebo simulation, so you could have configured it such that it does accept JointState messages as commands, but you would have to check that yourself.

I [..] send velocity commands [..] using the following command:

rostopic pub -1 /joint_states sensor_msgs/JointState '{header: auto, name: ['FLJ','FLJ'], position: [0,0], velocity: [1,0], effort: [0,0]}'

There is a problem with the way you've formatted the command. Note how you start the message contents with a single quote (ie: ') and end it with one.

But in the middle, you also use single quotes for the names of the joints. That can't work, as the shell (ie: bash) will assume you'll use ' to demarcate the arguments to rostopic. So in the end, this is what the command line ends up being:

  • rostopic
  • pub
  • -1
  • /joint_states
  • sensor_msgs/JointState
  • '{header: auto, name: ['
  • FLJ
  • ',' (ie: a comma in quotes)
  • FLJ
  • '], position: [0,0], velocity: [1,0], effort: [0,0]}'

that's probably not what you intended to do.

Summarising: you cannot embed single quotes in the YAML you want to pass to rostopic pub.

Two options:

  1. don't quote at all: if there are no spaces in the names, you could forgo quoting completely (YAML actually doesn't require strings to be quoted, it just helps avoid ambiguity)
  2. use double quotes (ie: "') for the joint names

But, this most likely won't help with:

but the robot is not moving...Why?

JointState messages are meant to report on current state, not to command desired state. The /joint_states topic also typically only carries current state, not commands.

We don't know how you've setup your Gazebo simulation, so you could have configured it such that it does accept JointState messages as commands, but you would have to check that yourself.


Edit:

If I do not quote:

this won't work. You need to quote the yaml argument. When I wrote: "you could avoid quoting", I only meant the joint names.

But no movement...

as I wrote earlier: /joint_states is typically not used to command motion.

We cannot check that for you as we don't know how you've configured your simulation. You'll have to figure that out.