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.pyfor getting the yaw angle (angle system)nav_obstacle.pykeep moving along the x-axis , stop until you feel an obstacle nearby.nav_square.pyA basic demo of the using odometry data to move the robot, along a square trajectory.
Run the get_angular_odom.py file
Open the terminal and launch the robot drive node:
roslaunch handsfree_hw handsfree_hw.launchOpen a second terminal and launch the keyboard control node:
roslaunch handsfree_teleop keyboard_teleop.launchOpen a third terminal and run the python file:
rosrun handsfree_tutorials get_angular_odom.pyAt the beginning, the terminal displays the message
0.0. When we select the second terminal with the mouse and use thej or kkeys to control the rotation of the robot, we will see that the data displayed on the terminal has changed:

Run the nav_obstacle.py file
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.launchOpen the second terminal and launch the laser node (please ignore this step if you have already opened it before):
roslaunch handsfree_lidar lidar.launchOpen 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.pyThe robot will keep moving until it stops at about half a meter from the obstacle:

Run the nav_square.py file
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.launchOpen 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.pyNormally, the terminal displays the following information:
