This repository holds code for various motion and path planning explorations, with a focus on robot arms.
Most robot arms have 6 degrees of freedom (DOF). This makes path and motion planning more difficult to visualize than for 2D or 3D cases, but the principles and applicable algorithms are the same.
In this repository, A* and the Probabilistic Roadmap (PRM) method along with some of their variants are used.
The code in this repository assumes a generic 6 DOF robot arm (arm model determines dimensions, joint angle limits, etc. during planning).
It is recommended to use a Docker container by following the steps below. The code in this repository may work outside of a container depending on your system, but no guarantees.
- Install
docker
anddocker-compose
- e.g. in Arch-based distros:
yay -S docker docker-compose
- Be sure to
enable
andstart
the Docker daemon- e.g.
systemctl enable docker.service && systemctl start docker.service
- e.g.
- Note: depending on your install, either
docker compose
ordocker-compose
may work for the following commands.
- e.g. in Arch-based distros:
- Build the Docker image:
sudo docker build -f Dockerfile -t motion-planning:latest .
- Start the container:
- Create new container and start:
sudo docker compose -f docker-compose.yaml up -d
- Start existing container:
sudo docker compose -f docker-compose.yaml start
- Create new container and start:
- Enter the container:
sudo docker compose exec motion-planning bash
When finished, either stop
the container (which will allow it to be reused later with start
) or down
the container, which will stop and remove the container:
sudo docker compose -f docker-compose.yaml stop
sudo docker compose -f docker-compose.yaml down
The code may be used out of the box with the provided example arm configuration file. However, you may wish to use dimensions/parameters specific to your own arm. If so, it's recommended to duplicate the example file and modify it to suit your purposes instead of editing it directly, which will probably make some unit tests fail.
Additionally, note that if you significantly change the arm dimensions you will probably want to modify the self-collision checking function in the Map class.
The guidance in Arm Parameters applies. Recommended to duplicate the example obstacles configuration file instead of modifying it, or else some unit tests may fail.
- If not already inside, enter Docker container (see steps above).
- (Skip if done already) Configure the project with CMake:
- Navigate to
motion-planning
directory. mkdir build
cd build
cmake ..
- Navigate to
- Build the project:
- Navigate to the
build
directory. cmake --build .
- Navigate to the
- Run the example script.
Visualization is done using matplotlib
plots in a Python script. Currently, I do not know of a straightforward/general way to view the plots directly in Docker. If you know of one, please let me know or make a pull request. In the meantime, to view the interactive visualization plots you have to run the Python script locally.
- Install required Python packages from
requirements.txt
.- The exact command will depend on your system. A common one:
pip install -r visualizer/requirements.txt
- The exact command will depend on your system. A common one:
- Run the visualizer script.
Various unit tests are provided for the libraries in this repository. They currently use the Catch2 framework for C++ code, and the PyTest framework for Python code. Unit tests should be run from within the Docker environment.
To run the C++ unit tests:
- Compile the code (e.g. by following the steps above.)
- Navigate to the
build
directory. - Run any of the unit test executables, e.g.
Vec3Test
.
To run the Python unit tests:
- Navigate to the directory containing the Python code.
- Run
pytest
in that directory.
The code mainly follows the Google code style guidelines. Max characters per line are limited to 120 instead of 80.
Feel free to use or modify the code in this repository as you wish (MIT license).