NVIDIA-AI-IOT / ros2_tao_pointpillars

ROS2 node for 3D object detection using TAO-PointPillars.
Apache License 2.0
70 stars 22 forks source link

Compilation in galactic fails with missing attributes in vision_msgs::msg::ObjectHypothesisWithPose #3

Open RFRIEDM-Trimble opened 1 year ago

RFRIEDM-Trimble commented 1 year ago

The following two lines of code cause failure to compile when building in ROS2 galactic.

        hyp.id = std::to_string(nms_pred[i].id);
        hyp.score = nms_pred[i].score;

Full error:

 root@rfriedm-us-dl01:~/tas-ros2-system# colcon build --packages-up-to pp_infer --cmake-args -DCMAKE_CXX_COMPILER=g++-8
Starting >>> pp_infer
--- stderr: pp_infer                             
** WARNING ** io features related to openni will be disabled
** WARNING ** io features related to openni2 will be disabled
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
** WARNING ** io features related to libusb-1.0 will be disabled
** WARNING ** visualization features related to openni will be disabled
** WARNING ** visualization features related to openni2 will be disabled
** WARNING ** apps features related to openni will be disabled
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp: In constructor ‘MinimalPublisher::MinimalPublisher()’:
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:76:42: warning: ‘const rclcpp::ParameterValue& rclcpp::Node::declare_parameter(const string&)’ is deprecated: declare_parameter() with only a name is deprecated and will be deleted in the future.
If you want to declare a parameter that won't change type without a default value use:
`node->declare_parameter<ParameterT>(name)`, where e.g. ParameterT=int64_t.

If you want to declare a parameter that can dynamically change type use:

rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.dynamic_typing = true;
node->declare_parameter(name, rclcpp::ParameterValue{}, descriptor);
 [-Wdeprecated-declarations]
     this->declare_parameter("class_names");
                                          ^
In file included from /opt/ros/galactic/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/galactic/include/rclcpp/executors.hpp:22,
                 from /opt/ros/galactic/include/rclcpp/rclcpp.hpp:156,
                 from /opt/ros/galactic/include/message_filters/subscriber.h:38,
                 from /root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/include/pp_infer/pointpillar.h:31,
                 from /root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:39:
/opt/ros/galactic/include/rclcpp/node.hpp:422:3: note: declared here
   declare_parameter(const std::string & name);
   ^~~~~~~~~~~~~~~~~
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp: In member function ‘void MinimalPublisher::topic_callback(sensor_msgs::msg::PointCloud2_<std::allocator<void> >::ConstSharedPtr)’:
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:177:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<Bndbox>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
       for(int i=0; i<nms_pred.size(); i++) {
                    ~^~~~~~~~~~~~~~~~
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:199:13: error: ‘using ObjectHypothesisWithPose = struct vision_msgs::msg::ObjectHypothesisWithPose_<std::allocator<void> >’ {aka ‘struct vision_msgs::msg::ObjectHypothesisWithPose_<std::allocator<void> >’} has no member named ‘id’
         hyp.id = std::to_string(nms_pred[i].id);
             ^~
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:200:13: error: ‘using ObjectHypothesisWithPose = struct vision_msgs::msg::ObjectHypothesisWithPose_<std::allocator<void> >’ {aka ‘struct vision_msgs::msg::ObjectHypothesisWithPose_<std::allocator<void> >’} has no member named ‘score’
         hyp.score = nms_pred[i].score;
             ^~~~~
/root/tas-ros2-system/src/TrimbleExternal/RFRIEDM-Trimble/ros2_tao_pointpillars/src/pp_inference_node.cpp:135:20: warning: unused variable ‘num_point_values’ [-Wunused-variable]
       unsigned int num_point_values = pcl_cloud->size();
                    ^~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/pp_infer.dir/build.make:63: CMakeFiles/pp_infer.dir/src/pp_inference_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/pp_infer.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< pp_infer [7.99s, exited with code 2]

Summary: 0 packages finished [9.09s]
  1 package failed: pp_infer
  1 package had stderr output: pp_infer

The variable hyp is of type vision_msgs::msg::ObjectHypothesisWithPose, definition for galactic here. Perhaps it is related to this PR, since there was a breaking change in the message definition?

The standard ROS2 way of handling this would be to create branches for each version as such:

  1. Take the current branch, name it foxy, this is the current state of the repo.
  2. Create a new branch, name it galactic and use the new message definition from galactic. I am happy to submit a PR to handle this.
  3. Create a humble and rolling branch, fixing compilation in them as needed.