Launching two devices using the same node

asked 2020-03-11 05:52:47 -0500

Antoniocl996 gravatar image

Hello, I'm making this post because im giving my first steps in developing a robot with ros and i'm facing the next problem, for my robot i want to use 2 motors and their controllers (epos2), one for each motor. The thing is that they both work with the same package and node but i dont know how to launch both of them using the same node or even if it's possible. Could anybody give me any advice about how to solve this?

edit retag flag offensive close merge delete

Comments

Hi @Antoniocl996,

To be more clear, your problem is that you want to use one unique node to control both or you want to control each one separated with two different nodes using the same code?

In the first case you could implement a node to control both motors but I think it would be better to implement a class node which you will be able to use to extrapolate to more than one robot and use the concept of ROS namespaces.

Weasfas gravatar image Weasfas  ( 2020-03-11 06:28:09 -0500 )edit

So, in order to make more clear the situation, i am using ROS control too, so when i wanted to make 1 motor work i was launching the motor controller node (the one of this package https://github.com/RIVeR-Lab/epos_har... ) it works with an URDF file i already made, and a yaml file, now i want to make the two motors work at the same time in order to implement both of them in the same robot, and i want to find the best option to do this. At first i tried defining groups in the launch file, but i realized i need different URDF files.

Antoniocl996 gravatar image Antoniocl996  ( 2020-03-11 06:51:50 -0500 )edit

ROS control is made to load all the needed controllers into a specific namespace with a set of known transmissions extracted from the URDF. Having said that, what you really want is to control each "transmission" separately, so just load all necessary transmissions into the same URDF and then set the yaml and launch file to launch those controllers.

The concept you are using as "motor" is indeed a transmission in the ROS control, thus they need to be controlled within the same robot namespace.

Furthermore, the repository you mentioned specifically is doing that, with the instantiation of a VelocityJointInterface which the controller manager will use to control each URDF joint separately, listening to different command topics.

Weasfas gravatar image Weasfas  ( 2020-03-11 07:13:03 -0500 )edit

I understand what you mean but i still don't know how should i make the launch file in order to run both motors. I already define one URDF file in which i define both transmissions and a YAML file in with i have defined both transmissions too; but when it comes to make both work at the same time, i dont know how to make the launch file.

Antoniocl996 gravatar image Antoniocl996  ( 2020-03-12 12:15:23 -0500 )edit

Maybe this can help you. A common ros control launcher file looks like this:

<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find you_package)/config/control_cfg.yaml" command="load"/>

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/namespace_1" args="controller1 controller2 ... joint_state_controller"/>

  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="/joint_states" to="/namespace_1/joint_states" />
  </node>

</launch>

Then you need gazebo and the spawner to spawn the robot in the simulation. From there you should be able to see in terminal how the controller manager load all controllers.

Weasfas gravatar image Weasfas  ( 2020-03-12 13:38:52 -0500 )edit