Ask Your Question

¿How can i get the exact date and hour of an event?

asked 2017-02-09 11:40:31 -0500

fhfonsecaa gravatar image

updated 2017-02-09 11:50:20 -0500

Hello guys, I'm having a problem with ROS Time, I need for a protect the exact Time and the exact Hour at which some event happened. I tried with ros time, but I don't see any equivalences between the double number 1486371808.656735126 and the Date and Hour Mon Feb 6 04:03:32 COT 2017.

Does anyone have suggestions?

Thank you very much

[ INFO] [1486371808.656553045]: Slot ID Bloque A - Casilla 2 with CHANGE
[ INFO] [1486371808.656735126]: The sensor in the slot Bloque A - Casilla 2 was ACTIVATED
rosrun sound_play 'La herramienta fue dejada'1.48637e+12
root@raspberrypi:/home/pi# date
lun feb  6 04:03:32 COT 2017

if( == true){
    ROS_INFO("The sensor in the slot %s was ACTIVATED",;
    double timeDouble = ros::WallTime::now().toSec()*1000.;
    std::ostringstream sstream;
    sstream << timeDouble;
    std::string timeString = sstream.str();
    string message = "rosrun sound_play 'La herramienta fue dejada'"+timeString;
    std::cout << message << std::endl;
    //system("rosrun sound_play 'La herramienta fue dejada'");
    //TODO definir hora de recepcion del usuario en la herramienta con getTimePointActivated
    ROS_INFO("The sensor in the slot %s is DEACTIVATED",;
    //system("rosrun sound_play 'The tool has been taken'");
    //TODO definir hora de entrega al usuario en la herramienta con getTimePointActivated
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-02-09 13:22:44 -0500

Bill Smart gravatar image

The time is in Unix time, seconds since 1970. You can transform it to a more readable format with the functions in <ctime> for C++ or the time module in Python.

edit flag offensive delete link more


Thank you very much, <ctime> worked perfectly.

fhfonsecaa gravatar image fhfonsecaa  ( 2017-02-09 20:56:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-09 11:40:31 -0500

Seen: 264 times

Last updated: Feb 09 '17