about sim.buildPose sim.matrixToPose

Report crashes, strange behaviour, or apparent bugs
Post Reply
zhaoweishuo
Posts: 1
Joined: 18 Mar 2024, 09:21

about sim.buildPose sim.matrixToPose

Post by zhaoweishuo »

When I was using python's api interface to get the information, I found that the pose information generated through sim.buildPose and sim.matrixToPose was the opposite of the quaternion part of the data of the pose information obtained from sim.getObjectPose. I don't know if I'm doing it wrong. The software version is 4.6.0 rev. 18.

The link to the scene is: https://drive.google.com/file/d/1yodvDp ... drive_link

code:

Code: Select all

from coppeliasim_zmqremoteapi_client import RemoteAPIClient

client = RemoteAPIClient()  
sim = client.require('sim')

target_handle = sim.getObject('/AUBO_i5_Base/target')
target_position = sim.getObjectPosition(target_handle)
target_orientation = sim.getObjectOrientation(target_handle)

quaternion = sim.getObjectQuaternion(target_handle)
matrix = sim.getObjectMatrix(target_handle)
pose = sim.getObjectPose(target_handle)

buildPose = sim.buildPose(target_position, target_orientation)
buildmatrix = sim.buildMatrix(target_position, target_orientation)
matrixtopose = sim.matrixToPose(matrix)
print("p+o:", target_position+target_orientation)
print("getmatrix  :", matrix)
print("buildmatrix:", buildmatrix)
print("getpose  :", pose)
print("buildPose:", buildPose)
print("matrixtopose :", matrixtopose)
Printed information:

Code: Select all

p+o: [-0.41549992416098513, -0.05003193817850444, 0.9099538554466107, -0.6277006656026236, 1.554759639154284, -0.18438106416448685]
getmatrix  : [0.015764188683439206, 0.0029400102048859345, 0.9998714150805335, -0.41549992416098513, -0.7256467173344583, 0.6880030148329459, 0.009417706860055775, -0.05003193817850444, -0.6878868598664158, -0.7257018726176558, 0.012979218094706813, 0.9099538554466107]
buildmatrix: [0.015764188683428954, 0.002940010204884023, 0.9998714150805335, -0.41549992416098513, -0.725646717334463, 0.6880030148329412, 0.009417706860049647, -0.05003193817850444, -0.6878868598664111, -0.7257018726176603, 0.012979218094698368, 0.9099538554466107]
getpose  : [-0.41549992416098513, -0.05003193817850444, 0.9099538554466107, 0.2805271625688796, -0.644061256414093, 0.27803417711601647, -0.6551233512879641]
buildPose: [-0.41549992416098513, -0.05003193817850444, 0.9099538554466107, -0.28052716256888094, 0.6440612564140956, -0.2780341771160194, 0.6551233512879594]
matrixtopose : [-0.41549992416098513, -0.05003193817850444, 0.9099538554466107, -0.28052716256887955, 0.644061256414093, -0.2780341771160164, 0.655123351287964]
Also, after I moved the Dummy unchanged using the following code, the quaternion portion of the printed position information became consistent.

Code: Select all

target_handle = sim.getObject('/AUBO_i5_Base/target')
target_position = sim.getObjectPosition(target_handle)
target_orientation = sim.getObjectOrientation(target_handle)

sim.setObjectPosition(target_handle, target_position)
sim.setObjectOrientation(target_handle, target_orientation)
Printed information:

Code: Select all

p+o: [-0.41549992416098525, -0.05003193817850433, 0.9099538554466103, -0.6277006656026478, 1.5547596391542977, -0.18438106416447217]
getmatrix  : [0.01576418868342888, 0.0029400102048837695, 0.9998714150805337, -0.41549992416098525, -0.7256467173344628, 0.6880030148329412, 0.00941770686004989, -0.05003193817850433, -0.6878868598664112, -0.7257018726176603, 0.012979218094698042, 0.9099538554466103]
buildmatrix: [0.01576418868341547, 0.002940010204881268, 0.9998714150805337, -0.41549992416098525, -0.7256467173344696, 0.6880030148329344, 0.009417706860041878, -0.05003193817850433, -0.6878868598664043, -0.7257018726176669, 0.012979218094687002, 0.9099538554466103]
getpose  : [-0.41549992416098525, -0.05003193817850433, 0.9099538554466103, -0.280527162568881, 0.6440612564140957, -0.2780341771160193, 0.6551233512879595]
buildPose: [-0.41549992416098525, -0.05003193817850433, 0.9099538554466103, -0.28052716256888305, 0.6440612564140992, -0.2780341771160234, 0.6551233512879534]
matrixtopose : [-0.41549992416098525, -0.05003193817850433, 0.9099538554466103, -0.28052716256888105, 0.6440612564140958, -0.27803417711601935, 0.6551233512879595]

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: about sim.buildPose sim.matrixToPose

Post by coppelia »

Hello,

given two quaternions Q1 = [Qx, Qy, Qz, Qw] and Q2 = [-Qx, -Qy, -Qz, -Qw], the resulting rotation is the same (but using an opposite axes and a reverse angle). So effectively Q1 == Q2

Cheers

Post Reply