This repository contains a 3D A* path planning algorithm that is simulated using ROS and CoppeliaSim.
Before you can run this code, make sure you have the following installed on your Ubuntu system:
- ROS (Robot Operating System)
- CoppeliaSim - Download the appropriate version for your system.
- Python libraries:
numpy
,math
Follow these steps to set up and run the code:
-
Clone this repository and navigate to your workspace:
mkdir -p ~/pathplanning/src cd ~/pathplanning catkin_init_workspace cd pathplanning/src catkin_create_pkg a_star_pathplanning std_msgs rospy cd pathplanning catkin build a_star_pathplanning source devel/setup.bash cd pathplanning/src/a_star_pathplanning mkdir scripts cd scripts
-
Paste the
a_star.py
file in thescripts
directory and make it executable:sudo chmod +x a_star.py
-
Open a new terminal and add the following line to your
~/.bashrc
to avoid sourcing the workspace every time:echo "source ~/pathplanning/devel/setup.bash" >> ~/.bashrc
-
Start a ROS core in a new terminal:
roscore
-
Open CoppeliaSim using the following commands:
cd CoppeliaSim_Edu_V4_3_0_Ubuntu20_04/ ./coppeliaSim.sh
CoppeliaSim should open.
-
Load the scene
A_star_simulation_map.ttt
in CoppeliaSim. -
Run the scene in CoppeliaSim.
-
Open a new terminal and run the following command to execute the Python script:
rosrun a_star_pathplanning a_star.py
The code works by creating a 3D array map to represent walkable and non-walkable areas (e.g., map[x, y, z] = 0
or 1
). After defining the map, two random points are chosen as start and end points. The algorithm follows this flowchart:
Here are some visual results of the path planning algorithm: