Advanced Programming

This section describes how to get information about a robot, or control its actions, through the python program.

Understanding Program

There are three files here, which are:

  • get_angular_odom.py for getting the yaw angle (angle system)
  • nav_obstacle.py keep moving along the x-axis , stop until you feel an obstacle nearby.
  • nav_square.py A basic demo of the using odometry data to move the robot, along a square trajectory.

Run the get_angular_odom.py file

  1. Open the terminal and launch the robot drive node:

     roslaunch handsfree_hw handsfree_hw.launch
    
  2. Open a second terminal and launch the keyboard control node:

     roslaunch handsfree_teleop keyboard_teleop.launch
    
  3. Open a third terminal and run the python file:

     rosrun handsfree_tutorials get_angular_odom.py
    

    At the beginning, the terminal displays the message 0.0. When we select the second terminal with the mouse and use the j or k keys to control the rotation of the robot, we will see that the data displayed on the terminal has changed:
    get-angular-odom

Run the nav_obstacle.py file

  1. Open the terminal and launch the robot drive node (please ignore this step if you have already opened it before):

     roslaunch handsfree_hw handsfree_hw.launch
    
  2. Open the second terminal and launch the laser node (please ignore this step if you have already opened it before):

     roslaunch handsfree_lidar lidar.launch
    
  3. Open the third terminal and run the python file (it is recommended that the front of the robot be more than one meter away from the obstacle, otherwise the effect is not obvious.)

     rosrun handsfree_tutorials nav_obstacle.py
    

    The robot will keep moving until it stops at about half a meter from the obstacle:
    nav-obstacle

Run the nav_square.py file

  1. Open the terminal and launch the robot drive node (please ignore this step if you have already opened it before):

     roslaunch handsfree_hw handsfree_hw.launch
    
  2. Open a second terminal and run the python file (the robot needs a 2.5 square meter space to move along the square trajectory):

     rosrun handsfree_tutorials nav_square.py
    

    Normally, the terminal displays the following information:
    nav-square

results matching ""

    No results matching ""