Hi @PepMS, I have that message marked as send in the uorb_rtps_message_ids.yaml
file both in Firmware/msg/tools
and px4_ros_com_ros2/src/px4_ros_com/templates
(this workspace was created following the px4 dev guide documentation on the RTPS/ROS2 interface). I was cloning your repository at the same level as px4_ros_com in the px4_ros_com_ros2/src
directory with the following structure:
px4_ros_com_ros2/
- build/
- install/
- log/
- src/
+ px4_mpc
+ px4_msgs
+ px4_ros_com
But when I build using the build_ros2_workspace.bash, it fails with:
--- stderr: px4_mpc
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp: In constructor ‘OffboardControl::OffboardControl(rclcpp::Node::SharedPtr)’:
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:7:184: error: no matching function for call to ‘rclcpp::Node::create_subscription<px4_msgs::msg::VehicleOdometry>(const char [28], std::_Bind_helper<false, void (OffboardControl::*)(std::unique_ptr<px4_msgs::msg::VehicleOdometry_<std::allocator<void> >, std::default_delete<px4_msgs::msg::VehicleOdometry_<std::allocator<void> > > >), OffboardControl*, const std::_Placeholder<1>&>::type)’
7 | odometry_subs_ = node_->create_subscription<px4_msgs::msg::VehicleOdometry>("VehicleOdometry_PubSubTopic", std::bind(&OffboardControl::odometryCallback, this, std::placeholders::_1));
| ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/user/px4_ros_com_ros2/src/px4_mpc/include/px4_mpc/offboard_control.hpp:4,
from /home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note: candidate: ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr)’
213 | create_subscription(
| ^~~~~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note: template argument deduction/substitution failed:
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:7:184: note: candidate expects 5 arguments, 2 provided
7 | odometry_subs_ = node_->create_subscription<px4_msgs::msg::VehicleOdometry>("VehicleOdometry_PubSubTopic", std::bind(&OffboardControl::odometryCallback, this, std::placeholders::_1));
| ^
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:8:198: error: no matching function for call to ‘rclcpp::Node::create_subscription<px4_msgs::msg::VehicleControlMode>(const char [31], std::_Bind_helper<false, void (OffboardControl::*)(std::unique_ptr<px4_msgs::msg::VehicleControlMode_<std::allocator<void> >, std::default_delete<px4_msgs::msg::VehicleControlMode_<std::allocator<void> > > >), OffboardControl*, const std::_Placeholder<1>&>::type)’
8 | ctrl_mode_subs_ = node_->create_subscription<px4_msgs::msg::VehicleControlMode>("VehicleControlMode_PubSubTopic", std::bind(&OffboardControl::vehicleCtrlModeCallback, this, std::placeholders::_1));
| ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/user/px4_ros_com_ros2/src/px4_mpc/include/px4_mpc/offboard_control.hpp:4,
from /home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note: candidate: ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr)’
213 | create_subscription(
| ^~~~~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note: template argument deduction/substitution failed:
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:8:198: note: candidate expects 5 arguments, 2 provided
8 | ctrl_mode_subs_ = node_->create_subscription<px4_msgs::msg::VehicleControlMode>("VehicleControlMode_PubSubTopic", std::bind(&OffboardControl::vehicleCtrlModeCallback, this, std::placeholders::_1));
| ^
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:10:116: error: no matching function for call to ‘rclcpp::Node::create_publisher<px4_msgs::msg::OffboardControlMode>(const char [32])’
10 | offboard_mode_pub_ = node->create_publisher<px4_msgs::msg::OffboardControlMode>("OffboardControlMode_PubSubTopic");
| ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
from /home/user/px4_ros_com_ros2/src/px4_mpc/include/px4_mpc/offboard_control.hpp:4,
from /home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note: candidate: ‘template<class MessageT, class AllocatorT, class PublisherT> std::shared_ptr<PublisherT> rclcpp::Node::create_publisher(const string&, const rclcpp::QoS&, const rclcpp::PublisherOptionsWithAllocator<AllocatorT>&)’
184 | create_publisher(
| ^~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note: template argument deduction/substitution failed:
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:10:116: note: candidate expects 3 arguments, 1 provided
10 | offboard_mode_pub_ = node->create_publisher<px4_msgs::msg::OffboardControlMode>("OffboardControlMode_PubSubTopic");
| ^
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp: In member function ‘void OffboardControl::odometryCallback(px4_msgs::msg::VehicleOdometry_<std::allocator<void> >::UniquePtr)’:
/home/user/px4_ros_com_ros2/src/px4_mpc/src/offboard_control.cpp:22:88: warning: unused parameter ‘msg’ [-Wunused-parameter]
22 | void OffboardControl::odometryCallback(const px4_msgs::msg::VehicleOdometry::UniquePtr msg)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
make[2]: *** [CMakeFiles/offboard_controller.dir/build.make:76: CMakeFiles/offboard_controller.dir/src/offboard_control.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/offboard_controller.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed <<< px4_mpc [3.86s, exited with code 2]
Aborted <<< px4_ros_com [1min 39s]
Summary: 1 package finished [4min 7s]
1 package failed: px4_mpc
1 package aborted: px4_ros_com
2 packages had stderr output: px4_mpc px4_ros_com
Any ideas?