This is the whole robot program which including navigation, localization and main function.
-
git clone https://github.com/pithreeone/Navigation_Project.git
or clone by sshgit clone git@github.com:pithreeone/Navigation_Project.git -
If you are developer, you can also clone the Simulation package use in this repo.
https://github.com/pithreeone/Simulation.gitor clone by sshgit@github.com:pithreeone/Simulation.git
cd ~/."your_ws"/src/Navigation_Project/localization/YDLidar-SDK/buildcmake ..makesudo make install
sudo apt-get install ros-noetic-gazebo-rossudo apt-get install ros-noetic-ros-controllerssudo apt install ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-controlsudo apt-get install ros-noetic-filters
-
check tf between
base_frame&laser_frame -
Set the USB-port name in
localization_run/launch/localization.launch. Check the following argument:- lidar_port
- odometry_port
- mechanism_port
-
Add environment variable in
~/.bashrc. When save the map, it will save at this path.export MAP_PATH=/home/pithreeone/amr_robot/src/navigation/navigation/navigation-stack/map_server/map_configexport MUSIC_PATH=/home/pithreeone/amr_robot/src/navigation/localization/chores/elevator-audio -
Authorization of I2C ports:
ls -l /dev | grep i2c: Can see all available I2C ports.
sudo chmod 777 /dev/i2c-*: * is the number of the port you want to authorize.
sudo usermod -aG i2c ubuntu: The most important step to keep the configuration effective even after rebooting.
- Add environment variable in
~/.bashrcexport GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/amr_robot/src/Simulation/gazebo_simulation/models
- The main program of robot is achieved by finite state machine. Machine Graph can be seen above. To change state, we need events which can be created by publishing topic:
/action - The message is user-defined in
robot_interfacepackage. - Initial state is
STOP
-
Publish an topic which mission is
start_mapping(state:STOP$\rightarrow$START_MAPPING$ \rightarrow$AUTO_MAPPING) Let the topic name beaction, or you can remap. -
Now robot will move automatically.
-
You can also use telop_twist_keyboard to publish velocity topic. Topic name is
control_cmd_vel. We can use the following command to change the topic name that teleop_twist_keyboard publish.rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=control_cmd_vel -
Once finish mapping, publich an topic which mission is
check_map. Then it will save map. The map will be saved in/home/user-name/.rosSet the following message for your topic :action.map_ok(bool) = trueaction.set_map_name(string) = floor_XX
-
If the computer on robot do not have enough computility, you can launch the gmapping on your own PC.
roslaunch localization_run gmapping.launch
Localization mode is also mission mode. Ex: robot moves crossing floor.
The following list some parameters that may need to tune.
- Set the minimum and maximum range that you don't want.
- In
laser_filters/launch/rane_filter.yaml
- In
localization/elevator_classifier/config/classifier_tradition.yaml
- In
navigtion/robot_interface/config/interface.yaml - You can set each goal point in the YAML file.
The package provides three custom message types. All of their numerical values are provided in SI units.
-
Interfacestring missionmissions:[start_mapping,finish_control_mapping,check_map,choose_map,move_goal,move_goal_key,record_position]geometry_msgs/PoseStamped goalif mission ismove_goal, set goalstring choose_map_nameif mission ischoose_map, choose a mapstring position_keyif mission isrecord_position, set name of positionbool map_okcheck whether map is acceptablestring set_map_nameif mission ischeck_map, set map name
-
Robot_Statestring robot_staterobot current state. state : [REACH,STUCK]
For start up real robot, you can launch the file below.
roslaunch navigation_run navigation.launch 2>/dev/null
publish_mission node can help you publish the Interface topic. It's hard to publish it using rostopic pub ...
rosrun navigation_run publish_mission
*Be careful to publish the command velocity to odometry with topic name control_cmd_vel instead of cmd_vel
rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=control_cmd_vel
roslaunch localization_run odometry.launch
You can add specific port name after the above command.
roslaunch localization_run odometry.launch odometry_port:=/dev/USB1
[ WARN] [1699963788.943319783]: Robot_Interface: Cannot subscribe current floor ...
Solution: Usually means the bmp280 pressure sensor doesn't open correctly. Check the code Line 10 in:/localization/sensor_firmware/src/bmp280_publisher.py
bus = smbus2.SMBus(1)You can change the SMBus to 0,1,2,...
