ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Did you tried including #include <std_msgs/Time.h> ?

Also, dont mix ros::Time which is a class to represent Time in a ROS context and std_msgs::Time Which is a Time message that you can publish/subscribe.

Did you tried including #include <std_msgs/Time.h> ?

Also, dont mix ros::Time which is a class to represent Time in a ROS context and std_msgs::Time Which is a Time message that you can publish/subscribe.

Edit : Small example :

#include <ros/ros.h>
#include <ros/time.h>
#include <std_msgs/Time.h>

int main(int argc, char **argv)
{
  ros::init(argc, argv, "time_publisher");
  ros::NodeHandle nh;
  std_msgs::Time msg;
  ros::Publisher time_publisher = nh.advertise<std_msgs::Time>("time", 1000);

  while (ros::ok()){

    msg.data = ros::Time::now();
    time_publisher .publish(msg);
  }
 }