Python example: se2-poses-example.py

Example usage of SE(2) poses, for transformations in the plane (x,y,phi):

 1#!/usr/bin/env python3
 2
 3# ---------------------------------------------------------------------
 4# Install python3-pymrpt, ros-$ROS_DISTRO-python-mrpt,
 5# ros-$ROS_DISTRO-mrpt2, or test with a local build with:
 6# export PYTHONPATH=$HOME/code/mrpt/build-Release/:$PYTHONPATH
 7# ---------------------------------------------------------------------
 8
 9from math import radians
10from mrpt.pymrpt.mrpt.poses import CPose2D
11
12p1 = CPose2D(1.0, 2.0, radians(90.0))
13p2 = CPose2D(3.0, 0.0, radians(0.0))
14
15p3 = p1 + p2
16p4 = p3 - p1
17
18print('p1             : ' + str(p1))
19print('p2             : ' + str(p2))
20print('p1(+)p2        : ' + str(p3))
21print('(p1(+)p2)(-)p1 : ' + str(p4))

Output:

1p1             : (1.000,2.000,90.00deg)
2p2             : (3.000,0.000,0.00deg)
3p1(+)p2        : (1.000,5.000,90.00deg)
4(p1(+)p2)(-)p1 : (3.000,-0.000,0.00deg)