# RRT* Path Finding Algorithm in Rerun

## How to Visualize the RRT* Algorithm in a Simple Environment

2 min readMay 15, 2024

--

This tutorial focused on visualizing the path finding algorithm RRT* in a simple environment with Rerun.

If you’re eager to give it a try: Try it on the browser!

The algorithm finds a path between two points by randomly expanding a tree from the start point. After it has added a random edge to the tree it looks at nearby nodes to check if it’s faster to reach them through this new edge instead, and if so it changes the parent of these nodes. This ensures that the algorithm will converge to the optimal path given enough time.

# Logging and visualizing with Rerun

All points are logged using the `Points2D` archetype, while the lines are logged using the `LineStrips2D`.

The visualizations in this example were created with the following Rerun code:

# Map

## Starting point

`rr.log("map/start", rr.Points2D([start_point], radii=0.02, colors=[[255, 255, 255, 255]]))`

## Destination point

`rr.log("map/destination", rr.Points2D([end_point], radii=0.02, colors=[[255, 255, 0, 255]]))`

## Obstacles

`rr.log("map/obstacles", rr.LineStrips2D(self.obstacles))`

# RRT tree

## Edges

`rr.log("map/tree/edges", rr.LineStrips2D(tree.segments(), radii=0.0005, colors=[0, 0, 255, 128]))`

## New edges

`rr.log("map/new/new_edge", rr.LineStrips2D([(closest_node.pos, new_point)], colors=[color], radii=0.001))`

## Vertices

`rr.log("map/tree/vertices", rr.Points2D([node.pos for node in tree], radii=0.002), rr.AnyValues(cost=[float(node.cost) for node in tree]))`

## Close nodes

`rr.log("map/new/close_nodes", rr.Points2D([node.pos for node in close_nodes]))`

## Closest node

`rr.log("map/new/closest_node", rr.Points2D([closest_node.pos], radii=0.008))`

## Random points

`rr.log("map/new/random_point", rr.Points2D([random_point], radii=0.008))`

## New points

`rr.log("map/new/new_point", rr.Points2D([new_point], radii=0.008))`

## Path

`rr.log("map/path", rr.LineStrips2D(segments, radii=0.002, colors=[0, 255, 255, 255]))`

--

--

AI | Robotics | Apple Enthusiast | Passionate Computer Scientist pursuing an MSc in Autonomous Systems at KTH.