-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reenable sensor_msgs test #422
Changes from 3 commits
33c0a39
7eb81ba
283cc4b
86c30b5
1d9c751
b392269
9b9c170
778574f
1f8065a
192d585
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,10 @@ | |
<depend>tf2_ros</depend> | ||
<!-- <depend>python_orocos_kdl</depend> --> | ||
<!-- <test_depend>rostest</test_depend> --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think we should remove this. It's a ros1 dependency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gleichdick I will relaunch CI when this line will be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed them, furhtermore some more flake8 issues are resolved which the CI found. Maybe we should add the flake8 modules mentioned here to the CI of this project (not the big one)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I agree we should eventually do that, I don't think we should do that here. The next step for this package in my opinion is to split it up into separate |
||
|
||
<exec_depend>tf2_ros_py</exec_depend> | ||
<!-- <exec_depend>tf2_ros_py</exec_depend> --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
|
||
<test_depend>ament_cmake_gtest</test_depend> | ||
<test_depend>rclcpp</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -27,13 +27,16 @@ | |||||||||||
* POSSIBILITY OF SUCH DAMAGE. | ||||||||||||
*/ | ||||||||||||
|
||||||||||||
#include <memory> | ||||||||||||
|
||||||||||||
#include <tf2_sensor_msgs/tf2_sensor_msgs.hpp> | ||||||||||||
#include <geometry_msgs/PoseStamped.h> | ||||||||||||
#include <tf2_ros/transform_listener.h> | ||||||||||||
#include <ros/ros.h> | ||||||||||||
#include <builtin_interfaces/msg/time.hpp> | ||||||||||||
#include <geometry_msgs/msg/pose_stamped.hpp> | ||||||||||||
#include <gtest/gtest.h> | ||||||||||||
#include <rclcpp/rclcpp.hpp> | ||||||||||||
#include <sensor_msgs/point_cloud2_iterator.hpp> | ||||||||||||
#include <tf2_ros/buffer.h> | ||||||||||||
#include <tf2_ros/transform_listener.h> | ||||||||||||
#include <tf2_sensor_msgs/tf2_sensor_msgs.hpp> | ||||||||||||
|
||||||||||||
std::unique_ptr<tf2_ros::Buffer> tf_buffer = nullptr; | ||||||||||||
static const double EPS = 1e-3; | ||||||||||||
|
@@ -42,45 +45,48 @@ static const double EPS = 1e-3; | |||||||||||
TEST(Tf2Sensor, PointCloud2) | ||||||||||||
{ | ||||||||||||
sensor_msgs::msg::PointCloud2 cloud; | ||||||||||||
sensor_msgs::msg::PointCloud2Modifier modifier(cloud); | ||||||||||||
sensor_msgs::PointCloud2Modifier modifier(cloud); | ||||||||||||
modifier.setPointCloud2FieldsByString(2, "xyz", "rgb"); | ||||||||||||
modifier.resize(1); | ||||||||||||
|
||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_x(cloud, "x"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_y(cloud, "y"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_z(cloud, "z"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_x(cloud, "x"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_y(cloud, "y"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_z(cloud, "z"); | ||||||||||||
|
||||||||||||
*iter_x = 1; | ||||||||||||
*iter_y = 2; | ||||||||||||
*iter_z = 3; | ||||||||||||
|
||||||||||||
cloud.header.stamp = builtin_interfaces::msg::Time(2); | ||||||||||||
cloud.header.stamp.sec = 2; | ||||||||||||
cloud.header.stamp.nanosec = 0; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as below |
||||||||||||
cloud.header.frame_id = "A"; | ||||||||||||
|
||||||||||||
// simple api | ||||||||||||
sensor_msgs::msg::PointCloud2 cloud_simple = tf_buffer->transform(cloud, "B", tf2::durationFromSec(2.0)); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_x_after(cloud_simple, "x"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_y_after(cloud_simple, "y"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_z_after(cloud_simple, "z"); | ||||||||||||
sensor_msgs::msg::PointCloud2 cloud_simple = tf_buffer->transform( | ||||||||||||
cloud, "B", tf2::durationFromSec( | ||||||||||||
2.0)); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks wierd.
Suggested change
|
||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_x_after(cloud_simple, "x"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_y_after(cloud_simple, "y"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_z_after(cloud_simple, "z"); | ||||||||||||
EXPECT_NEAR(*iter_x_after, -9, EPS); | ||||||||||||
EXPECT_NEAR(*iter_y_after, 18, EPS); | ||||||||||||
EXPECT_NEAR(*iter_z_after, 27, EPS); | ||||||||||||
|
||||||||||||
// advanced api | ||||||||||||
sensor_msgs::msg::PointCloud2 cloud_advanced = tf_buffer->transform(cloud, "B", builtin_interfaces::msg::Time(2.0), | ||||||||||||
"A", tf2::durationFromSec(3.0)); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_x_advanced(cloud_advanced, "x"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_y_advanced(cloud_advanced, "y"); | ||||||||||||
sensor_msgs::msg::PointCloud2Iterator<float> iter_z_advanced(cloud_advanced, "z"); | ||||||||||||
sensor_msgs::msg::PointCloud2 cloud_advanced = tf_buffer->transform( | ||||||||||||
cloud, "B", tf2::timeFromSec(2.0), | ||||||||||||
"A", tf2::durationFromSec(3.0)); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_x_advanced(cloud_advanced, "x"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_y_advanced(cloud_advanced, "y"); | ||||||||||||
sensor_msgs::PointCloud2Iterator<float> iter_z_advanced(cloud_advanced, "z"); | ||||||||||||
EXPECT_NEAR(*iter_x_advanced, -9, EPS); | ||||||||||||
EXPECT_NEAR(*iter_y_advanced, 18, EPS); | ||||||||||||
EXPECT_NEAR(*iter_z_advanced, 27, EPS); | ||||||||||||
} | ||||||||||||
|
||||||||||||
int main(int argc, char **argv){ | ||||||||||||
int main(int argc, char ** argv) | ||||||||||||
{ | ||||||||||||
testing::InitGoogleTest(&argc, argv); | ||||||||||||
ros::init(argc, argv, "test"); | ||||||||||||
ros::NodeHandle n; | ||||||||||||
|
||||||||||||
rclcpp::Clock::SharedPtr clock = std::make_shared<rclcpp::Clock>(RCL_SYSTEM_TIME); | ||||||||||||
tf_buffer = std::make_unique<tf2_ros::Buffer>(clock); | ||||||||||||
|
@@ -94,7 +100,8 @@ int main(int argc, char **argv){ | |||||||||||
t.transform.rotation.y = 0; | ||||||||||||
t.transform.rotation.z = 0; | ||||||||||||
t.transform.rotation.w = 0; | ||||||||||||
t.header.stamp = builtin_interfaces::msg::Time(2.0); | ||||||||||||
t.header.stamp.sec = 2; | ||||||||||||
t.header.stamp.nanosec = 0; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try this?
Suggested change
|
||||||||||||
t.header.frame_id = "A"; | ||||||||||||
t.child_frame_id = "B"; | ||||||||||||
tf_buffer->setTransform(t, "test"); | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove