Skip to content

Commit ef4bf33

Browse files
authored
Add feature to use wxyz as base orientation (#125)
1 parent 6ad11a1 commit ef4bf33

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

robot_log_visualizer/signal_provider/signal_provider.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,11 @@ def get_robot_state_at_index(self, index):
384384
robot_state["base_orientation"][2],
385385
).toNumPy()
386386
if robot_state["base_orientation"].shape[0] == 4:
387-
# convert the x y z w quaternion into w x y z
388387
tmp_quat = robot_state["base_orientation"]
389-
tmp_quat = np.array([tmp_quat[3], tmp_quat[0], tmp_quat[1], tmp_quat[2]])
388+
if self._robot_state_path.base_orientation_type == "xyzw":
389+
# convert x y z w into w x y z (iDynTree convention)
390+
tmp_quat = np.array([tmp_quat[3], tmp_quat[0], tmp_quat[1], tmp_quat[2]])
391+
# wxyz is already in iDynTree convention
390392

391393
robot_state["base_orientation"] = idyn.Rotation.RotationFromQuaternion(
392394
tmp_quat

robot_log_visualizer/ui/gui.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ def variableTreeWidget_on_right_click(self, item_position):
11071107
menu.addAction(dont_use_as_base_orientation_str)
11081108
else:
11091109
menu.addAction(use_as_base_orientation_str + " (xyzw Quaternion)")
1110+
menu.addAction(use_as_base_orientation_str + " (wxyz Quaternion)")
11101111

11111112
if item_size == 6:
11121113
if item_key in self.visualized_3d_arrows:
@@ -1199,6 +1200,12 @@ def variableTreeWidget_on_right_click(self, item_position):
11991200
self.robot_state_path.base_orientation_path
12001201
).setBackground(0, QtGui.QBrush(deselected_base_color))
12011202
self.robot_state_path.base_orientation_path = item_path
1203+
if "wxyz Quaternion" in action.text():
1204+
self.robot_state_path.base_orientation_type = "wxyz"
1205+
elif "xyzw Quaternion" in action.text():
1206+
self.robot_state_path.base_orientation_type = "xyzw"
1207+
else:
1208+
self.robot_state_path.base_orientation_type = "rpy"
12021209
# In real time mode, add those signal to the provider buffer
12031210
if (
12041211
self.signal_provider
@@ -1215,6 +1222,7 @@ def variableTreeWidget_on_right_click(self, item_position):
12151222

12161223
if action.text() == dont_use_as_base_orientation_str:
12171224
self.robot_state_path.base_orientation_path = []
1225+
self.robot_state_path.base_orientation_type = "rpy"
12181226
# if the item is used as base position we do not remove the color
12191227
if item_path != self.robot_state_path.base_position_path:
12201228
item.setBackground(0, QtGui.QBrush(deselected_base_color))

robot_log_visualizer/utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class RobotStatePath:
1717
def __init__(self):
1818
self.joints_state_path = []
1919
self.base_orientation_path = []
20+
self.base_orientation_type = "rpy" # "rpy", "xyzw", or "wxyz"
2021
self.base_position_path = []
2122

2223

0 commit comments

Comments
 (0)