Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert transformation matrix to pose ros

#!/usr/bin/env python

import numpy

from geometry_msgs.msg import Quaternion, Pose, Point
from transforms3d.quaternions import quat2mat, mat2quat

def transform_matrix_to_ros_pose(mat):
    """
    Convert a transform matrix to a ROS pose.
    """
    quat = mat2quat(mat[:3, :3])
    msg = Pose()
    msg.position = Point(x=mat[0, 3], y=mat[1, 3], z=mat[2, 3])
    msg.orientation = Quaternion(w=quat[0], x=quat[1], y=quat[2], z=quat[3])
    return msg


def ros_pose_to_transform_matrix(msg):
    """
    Convert a ROS pose to a transform matrix
    """
    mat44 = numpy.eye(4)
    mat44[:3, :3] = quat2mat([msg.orientation.w, msg.orientation.x,
                              msg.orientation.y, msg.orientation.z])
    mat44[0:3, -1] = [msg.position.x, msg.position.y, msg.position.z]
    return mat44
Comment

PREVIOUS NEXT
Code Example
Python :: try datetime python 
Python :: discord identity python html avatar 
Python :: classification report value extration 
Python :: seaborn styles 
Python :: sort list of dictionaries python by value 
Python :: pandas date_range 
Python :: open csv from google drive using python 
Python :: python clear screen 
Python :: python httpserver 
Python :: close selenium webdriver python 
Python :: django annotate concat string 
Python :: djangodebug toolbar not showing 
Python :: ubuntu cant find python installation 
Python :: print on two digit python format 
Python :: python format datetime 
Python :: rotate xticks matplotlib 
Python :: how to write words on any other apps in python 
Python :: find sum of values in a column that corresponds to unique vallues in another coulmn python 
Python :: changing instance through dict changes all instances 
Python :: How to save XLSX file to ir_attachment odoo 
Python :: is prime python 
Python :: pandas get numeric columns 
Python :: program to segregate positive and negative numbers in same list 
Python :: double .get().get() dict python 
Python :: how to remove trackback on python when ctrl c 
Python :: pandas series select first value 
Python :: taking hour information from time in pandas 
Python :: python logger format time 
Python :: pros and cons of python flush print function 
Python :: DataFrame.plot.line() method: | dataframe line plot 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =