Calling a callback function from another callback function [closed]
Hi! I have a node with two subscribers and the code in one of the subscribers gets executed only once(because of a conditional flag) and it is in this function that I wish to call another callback function. The callback function expects const package::Euler_val::ConstPtr& array
where package::Euler_val
is a custom message type defined as float64[3] Euler_angles
. So far, this is what I've done:
const boost::shared_ptr<std_msgs::Float64> my_arr(new std_msgs::Float64[3], std::default_delete<std_msgs::Float64[]>());
for (int i = 0; i < 3; i++)
my_arr.get()[i] = Euler.at<std_msgs::Float64>(i);
callback2(my_arr);
and the error I get is
error: invalid initialization of reference of type ‘const ConstPtr& {aka const boost::shared_ptr<const calibration_camera_lidar::Euler_val_<std::allocator<void> > >&}’ from expression of type ‘const boost::shared_ptr<std_msgs::Float64_<std::allocator<void> > >’
The thing is I'm not quite sure how to call the callback2 function from another callback function. I'll be grateful if someone could help. Thanks in advance!