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

ROSCONSOLE_FORMAT time zone

asked 2022-02-08 09:22:41 -0600

thebyohazard gravatar image

updated 2022-02-15 12:26:17 -0600

I am using the new feature as of noetic in rosconsole where you can format the time according to strftime formats.

export ROSCONSOLE_FORMAT='${time:%r}[${severity}] ${node}: ${message}'

I am wondering how to properly set the time zone so that the messages display times in my local time zone.

When I run the command date, the times do show in my time zone.

I am running Noetic on Ubuntu 20.04.3

edit: There's a ticket for this.

edit retag flag offensive close merge delete

Comments

Listening in here, also interested in solutions. With a ROSCONSOLE_FORMAT definition like yours, my experiments show that python nodes will log with local time and c++ nodes will log with UTC, which makes things even more confusing. And the %z and %Z format options do not seem to be supported.

knxa gravatar image knxa  ( 2022-02-10 03:30:40 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-02-22 10:23:17 -0600

thebyohazard gravatar image

I'm not sure it's possible as it's written. The code in question imbues a stringstream with the C locale:

boost::posix_time::time_facet *facet = new boost::posix_time::time_facet();
facet->format(format_.c_str());
ss.imbue(std::locale(std::locale::classic(), facet));
ss << ros::WallTime::now().toBoost();

The interwebs seems to say that the time zone isn't really a part of the locale. But it might be on some systems; it kinda just depends on the implementation. So on some systems %z and %Z might work, but they do not on mine.

One of the answers in the above question points to std::chrono::time_zone as being a possibility in the c++20 spec. Then there are some boost solutions here. Also, this thread lists a few ways to do it, but it seems to be a semi-complicated problem and hard to make portable.

So as far as some kind of system configuration setting to just make it work without rewriting code, it probably doesn't exist : (

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2022-02-08 09:22:41 -0600

Seen: 382 times

Last updated: Feb 22 '22