How does Dynamixel send and receive commands for the movements?

Once you have launched the controller_manager.launch file, you will see a list of topics. Remember to use the following command line to see these topics:

    $ rostopic list
  

These topics will show the state of the motors configured, as follows:

    /diagnostics
    /motor_states/pan_tilt_port
    /rosout
    /rosout_agg
  

If you see /motor_states/pan_tilt_port with the rostopic echo command, you will see the state of all the motors, which, in our case, is only the motor with the ID 6; however, we cannot move the motors with these topics, so we need to run the next launch file to do it.

This launch file will create the necessary topics to move the motors, as follows:

    $ roslaunch dynamixel_tutorials controller_spawner.launch
  

The topic list will have two new topics added to the list. One of the new topics will be used to move the servomotor, as follows:

    /diagnostics
    /motor_states/pan_tilt_port
    /rosout
    /rosout_agg
    /tilt_controller/command
    /tilt_controller/state
  

To move the motor, we are going to use the /tilt_controller/command that will publish a topic with the rostopic pub command. First, you need to see the fields of the topic and the type. To do this, use the following command lines:

    $ rostopic type /tilt_controller/command
    
    std_msgs/Float64
  

As you can see, it is a Float64 variable. This variable is used to move the motor to a position measured in radians. So, to publish a topic, use the following commands:

    $ rostopic pub /tilt_controller/command std_msgs/Float64 -- 0.5
  

Once the command is executed, you will see the motor moving, and it will stop at 0.5 radians or 28.6478898 degrees.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.14.93