Skip to content

Commit 9e9169e

Browse files
tobifalkcassava
authored andcommitted
models: Add geometry utility functions
1 parent 962d35d commit 9e9169e

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

models/include/cloe/utility/geometry.hpp

+27-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,34 @@ inline Eigen::Isometry3d pose_from_rotation_translation(const Eigen::Quaterniond
5252
}
5353

5454
/**
55-
* Change a point's frame of reference.
56-
* Both the point and the child frame need to have the same parent frame.
55+
* Compute the roll, pitch and yaw angles from a given pose.
56+
*
57+
* \param pose: Pose of which the rotation matrix shall be expressed in Euler angles.
58+
*/
59+
inline Eigen::Vector3d get_pose_roll_pitch_yaw(const Eigen::Isometry3d& pose) {
60+
return pose.rotation().matrix().eulerAngles(2, 1, 0).reverse();
61+
}
62+
63+
/**
64+
* Change a point's frame of reference from the parent frame to the child frame.
65+
*
66+
* \param child_frame: Pose of the child reference frame w.r.t. the parent frame.
67+
* \param pt_vec: Point coordinate vector w.r.t. the parent frame.
68+
*/
69+
inline void transform_point_to_child_frame(const Eigen::Isometry3d& child_frame,
70+
Eigen::Vector3d* pt_vec) {
71+
*pt_vec = child_frame.inverse() * (*pt_vec);
72+
}
73+
74+
/**
75+
* Change a point's frame of reference from the child frame to the parent frame.
76+
*
77+
* \param child_frame: Pose of the child reference frame w.r.t. the parent frame.
78+
* \param pt_vec_child: Point coordinate vector w.r.t. the child frame.
5779
*/
58-
inline void transform_to_child_frame(const Eigen::Isometry3d& child_frame, Eigen::Vector3d* point) {
59-
*point = child_frame.inverse() * (*point);
80+
inline void transform_point_to_parent_frame(const Eigen::Isometry3d& child_frame,
81+
Eigen::Vector3d* pt_vec_child) {
82+
*pt_vec_child = child_frame * (*pt_vec_child);
6083
}
6184

6285
} // namespace utility

optional/vtd/src/osi_omni_sensor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ void OsiOmniSensor::from_osi_boundary_points(const osi3::LaneBoundary& osi_lb,
627627
const auto& osi_pt = osi_lb.boundary_line(i);
628628
Eigen::Vector3d position = osi_vector3d_xyz_to_vector3d(osi_pt.position());
629629
// Transform points from the inertial into the sensor reference frame.
630-
cloe::utility::transform_to_child_frame(osi_ego_pose_, &position);
631-
cloe::utility::transform_to_child_frame(osi_sensor_pose_, &position);
630+
cloe::utility::transform_point_to_child_frame(osi_ego_pose_, &position);
631+
cloe::utility::transform_point_to_child_frame(osi_sensor_pose_, &position);
632632
lb.points.push_back(position);
633633
}
634634
// Compute clothoid segment. TODO(tobias): implement curved segments.

optional/vtd/src/osi_utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void osi_transform_base_moving(const osi3::BaseMoving& base_ref, osi3::BaseMovin
115115

116116
// Transform base.position/orientation/velocity/acceleration/orientation_rate:
117117
Eigen::Vector3d pos_ref_frame = pose.translation();
118-
cloe::utility::transform_to_child_frame(pose_ref, &pos_ref_frame);
118+
cloe::utility::transform_point_to_child_frame(pose_ref, &pos_ref_frame);
119119
pose.translation() = pos_ref_frame; // location in reference frame
120120
pose.rotate(pose_ref.rotation().inverse()); // orientation in reference frame
121121
// Write new pose to base.

0 commit comments

Comments
 (0)