using time_synchronizer to combine the force and position data from different sensor
Hi everyone, I try to use the time_synchronizer to get the force and position data from a force sensor and NDI, the code is show here which imitated from #q297174:
#include "ros/ros.h"
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <geometry_msgs/Wrench.h>
#include <geometry_msgs/PoseArray.h>
#include "std_msgs/Float64.h"
void callback(const geometry_msgs::WrenchConstPtr& netft_data, const geometry_msgs::PoseArrayConstPtr& targets)
{
static tf2_ros::TransformBroadcaster tf2_broadcaster;
geometry_msgs::TransformStamped transformStamped;
transformStamped.header.stamp = ros::Time::now();
transformStamped.header.frame_id = "ts_frame";
transformStamped.child_frame_id = "prism_frame";
transformStamped.transform.translation.x = targets->poses[0].position.x;
transformStamped.transform.translation.y = targets->poses[0].position.y;
transformStamped.transform.translation.z = targets->poses[0].position.z;
tf2::Quaternion q;
transformStamped.transform.rotation.x = netft_data->force.x;
transformStamped.transform.rotation.y = netft_data->force.y;
transformStamped.transform.rotation.z = netft_data->force.z;
transformStamped.transform.rotation.w = targets->poses[0].orientation.w;
tf2_broadcaster.sendTransform(transformStamped);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "get_all_sensor_in_one");
ros::NodeHandle nh;
message_filters::Subscriber<geometry_msgs::Wrench> force_sub(nh, "/netft_data", 1);
message_filters::Subscriber<geometry_msgs::PoseArray> pose_sub(nh, "/targets", 1);
message_filters::TimeSynchronizer<geometry_msgs::Wrench, geometry_msgs::PoseArray> sync(force_sub, pose_sub, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}
what i do is just change the topic and the type of argument, but it is wrong somewhere. I'm pretty new of this, so can you help me??
error:
In file included from /opt/ros/indigo/include/message_filters/time_synchronizer.h:39:0,
from /home/edward/kuka_catkin/src/iiwa_stack-master-Sunrise1.9/iiwa_ros/src/topic_synchronizer/get_all_sensor_in_one.cpp:8:
/opt/ros/indigo/include/message_filters/sync_policies/exact_time.h: In instantiation of ‘void message_filters::sync_policies::ExactTime<M0, M1, M2, M3, M4, M5, M6, M7, M8>::add(const typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type&) [with int i = 0; M0 = geometry_msgs::Wrench_<std::allocator<void> >; M1 = geometry_msgs::PoseArray_<std::allocator<void> >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType; typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type = ros::MessageEvent<const geometry_msgs::Wrench_<std::allocator<void> > >]’:
/opt/ros/indigo/include/message_filters/synchronizer.h:358:5: required from ‘void message_filters::Synchronizer<Policy>::cb(const typename boost::mpl::at_c<typename Policy::Events, i>::type&) [with int i = 0; Policy = message_filters::sync_policies::ExactTime<geometry_msgs::Wrench_<std::allocator<void> >, geometry_msgs::PoseArray_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>; typename boost::mpl::at_c<typename Policy::Events, i>::type = ros::MessageEvent<const geometry_msgs::Wrench_<std::allocator<void> > >]’
/opt/ros/indigo/include/message_filters/synchronizer.h:290:138: required from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&) [with F0 = message_filters::Subscriber<geometry_msgs::Wrench_<std::allocator<void> > >; F1 = message_filters::Subscriber<geometry_msgs ...