ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Messages in ROS are compiled into compatible C++ structures. Here joint_state.name
is a std::vector<std::string>
and joint_state.position
is a std::vector<double>
. When adding elements to these structures, you need to use the standard methods of adding elements to a C++ vector, such as
joint_state.position.push_back(0.0);
or by first resizing the joint_state.position
vector:
joint_state.position.resize(7); // and then index as you do above
joint_state.position[0] = 0.0;
I happen to have a Github Gist that commands Baxter's arms with C++, quite similar to your code (sans the coredump :)
https://gist.github.com/rethink-imcmahon/237e6be4d29d812577be
One potential "gotcha" here is that you will need to command Baxter's arms at a rate greater than 5Hz. Otherwise, they will revert back into position mode and hold their place. This is a safety feature.
And for a few helpful links -