Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Trying to write test pgm for TimeSync

Trying to write test pgm for TimeSync but why does it not support std_msgs:String.

/opt/ros/hydro/include/message_filters/sync_policies/exact_time.h:126:102: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::String_<std::allocator<void> >, void>’

This compile error is generated by the following code:

#include <string>
#include <ros/ros.h>
#include <std_msgs/String.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>


using namespace message_filters;

class SynchronizerTest
{
public:
  SynchronizerTest()
  {
    setTest();
  }


void handelerSynchronizerTest(std_msgs::StringConstPtr& msg1, std_msgs::StringConstPtr& msg2)
{
    ROS_INFO("HERE made it to handeler");
}

void setTest()
{
     Subscriber<std_msgs::String> j1_sub(n, "/SynchronizerTest1", 10);
     Subscriber<std_msgs::String> j2_sub(n, "/SynchronizerTest2", 10);
     TimeSynchronizer<std_msgs::String, std_msgs::String> sync(j1_sub, j2_sub, 10);
     sync.registerCallback(boost::bind(&SynchronizerTest::handelerSynchronizerTest, this, _1, _2));
     ROS_INFO("Test set");
}


private:

 ros::NodeHandle n;

};  // Enodof Class



int main(int argc, char **argv)
{ 
  ros::init(argc, argv, "SynchronizerTest");
  ros::NodeHandle n;
  ros::Rate loop_rate(10);
  int count = 0;

  SynchronizerTest sp;
  ros::Publisher pub1 = n.advertise<std_msgs::String>("SynchronizerTest1", 10);
  ros::Publisher pub2 = n.advertise<std_msgs::String>("SynchronizerTest2", 10);
  while (ros::ok())
  {
     std_msgs::String msg;
     std::stringstream ss;
     ss << "hello world " << count;
     msg.data = ss.str();
     pub1.publish(msg);
     pub2.publish(msg);
     ros::spinOnce();
     loop_rate.sleep();
     ++count;
  }

  return 0;
}

Trying to write test pgm for TimeSync

Update: changed code according to ans. Still will not compile.

#include <string>
#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>


using namespace message_filters;

class SynchronizerTest
{
public:
  SynchronizerTest()
  {
    setTest();
  }


void handelerSynchronizerTest(geometry_msgs::PoseStampedConstPtr& msg1, geometry_msgs::PoseStampedConstPtr& msg2)
{
    ROS_INFO("HERE made it to handeler");
}

void setTest()
{
     Subscriber<geometry_msgs::PoseStamped> j1_sub(n, "/SynchronizerTest1", 10);
     Subscriber<geometry_msgs::PoseStamped> j2_sub(n, "/SynchronizerTest2", 10);
     TimeSynchronizer<geometry_msgs::PoseStamped, geometry_msgs::PoseStamped> sync(j1_sub, j2_sub, 10);
     sync.registerCallback(boost::bind(&SynchronizerTest::handelerSynchronizerTest, this, _1, _2));
     ROS_INFO("Test set");
}


private:

 ros::NodeHandle n;

};  // Enodof Class



int main(int argc, char **argv)
{ 
  ros::init(argc, argv, "SynchronizerTest");
  ros::NodeHandle n;
  ros::Rate loop_rate(10);
  int count = 0;

  SynchronizerTest sp;
  ros::Publisher pub1 = n.advertise<geometry_msgs::PoseStamped>("SynchronizerTest1", 10);
  ros::Publisher pub2 = n.advertise<geometry_msgs::PoseStamped>("SynchronizerTest2", 10);
  while (ros::ok())
  {
     geometry_msgs::PoseStamped msg;     
     msg.header.stamp = ros::time::now();
     pub1.publish(msg);
     pub2.publish(msg);
     ros::spinOnce();
     loop_rate.sleep();
     ++count;
  }

  return 0;
}

Trying to write test pgm for TimeSync but why does it not support std_msgs:String.

/opt/ros/hydro/include/message_filters/sync_policies/exact_time.h:126:102: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::String_<std::allocator<void> >, void>’

This compile error is generated by the following code:

#include <string>
#include <ros/ros.h>
#include <std_msgs/String.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>


using namespace message_filters;

class SynchronizerTest
{
public:
  SynchronizerTest()
  {
    setTest();
  }


void handelerSynchronizerTest(std_msgs::StringConstPtr& msg1, std_msgs::StringConstPtr& msg2)
{
    ROS_INFO("HERE made it to handeler");
}

void setTest()
{
     Subscriber<std_msgs::String> j1_sub(n, "/SynchronizerTest1", 10);
     Subscriber<std_msgs::String> j2_sub(n, "/SynchronizerTest2", 10);
     TimeSynchronizer<std_msgs::String, std_msgs::String> sync(j1_sub, j2_sub, 10);
     sync.registerCallback(boost::bind(&SynchronizerTest::handelerSynchronizerTest, this, _1, _2));
     ROS_INFO("Test set");
}


private:

 ros::NodeHandle n;

};  // Enodof Class



int main(int argc, char **argv)
{ 
  ros::init(argc, argv, "SynchronizerTest");
  ros::NodeHandle n;
  ros::Rate loop_rate(10);
  int count = 0;

  SynchronizerTest sp;
  ros::Publisher pub1 = n.advertise<std_msgs::String>("SynchronizerTest1", 10);
  ros::Publisher pub2 = n.advertise<std_msgs::String>("SynchronizerTest2", 10);
  while (ros::ok())
  {
     std_msgs::String msg;
     std::stringstream ss;
     ss << "hello world " << count;
     msg.data = ss.str();
     pub1.publish(msg);
     pub2.publish(msg);
     ros::spinOnce();
     loop_rate.sleep();
     ++count;
  }

  return 0;
}