Closed vamsikalagaturu closed 2 years ago
https://answers.ros.org/question/330920/ros-2-composable-node-pass-nodehandler/
so you can use shared_from_this()
and std::shared_ptr
(with no const
and pass by value, not reference)
std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node
@vamsikalagaturu I forgot I had commented on this. The comment still applies:
When creating the object, replace
cluster_visualizer_rgb_("output/tabletop_cluster_rgb", true)
with:
cluster_visualizer_rgb_(shared_from_this(), "output/tabletop_cluster_rgb", true)
The constructor signature should be:
ClusteredPointCloudVisualizer::ClusteredPointCloudVisualizer(
std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node,
const std::string &topic_name, bool check_subscribers)
One other option is to create the visualizers only in the on_configure
function. It makes sense for keeping with the lifecycle rules of creating publishers only on configuration. This probably means you will have to make the visualizer objects themselves as shared_ptrs.
Declaring them in the on_configure
and using shared_from_this()
has resolved the duplicate name conflicts.
In the multimodal_object_recognition.cpp constructor:
https://github.com/HBRS-SDP/ss22-ros2-perception/blob/43bf5f8fa26eba3cfaf84deee420159f34f086fe/mir_object_recognition/ros/src/multimodal_object_recognition.cpp#L665
while initializing the
cluster_visualizer_rgb_
, we cannot passthis
as a paramter to the cluster_visualizerrgb.https://github.com/HBRS-SDP/ss22-ros2-perception/blob/43bf5f8fa26eba3cfaf84deee420159f34f086fe/mir_object_recognition/ros/src/mir_perception_utils/clustered_point_cloud_visualizer.cpp#L17
it throws the below error:
This can be reproduced by checking out to the commit
43bf5f8
ofcloud_image_recog
branch and addingthis
as a parameter in the below line:https://github.com/HBRS-SDP/ss22-ros2-perception/blob/43bf5f8fa26eba3cfaf84deee420159f34f086fe/mir_object_recognition/ros/src/multimodal_object_recognition.cpp#L665
This is not a blocking issue, currently, we are creating temporary nodes and publishing the data:
https://github.com/HBRS-SDP/ss22-ros2-perception/blob/43bf5f8fa26eba3cfaf84deee420159f34f086fe/mir_object_recognition/ros/src/mir_perception_utils/clustered_point_cloud_visualizer.cpp#L33
I am just exploring to pass the main node instance and use it to publish data, rather than temporary nodes.