Python example: se3-poses-example.py
Example usage of SE(3) poses, for transformations in the space (x,y,z,yaw,pitch,roll):
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 mrpt.pymrpt import mrpt
10from math import radians
11
12p1 = mrpt.poses.CPose3D.FromXYZYawPitchRoll(
13 1.0, 2.0, 0, radians(90), radians(0), radians(0))
14p2 = mrpt.poses.CPose3D.FromXYZYawPitchRoll(
15 3.0, 0.0, 0, radians(0.0), radians(0), radians(0))
16
17p3 = p1 + p2
18p4 = p3 - p1
19
20print('p1 : ' + str(p1))
21print('p2 : ' + str(p2))
22print('p1(+)p2 : ' + str(p3))
23print('(p1(+)p2)(-)p1 : ' + str(p4))
Output:
1p1 : (x,y,z,yaw,pitch,roll)=(1.0000,2.0000,0.0000,90.00deg,0.00deg,0.00deg)
2p2 : (x,y,z,yaw,pitch,roll)=(3.0000,0.0000,0.0000,0.00deg,0.00deg,0.00deg)
3p1(+)p2 : (x,y,z,yaw,pitch,roll)=(1.0000,5.0000,0.0000,90.00deg,-0.00deg,0.00deg)
4(p1(+)p2)(-)p1 : (x,y,z,yaw,pitch,roll)=(3.0000,-0.0000,0.0000,0.00deg,-0.00deg,0.00deg)