Previous Tutorial: C++ Get Started
Overview
This tutorial describes how to get started using Gazebo Math with Python.
NOTE: If you have compiled Gazebo Math from source, you should export your PYTHONPATH
.
We will run through an example that determines the distance between two points in 3D space. Start by creating a bare-bones main file using the editor of your choice.
The easiest way to include Gazebo Math is through import gz.math7
.
At this point your main file should look like
Now let's create two 3D points with arbitrary values. We will use the gz.math.Vector3
class to represent these points. Gazebo Math provides some Vector3
types which are: Vector3d
(Vector3 using doubles), Vector3f
(Vector3 using floats) and Vector3i
(Vector3 using integers). The result of this addition will be a main file similar to the following.
Finally, we can compute the distance between point1
and point2
using the gz.math.Vector3.distance()
function and output the distance value.
Running this program should result in the following output: