Giter Site home page Giter Site logo

maze_solver's Introduction

ROS2 2D MazeSolver

This is a 2d maze solver. It solve simple 2D mazes by first manually drawing a map with slam_toolbox. Then it uses manually predefined waypoints to navigate the robot through the maze. The main objective is to learn to design and tune PID controllers. For future project, I will try make robot to autonomously draw map and navigate maze from p1 to p2 via pathfinding algorithm like A*, RRT, or Dijkstra.

๐Ÿ“ฆ Installation Instructions

  • ROS2 Humble
  • Rviz Version ?>??"?
  • Gazebo Simulation
  • slam_toolbox
  • Armadillo

Software pacakges

  • rosbot_xl_gazebo

๐Ÿ“ Build Packages

cd ~/ros2_ws
#due to interdependencies, build lib packages first, otherwise colcon complains
colcon build --packages-select pid_lib ctrl_lib; source install/setup.bash
#build everything
colcon build; source install/setup.bash

Start Simulation

ros2 launch rosbot_xl_gazebo simulation.launch.py

Start Sim

๐Ÿงญ Start Mapping

#run Teleop for key board control
cd ~/ros2_ws
source install/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard
#Start Mapping
cd ~/ros2_ws
colcon build; source install/setup.bash
ros2 launch my_slam_toolbox_pkg mapping.launch.py
#To Save Map
ros2 service call /slam_toolbox/save_map slam_toolbox/srv/SaveMap "{name: {data: 'your_map_name'}}"

Mapping

๐Ÿ“ Start AMCL Localization

cd ~/ros2_ws
colcon build; source install/setup.bash
# For Simulation
ros2 launch localization sim_localization.launch.py
# For Real Robot (the Construct Cyberlab)
ros2 launch localization real_localization.launch.py

A manual pose estimation is needed

Please use the Pose Estimation tool in Rviz and localize the robot somewhat aaccurately. This initialization heavily influence whether the robot can solve maze via way_points, this approach is rather naive and brittle.

Mapping

If using waypoint to solve maze

# Print the current odom
ros2 topic echo /rosbot_xl_base_controller/odom --field pose.pose.position
# Print the current AMCL pose (your amcl_pose topic may be different)
ros2 topic echo /amcl_pose --field pose.pose.position

๐Ÿƒโ€โ™‚๏ธ Solving Maze

Once the your waypoints are saved as yaml files within maze_solver\pid_maze_solver\waypoints, run the naive_maze_solver.launch.py file to solve maze via waypoints. Change way_point file name within launch file, if you are using your own waypoints.

# scene:=0 is for simulation; 1 is real_robot
# reverse_solve if false, follows the yaml file order; true reverse the order
ros2 launch pid_maze_solver naive_maze_solver.launch.py scene_num:=0 reverse_solve:=false

Simulation Forward Solve

The robot can solve maze right in the middle of the maze. As long as it is somewhere along the solution path, the robot will try to move to the closest waypoint and solve the maze from there. FYI: this doesn't work if there is an obstable inbetween the robot and waypoint. This is a naive maze solver, it does NOT have any obstacle avoidance.

Simulation Forward Solve

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.