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

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

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

fhfonsecaa gravatar image

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

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 say.py 'La herramienta fue dejada'1.48637e+12
root@raspberrypi:/home/pi# date
lun feb  6 04:03:32 COT 2017
root@raspberrypi:/home/pi#

if(m_Slots.at(c).getState() == true){
    ROS_INFO("The sensor in the slot %s was ACTIVATED", m_Slots.at(c).getID().c_str());
    double timeDouble = ros::WallTime::now().toSec()*1000.;
    std::ostringstream sstream;
    sstream << timeDouble;
    std::string timeString = sstream.str();
    string message = "rosrun sound_play say.py 'La herramienta fue dejada'"+timeString;
    std::cout << message << std::endl;
    //system("rosrun sound_play say.py 'La herramienta fue dejada'");
    //TODO definir hora de recepcion del usuario en la herramienta con getTimePointActivated
}else{
    ROS_INFO("The sensor in the slot %s is DEACTIVATED", m_Slots.at(c).getID().c_str());
    //system("rosrun sound_play say.py '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
2

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

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

Comments

Thank you very much, <ctime> worked perfectly.

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

Question Tools

1 follower

Stats

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

Seen: 441 times

Last updated: Feb 09 '17