Hey,
My guess is, that you currently launch things with roslaunch <my_robot>_config demo.launch
?
If you inspect this launch-file, you'll notice the following:
<!-- We do not have a robot connected, so publish fake joint states -->
So you are right regarding the fact that you'll need to write your own node, which publishes joint states to the joint_states
-topic. What I didn't quite understand what you need your second node for? You either write your own launch file or modify the demo.launch
, to stop it from launching the generic joint-state-publisher and launch your own. Rviz/MoveIt should take care of the rest.
If you have any further questions, just ask.
Hope that helps,
Rabe
Edit:
If I understand you correctly, you have your understanding of the pipeline mixed up. The pipeline works something like this:
Publishing of Current Joint-States => MoveIt and Rviz => You create a new target state (either via Rviz or in your code with the MoveIt-Interface) => MoveIt computes a path for you. This path will contain certain discrete points with a position, velocity and acceleration for each joint of your robot. If you only have 1 joint, then only for this one ;) => This JointTrajectory gets published to the FollowJointTrajectory
-ActionServer. This is a server you need to write yourself, just like the JointStatePublisher. This server takes the trajectory and sends them to your (simulated) robot. Also, it answers to MoveIt when the trajectory was completed, otherwise MoveIt will send commands to cancel the movement, since it took too long. => Your robot starts moving => Your JointStatePublisher shows the new jointstates during the movement.
For me personnaly it was quite a hassle to work into the whole thing of ActionServers and stuff, but I was new to ROS and robotics in general. Follow the tutorials of how to implement your own robot, and you will get quite far.
Edit No 2:
Hey,
First of all, you should take everything I say with a grain of salt, I am by no means a ROS expert and my description of the pipeline was very simplyfied.
Regarding controlling your robot with a Joystick: I somehow assumed you used the whole MoveIt-Package, but now I am not certain if that is correct? For me, it's just the only way I know URDFs and that stuff.
In case you are using MoveIt:
You could write a second Node, which depending on the input from the joystick would create new motion-requests, MoveIt would plan the path and you could execute this planned path. You should check out the documentation for the Python-Interface for MoveIt, there are examples how to request movements to new positions.
Buuut I somehow get the feeling that's not exactly what you want to do?
In case you are NOT using MoveIt: Sure, you could write a node, which publishes JointStates depending on joystick-input or something like that. It would make the robot move in Rviz. But as far as I understand it, this wouldn't have ...
(more)