Robot Path Planning via a Path Generation Network.
Planning in configuration space allows us to consider the robot as a single point, thus simplifying the planning problem.
workspace | configuration space |
---|---|
![]() |
![]() |
path in workspace | path in configuration space |
---|---|
![]() |
![]() |
However, the conversion from workspace to configuration space usually does not have an explicit mathematical expression, and the configuration space is usually a continuous and high-dimensional space (e.g., a 6-dof robot arm), making it difficult to plan in configuration space.
Despite its continuity and high dimensionality, given a configuration, we can easily check if it is in the free configuration space. That means, we can sample from that space, and use finite samples to approximate the entire space. In this repo, whether a robot collides with an obstacle in the environment under configuration
The network in this repo named Collision Detection Network. Indeed, it is a binary classifier trained with Weighted Cross Entropy:
where
- Network Input: Robot Configuration + Variable (e.g. the information on the dimensions (bbox) of the object being grasped by the robot)
- Network output: The probability of collision with the environment
After training the Collision Detection Network, we can visualize its outputs in two ways:
- make configuration fixed, and change the bbox size
configuration in free space | probability in bbox size |
---|---|
![]() |
![]() |
configuration near obstacle | probability in bbox size |
---|---|
![]() |
![]() |
- make bbox size fixed, and change the configuration
ground truth configuration space | network predicted configuration space |
---|---|
![]() |
![]() |
Given a configuration
which is, the negative log-likelihood of the robot not colliding with the environment. By minimizing the objective function, configuration
If these independent configurations are constrained to a single curve, then the curve is hopefully capable of achieving overall obstacle avoidance. Instead of adding constrains to each points, we can use Bézier curve, and sample configurations on the curve. At this point the decision variable becomes the control point of the Bézier curve. The below figures shows curves before/after optimization:
This is actually perfectly fine as a simple path planning algorithm, but for tasks like Pick & Place, where the environment of the robot is fixed and only the dimensions of the object being grasped change, there exists a mapping from planning queries (
A Path Generation Network
In order to train
The training architecture looks like a GAN or Actor-Critic architecture. In fact, we can think of it as a GAN with a fixed discriminator, or an Actor-Critic with a fixed critic. The problem is actually a simplified reinforcement learning problem, i.e., an associated, continuous state space multi-armed bandit problem.
In order to ensure that the output values of the path generation network do not have a large number of control points concentrated in a small region due to network weight initialization, a specific strategy is adopted whereby the output of the path generation network does not directly correspond to the control points of the curve, but is an offset with respect to the initial control points. The selection scheme for the initial control points is to sample points equally spaced on a straight line connecting the starting configuration to the goal configuration. This is done by calculating the length of the straight line segment connecting the starting configuration and the goal configuration, and then dividing it equally spaced according to the number of control points, and assigning each division point sequentially to each intermediate control point:
Since the intermediate control points lie on the same line, all points on the initial Bézier curve also fall on that line. This offset mechanism makes it possible to generate a curve that essentially behaves as a straight line even if the output value of the model is small, avoiding abnormal shapes to the curve.
The loss function used to train
During the training of the path generation network, we use two different sampling strategies for the curve parameter
Path Planned by Path Generation Network:
Make sure you installed required Python package, e.g., PyTorch, PyQt5 etc.
In src
folder:
python3 generate_data.py --num_train_samples 500000 --num_test_samples 50000 --save_path "../data" --min_bbox_width 10 --max_bbox_width 40 --min_bbox_height 10 --max_bbox_height 40
After running the script, two .npy
files generated for training and testing respectively. BBOX size are sampled from two uniform distribution
In src
folder:
python3 train_collision_detection_network.py --data_folder ../data --log_name collision_detection_network --epochs 100 --gpu_ids 0
In src
folder:
python3 visualize.py --ckpt ../run/collision_detection_network/final.pth --gpu_ids 0
- --ckpt: the checkpoint file of the network
There are two buttons:
- Evaluate Network Output: generate probability in bbox size plot and probability heat map
- Generate Ground Truth Configuration Space: generate the ground truth configuration space using collision detection algorithm provided by PyQt5
- Visualize Collison Avoidance
In src folder:
python3 visualize_collision_avoidance.py --ckpt ../run/collision_detection_network/final.pth --gpu_ids 0
- Visualize Curve Optimization
In src folder:
python3 visualize_curve_optimization.py --ckpt ../run/collision_detection_network/final.pth --gpu_ids 0
In src
folder:
python3 train_path_generation_network.py --ckpt ../run/collision_detection_network/final.pth --log_name path_generation_network --epochs 100 --gpu_ids 0 --gamma 30
In src
folder:
python3 app.py --cdn_ckpt ../run/collision_detection_network/final.pth --pgn_ckpt ../run/path_generation_network/final.pth --gpu_ids 0
- --cdn_ckpt is the collision detection network checkpoint file
- --pgn_ckpt is the path generation network checkpoint file
mouse double click in the scene to set the goal pose
As can be seen, during curve optimization, some curves stuck at local minima are successfully planned by
If you use this repo in your research, please cite this repo:
@misc{Movic2024,
author = {Movic, Chen},
title = {Path Generation Network},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/mo-vic/PathGenerationNetwork}}
}
For commercial use, contact me first: [email protected]
[1] Choset H, Lynch K. M, Hutchinson S, et al. Principles of robot motion: theory, algorithms, and implementations[M]. MIT Press, 2005.