Giter Club home page Giter Club logo

catkin_ws_pg_omni's Introduction

catkin_ws_pg_omni

Hi All,

This repo is for the final project of Embedded Microprocessor(嵌入式微處理機).

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 :

https://github.com/keon/policy-gradient

PART 1. Enviroment Setup:


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 :

http://wiki.ros.org/melodic/Installation/Ubuntu



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

PART 2.

You need to setup the enviroment for running ML.

1.Choose a proper version of anaconda and install it:

https://repo.anaconda.com/archive/



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.

PART 3. Clone the project


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.

PART 4.Training

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

  1. 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

image


PART 5.SLAM

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.

image



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.

PART 6.AMCL

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

image

You can now observe some particles around the robot.
Use your keyboard drive your robot go through the enviroment ,

image


Then you should observe that the particle converge to the real position of robot.

image

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.