Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Cant publish a time object

I am trying to publish the current wallclock time but some how during the build process it always gives an error : Const Class ros::Time does not have any member named getMD5su

Here is the code :

ros::NodeHandle n;

ros::Publisher sum_publisher = n.advertise<ros::Time>("sum", 1000);

std::cout<<ros::XMLRPCManager::instance()->getServerURI()<<std::endl;

ros::Rate loop_rate(1);
int a = 0;
int count = 0;
while (ros::ok()){

            ros::Time currentTime;
            currentTime = ros::Time::now();

            sum_publisher.publish(currentTime);

            ros::spinOnce();
            loop_rate.sleep();
            }

I guess i should be advertising std_msgs::Time instead of ros::Time but it is not getting resolved. I already have included ros/time.h

Cant publish a time object

I am trying to publish the current wallclock time but some how during the build process it always gives an error : Const Class ros::Time does not have any member named getMD5su

Here is the code :

#include "ros/xmlrpc_manager.h"  
#include  "std_msgs/Float32.h"  
#include "std_msgs/String.h"  
#include "std_msgs/Time.h"  
#include "ros/time.h"
#include "time.h"  
#include "sstream"           
using namespace std;
int main(int argc, char **argv){

ros::init(argc, argv, "talker");

ros::NodeHandle n;

n;


ros::Publisher sum_publisher = n.advertise<ros::Time>("sum", n.advertise<std_msgs::Time>("sum", 1000);

std::cout<<ros::XMLRPCManager::instance()->getServerURI()<<std::endl;

ros::Rate loop_rate(1);
int a = 0;
int count = 0;
while (ros::ok()){

            ros::Time currentTime;
            currentTime std_msgs::Time msg;

            msg.data = ros::Time::now();

            sum_publisher.publish(currentTime);
sum_publisher.publish(msg);

            ros::spinOnce();
            loop_rate.sleep();
 
            //++count;

}

return 0;

}

I guess i should be advertising std_msgs::Time instead of ros::Time but it is not getting resolved. I already have included ros/time.h