conda create -n pybullet_robot_base python=3.10
conda activate pybullet_robot_base
conda install -c conda-forge pybullet numpy
There are two classes, a Robot
and a Goal
class.
The Robot
class handles the simulation and offers a few functions:
- reset joint positions
- get current joint positions
- get joint limits
- compute end effector position using forward kinematics
- check whether the robot is in collision with the environment or itself
- compute the Jacobian matrix
- visualise a goal position
The Goal
class provides the goal position and a metric to check the distance and whether the goal has been reached or not.
There are six different goals, which can all be used in development and testing.
Finally, the main.py
file shows some exemplary use of the classes.
It should run without any modifications, show the robot in the starting configuration and visualise all the goals.
Once you hit Enter on the command line, it shows a different (colliding) joint configuration.
This repository presents Python code implementing the numpy
and matplotlib
.
The
- Python 3.11
- numpy
- matplotlib
-
Clone the repository:
git clone https://github.com/Klins101/pybullet-robot-base cd pybullet-robot-base
-
Run the main script:
python main.py
-
Initialization:
- The
$J^+$ -RTT algorithm is initialized with the start configuration of the robot arm and an empty tree containing only the start configuration.
- The
-
Expansion:
- Iteratively expand the tree by generating random configurations in the workspace.
- Use the Jacobian pseudoinverse to compute joint velocities that move the end effector towards the randomly generated configurations.
- Update the current configuration of the robot arm based on the computed joint velocities.
- Ensure that the generated configurations are collision-free by performing collision checking.
- If a collision-free configuration is found, add it to the tree.
-
Goal Biasing:
- To speed up convergence, we occasionally bias the tree expansion towards the goal configuration to speed up convergence by sampling more points around the goal configuration.
-
Termination:
- The algorithm is terminated when the maximum number of iterations is reached.
-
Output:
- If a path from the start to the goal configuration is found, return the sequence of configurations that form the path.
- If no path is found within the maximum number of iterations, return a failure message.
You can adjust various parameters in the algorithm to customize its behavior:
max_iter
: Maximum number of iterations.step_size
: Step size for extending the tree towards random configurations.threshold
: Threshold distance to consider a configuration close to the goal.
This implementation was inspired by the