Hi All,
Use policy gradient to train a omni robot in order to reach the destination without crashing to obstacle.
The model of Omni robot is base on these two projects :
https://github.com/GuiRitter/OpenBase
https://github.com/YugAjmera/omni3ros_pkg
Some components comes from turtlebot3 ,including the lidar module ,some world enviroment and slam pakage. You can find some resources of the turtlebot at the below link:
https://emanual.robotis.com/docs/en/platform/turtlebot3/overview/
And the model of Policy Gradient is base on :
Operation system : Ubuntu 18.04
ROS version : Melodic
1.First ,you need to install Ubuntu 18.04 and ROS melodic on your machine.
You can get the information about ros installation from :
2.After you setup your ros ,please install these following pakage if you haven't install yet :
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt-get install ros-melodic-ros-control
sudo apt-get install ros-melodic-effort-controllers
sudo apt-get install ros-melodic-joint-state-controller
sudo apt-get install ros-melodic-position-controllers
sudo apt-get install ros-melodic-ros-control
sudo apt-get install ros-melodic-velocity-controllers
sudo apt-get install ros-melodic-ros-controllers
sudo apt-get install ros-melodic-gazebo-ros
sudo apt-get install ros-melodic-gazebo-ros-control
You need to setup the enviroment for running ML.
1.Choose a proper version of anaconda and install it:
2.Create a conda enviroment by :
conda create -n ros-env python=2.7
4. Activate your conda enviroment:
conda activate ros-env
4. Install ROS related pakages and tensorflow ,keras inside your conda enviroment which you already created:
pip install rosinstall msgpack empy defusedxml netifaces
pip install tensorflow==1.14
pip install keras==2.1.5
pip install pydot
5. Close all terminal.
1. Move to your working space or any directory you like.
2. clone the repo:
git clone https://github.com/windlunar/catkin_ws_pg_omni
source /opt/ros/melodic/setup.bash
cd catkin_ws_pg_omni/
catkin_make
Close all the terminal.
1.open a new terminal ,and type the commands :
conda activate ros-env
source /opt/ros/melodic/setup.bash
2. Move to the catkin_ws_pg_omni folder , and type the following command.
source ./devel/setup.bash
roslaunch omni_3wd pg_env.launch
-
Open another terminal ,and type the same command to activate conda enviroment:
conda activate ros-env source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder , and type the following command.
source ./devel/setup.bash
Then move to :
catkin_ws_pg_omni/src/omni_pg/nodes
And type the following command to start tranning.
python pg_main.py
Install gmapping:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt-get install ros-melodic-slam-gmapping
Close all the terminal.
1.Open a new terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch omni_3wd slam_env.launch
You can see the gazebo is open.
2.Open the second terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch turtlebot3_slam turtlebot3_slam.launch
Now rviz is open.
3.Open another terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder
source ./devel/setup.bash
move to "/catkin_ws_pg_omni/src/cmd_vel_keyboard/nodes" folder
And run the command to control robot by keyboard:
python omni_keyboard.py
or
python cmd_vel_keyboard.py
Now you can use your keyboard to control the omniweel ,and the rviz will show the map which is created by gmapping.
Cause I haven't map all the frame yet ,so you may see some componets of omnibot are missing in rviz.
Install map_saver to save the map:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt-get install ros-melodic-map-server
Save your map:
rosrun map_server map_saver -f ./map
Then you should see your map "map.pgm" and "map.yaml" has been saved.
First, install amcl
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt-get install ros-melodic-amcl
Then, put your map(both "map.pgm" and "map.yaml") which was created by SLAM to the folder :
/catkin_ws_pg_omni/src/turtlebot3_navigation/maps/
Close all the terminal.
1.Open a new terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch omni_3wd slam_env.launch
You can see the gazebo is open.
2.Open another terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch turtlebot3_navigation turtlebot3_amcl.launch
Now rviz is open again.
Click the "2D Pose Estimate" at the top of the rviz window ,And set the initial position of robot
You can now observe some particles around the robot.
Use your keyboard drive your robot go through the enviroment ,
Then you should observe that the particle converge to the real position of robot.
Navigation.
Install the navigation pakage:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt-get install ros-melodic-navigation
Close all the terminal.
1.Open a new terminal:
source /opt/ros/melodic/setup.bash
Move to the catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch omni_3wd slam_env.launch
You can see the gazebo is open.
2.Open another terminal:
source /opt/ros/melodic/setup.bash
Move to catkin_ws_pg_omni folder and run:
source ./devel/setup.bash
roslaunch turtlebot3_navigation turtlebot3_navigation.launch
Now rviz is open.
3.Converge the particle as you did at PART 6.AMCL
4.Click the "2D Nav Goal" at the top of rviz toolbar.
5.Choose a place as the destination of robot ,and then click the left button.
6.As you can see ,the robot auto navigate to the destination.