-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add utils for pointcloud (#115)
* create geometry/conversion.hpp and pointcloud/transform_pointcloud.hpp Signed-off-by: Autumn60 <[email protected]> * add dummy_test for each namespaces Signed-off-by: Autumn60 <[email protected]> * pre-commit Signed-off-by: Autumn60 <[email protected]> --------- Signed-off-by: Autumn60 <[email protected]>
- Loading branch information
Showing
7 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/common/wheel_stuck_common_utils/include/wheel_stuck_common_utils/geometry/conversion.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2024 Fool Stuck Engineers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef WHEEL_STUCK_COMMON_UTILS__GEOMETRY__CONVERSION_HPP_ | ||
#define WHEEL_STUCK_COMMON_UTILS__GEOMETRY__CONVERSION_HPP_ | ||
|
||
#include <Eigen/Core> | ||
#include <tf2_eigen/tf2_eigen.hpp> | ||
|
||
namespace wheel_stuck_common_utils::geometry | ||
{ | ||
|
||
geometry_msgs::msg::Pose to_pose(const geometry_msgs::msg::Transform & transform) | ||
{ | ||
geometry_msgs::msg::Pose pose; | ||
pose.position.x = transform.translation.x; | ||
pose.position.y = transform.translation.y; | ||
pose.position.z = transform.translation.z; | ||
pose.orientation = transform.rotation; | ||
return pose; | ||
} | ||
|
||
Eigen::Matrix4f to_matrix4f(const geometry_msgs::msg::Pose & pose) | ||
{ | ||
Eigen::Affine3d affine; | ||
tf2::fromMsg(pose, affine); | ||
return affine.cast<float>().matrix(); | ||
} | ||
|
||
Eigen::Matrix4f to_matrix4f(const geometry_msgs::msg::Transform & transform) | ||
{ | ||
Eigen::Affine3d affine; | ||
tf2::fromMsg(to_pose(transform), affine); | ||
return affine.cast<float>().matrix(); | ||
} | ||
} // namespace wheel_stuck_common_utils::geometry | ||
|
||
#endif // WHEEL_STUCK_COMMON_UTILS__GEOMETRY__CONVERSION_HPP_ |
43 changes: 43 additions & 0 deletions
43
...l_stuck_common_utils/include/wheel_stuck_common_utils/pointcloud/transform_pointcloud.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 Fool Stuck Engineers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef WHEEL_STUCK_COMMON_UTILS__POINTCLOUD__TRANSFORM_POINTCLOUD_HPP_ | ||
#define WHEEL_STUCK_COMMON_UTILS__POINTCLOUD__TRANSFORM_POINTCLOUD_HPP_ | ||
|
||
#include <Eigen/Core> | ||
|
||
#include <pcl/common/transforms.h> | ||
#include <pcl/point_cloud.h> | ||
|
||
namespace wheel_stuck_common_utils::pointcloud | ||
{ | ||
template <typename PointT> | ||
void try_transform_pointcloud( | ||
const pcl::PointCloud<PointT> & input, pcl::PointCloud<PointT> & output, | ||
const Eigen::Affine3d & transform) | ||
{ | ||
pcl::transformPointCloud(input, output, transform); | ||
} | ||
|
||
template <typename PointT> | ||
pcl::PointCloud<PointT> transform_pointcloud( | ||
const pcl::PointCloud<PointT> & input, const Eigen::Affine3d & transform) | ||
{ | ||
pcl::PointCloud<PointT> output; | ||
pcl::transformPointCloud(input, output, transform); | ||
return output; | ||
} | ||
} // namespace wheel_stuck_common_utils::pointcloud | ||
|
||
#endif // WHEEL_STUCK_COMMON_UTILS__POINTCLOUD__TRANSFORM_POINTCLOUD_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/common/wheel_stuck_common_utils/test/geometry/dummy_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2024 Fool Stuck Engineers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "wheel_stuck_common_utils/geometry/conversion.hpp" |
15 changes: 15 additions & 0 deletions
15
src/common/wheel_stuck_common_utils/test/pointcloud/dummy_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2024 Fool Stuck Engineers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "wheel_stuck_common_utils/pointcloud/transform_pointcloud.hpp" |
16 changes: 16 additions & 0 deletions
16
src/common/wheel_stuck_common_utils/test/ros/dummy_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2024 Fool Stuck Engineers | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "wheel_stuck_common_utils/ros/function_timer.hpp" | ||
#include "wheel_stuck_common_utils/ros/no_callback_subscription.hpp" |