This is our fork of the original RM4D. We add the support to compute reachability map on GPU. Contributor: @rgong
This is the implementation of the paper "RM4D: A Combined Reachability and Inverse Reachability Map for Common 6-/7-axis Robot Arms by Dimensionality Reduction to 4D", which has been presented at ICRA 2025. A preprint is available on arxiv. Please also check out project webpage.
Disclaimer: This code is released as a research prototype and is not intended for production use. It may contain incomplete features or bugs. The RAI Institute does not provide maintenance or support for this software. Contributions via pull requests are welcome.
Knowledge of a manipulator's workspace is fundamental for a variety of tasks including robot design, grasp planning and robot base placement. Consequently, workspace representations are well studied in robotics. Two important representations are reachability maps and inverse reachability maps. The former predicts whether a given end-effector pose is reachable from where the robot currently is, and the latter suggests suitable base positions for a desired end-effector pose. Typically, the reachability map is built by discretizing the 6D space containing the robot's workspace and determining, for each cell, whether it is reachable or not. The reachability map is subsequently inverted to build the inverse map. This is a cumbersome process which restricts the applications of such maps. In this work, we exploit commonalities of existing six and seven axis robot arms to reduce the dimension of the discretization from 6D to 4D. We propose Reachability Map 4D (RM4D), a map that only requires a single 4D data structure for both forward and inverse queries. This gives a much more compact map that can be constructed by an order of magnitude faster than existing maps, with no inversion overheads and no loss in accuracy. Our experiments showcase the usefulness of RM4D for grasp planning with a mobile manipulator.
Using RM4D as forward map, we can visualize the reachable workspace:
Using RM4D as inverse map, we can visualize suitable base positions. E.g. for a given end-effector position (aggregated over all possible orientations), or for a particular pose with orientation.
The RM4D package can be installed as follows:
git clone git@github.com:mrudorfer/rm4d.git
cd rm4d/
conda env create -n rm4d -f environment.yml
conda activate rm4d
This also allows to run all the experiment scripts, except the two scripts for the base position example:
create_base_position_scenario.pyfind_base_position_example.py
To run these, we need to additionally install the BURG Toolkit for scene/object handling and grasp sampling. This can be done as follows:
pip install git+https://github.com/mrudorfer/burg-toolkit@dev
GPU Support: For GPU-accelerated accuracy calculation, PyTorch with CUDA support is required. You can either:
- Use the GPU-enabled environment:
conda env create -n rm4d -f environment-gpu.yml - Or add PyTorch manually to the base environment (see experiment_scripts/README_GPU_Accuracy.md for details)
All experiment scripts are provided in the experiment_scripts folder.
The experiment data will be stored in experiment_scripts/data.
First, RM4D needs to be constructed by sampling robot configurations:
python create_map.py -r franka
Per default, we create RM4D with 10M samples and save a checkpoint every 1M samples.
To evaluate accuracy, we need to build a number of evaluation poses:
python eval_poses.py -r franka -n 100000
This will sample n poses and use IK to determine whether they are reachable or not.
IK number of trials and threshold can be adjusted.
To reproduce the ablation studies for Franka, we can pass the argument --degrees {150,160,166,180},
which will artificially adjust the joint limits of axes 1 and 7.
Subsequently, we can calculate the accuracy of the map:
python calculate_accuracy.py data/rm4d_franka_joint_42 data/eval_poses_franka166_n1000000_t25_i100
For faster processing of large evaluation datasets, a GPU-accelerated version is available. See experiment_scripts/README_GPU_Accuracy.md for details.
And with draw_plots.py we can create the plots as in the paper.
You may need to adjust the paths in the script itself.
The experiment_scripts/data directory contains generated experiment data. The following file types are created:
These directories contain ground truth data for evaluating map accuracy:
poses.npy: NumPy array of shape(N, 4, 4)containing end-effector transformation matrices. These are randomly sampled poses used for evaluation.reachable_by_ik.npy: NumPy boolean array of shape(N,)indicating which poses are reachable according to the inverse kinematics (IK) solver. This serves as the ground truth for accuracy evaluation.
Generated by: eval_poses.py
These directories contain the constructed reachability maps at different sampling checkpoints:
rmap.npy: The reachability map data structure saved at a specific sample checkpoint. Contains the 4D boolean map indicating which configurations are reachable. Can be loaded usingReachabilityMap4D.from_file().hit_stats.npy: NumPy array containing statistics about map construction progress. Tracks how many new map elements (voxels) are discovered as sampling progresses. Used for plotting convergence curves. Format:[access_values, hit_values]whereaccess_valuesare sample counts andhit_valuesare cumulative new voxel counts.
Directory structure:
data/
├── eval_poses_franka166_n100000_t25_i100/ # Evaluation data
│ ├── poses.npy
│ └── reachable_by_ik.npy
└── rm4d_franka_joint_42_0.05/ # Map construction data
├── 2000000/ # Checkpoint at 2M samples
│ ├── rmap.npy
│ └── hit_stats.npy
├── 4000000/ # Checkpoint at 4M samples
│ ├── rmap.npy
│ └── hit_stats.npy
└── ... # Additional checkpoints
Generated by: create_map.py
Note: These .npy files are generated by the experiment scripts and are intended to be present. They can be safely deleted if you want to regenerate them, but they are required for running accuracy evaluation and plotting scripts.


