Plotting robot path and orientation using python +/- matplotlib

Viewed 1770

I have a 1000 x 3 numpy array of coordinates that consist of an (x, y, theta in radians) pose for a moving robot at various times (from time = 0 to time = 1000). Is it possible to graph this position and orientation information using python so that at each point (x,y) there is a small arrow that points in the theta direction? Perhaps a matplotlib type graph would be possible for this?

1 Answers

Have you tried the arrow function in matplotlib (documentation)?

Assuming that theta is angle in radians from the x axis, perhaps something like the following for each point will do it.

arrow(x, y, cos(theta), sin(theta))

The above code will draw an arrow from (x,y) to (x+dx, y+dy).

Another option is matplotlib.pyplot.quiverdocumentation. The quiver function allows us to control the length of the arrow in many ways.

Related