Skip to content

Commit ad56383

Browse files
authored
Remove last usage of date_time and replace it with std::chrono (PointCloudLibrary#5596)
* Remove last usage of date_time and replace it with std::chrono * Added new header with getTimestamp method. Added unit test to ensure it returns as expected, like boost format. Changed tools to use the new function. * Fix us printout. * Use frametime and not current time. * Minor doc correction. * Renaming. * Remove posix_time in additional files. Add parsing of string to time_point. Return timestamp in local timezone instead of UTC. rename from timestamp_generator to timestamp, since it can also parse now. * Add duration parse to microseconds, to get correct difference. * Doxygen Faster find using a char instead of string, per clang-tidy. * Remove last occurrences of date-time and only call pcl::getTimestamp once in openni_save_image.cpp. * Fix if check for position of dot in iso timestamp string. * Address reviews:�getTime returns time in seconds, don't multiply with 1000 in kinfu. Lowercase timestamp test in test/io/CMakeLists.txt Call getTimestamp once in openni_image.
1 parent 64ac461 commit ad56383

File tree

27 files changed

+297
-148
lines changed

27 files changed

+297
-148
lines changed

.dev/docker/env/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RUN apt-get update \
3030
clang-tidy \
3131
libbenchmark-dev \
3232
libblas-dev \
33-
libboost-date-time-dev \
33+
libboost-serialization-dev \
3434
libboost-filesystem-dev \
3535
libboost-iostreams-dev \
3636
libflann-dev \

.dev/docker/release/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN sed -i 's/^deb \(.*\)$/deb \1\ndeb-src \1/' /etc/apt/sources.list \
1515
dpkg-dev \
1616
git \
1717
g++ \
18-
libboost-date-time-dev \
18+
libboost-serialization-dev \
1919
libboost-filesystem-dev \
2020
libboost-iostreams-dev \
2121
libeigen3-dev \

.dev/docker/ubuntu-variety/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ENV DEBIAN_FRONTEND=noninteractive
1515
RUN apt update
1616
RUN apt install -y git cmake ${COMPILER_PACKAGE}
1717
RUN apt install -y libeigen3-dev libflann-dev
18-
RUN apt install -y libboost-filesystem-dev libboost-date-time-dev libboost-iostreams-dev
18+
RUN apt install -y libboost-filesystem-dev libboost-serialization-dev libboost-iostreams-dev
1919
RUN apt install -y libgtest-dev libbenchmark-dev
2020
RUN apt install -y qtbase5-dev libvtk${VTK_VERSION}-dev libvtk${VTK_VERSION}-qt-dev
2121

apps/src/openni_grab_frame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <pcl/console/print.h>
4141
#include <pcl/io/openni_grabber.h>
4242
#include <pcl/io/pcd_io.h>
43+
#include <pcl/io/timestamp.h>
4344
#include <pcl/visualization/pcl_visualizer.h>
4445
#include <pcl/point_cloud.h>
4546
#include <pcl/point_types.h>
@@ -157,8 +158,7 @@ class OpenNIGrabFrame {
157158
saveCloud()
158159
{
159160
FPS_CALC("I/O");
160-
const std::string time = boost::posix_time::to_iso_string(
161-
boost::posix_time::microsec_clock::local_time());
161+
const std::string time = pcl::getTimestamp();
162162
const std::string filepath = dir_name_ + '/' + file_name_ + '_' + time + ".pcd";
163163

164164
if (format_ & 1) {

apps/src/openni_grab_images.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ class OpenNIGrabFrame {
117117
void
118118
saveImages()
119119
{
120-
std::string time = boost::posix_time::to_iso_string(
121-
boost::posix_time::microsec_clock::local_time());
120+
const std::string time = pcl::getTimestamp();
122121
openni_wrapper::Image::Ptr image;
123122
openni_wrapper::DepthImage::Ptr depth_image;
124123

@@ -204,8 +203,7 @@ class OpenNIGrabFrame {
204203

205204
// wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
206205
while (!image_viewer_.wasStopped() && !quit_) {
207-
std::string time = boost::posix_time::to_iso_string(
208-
boost::posix_time::microsec_clock::local_time());
206+
const std::string time = pcl::getTimestamp();
209207
openni_wrapper::Image::Ptr image;
210208
openni_wrapper::DepthImage::Ptr depth_image;
211209

apps/src/openni_klt.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@
3939
#include <pcl/console/print.h>
4040
#include <pcl/io/openni_grabber.h>
4141
#include <pcl/io/pcd_io.h>
42+
#include <pcl/io/timestamp.h>
4243
#include <pcl/keypoints/harris_2d.h>
4344
#include <pcl/tracking/pyramidal_klt.h>
4445
#include <pcl/visualization/image_viewer.h>
4546

46-
#include <boost/date_time/posix_time/posix_time.hpp> // for to_iso_string, local_time
47-
4847
#include <mutex>
4948

5049
#define SHOW_FPS 1
@@ -175,9 +174,7 @@ class OpenNIViewer {
175174
if ((event.getKeyCode() == 's') || (event.getKeyCode() == 'S')) {
176175
std::lock_guard<std::mutex> lock(cloud_mutex_);
177176
frame.str("frame-");
178-
frame << boost::posix_time::to_iso_string(
179-
boost::posix_time::microsec_clock::local_time())
180-
<< ".pcd";
177+
frame << pcl::getTimestamp() << ".pcd";
181178
writer.writeBinaryCompressed(frame.str(), *cloud_);
182179
PCL_INFO("Written cloud %s.\n", frame.str().c_str());
183180
}

cmake/pcl_find_boost.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(Boost_SERIALIZATION_FOUND)
2626
endif()
2727

2828
# Required boost modules
29-
set(BOOST_REQUIRED_MODULES filesystem date_time iostreams system)
29+
set(BOOST_REQUIRED_MODULES filesystem iostreams system)
3030
find_package(Boost 1.65.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES})
3131

3232
if(Boost_FOUND)

cmake/pcl_pclconfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ foreach(_ss ${PCL_SUBSYSTEMS_MODULES})
7878
endforeach()
7979

8080
#Boost modules
81-
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem date_time iostreams")
81+
set(PCLCONFIG_AVAILABLE_BOOST_MODULES "system filesystem iostreams")
8282
if(Boost_SERIALIZATION_FOUND)
8383
string(APPEND PCLCONFIG_AVAILABLE_BOOST_MODULES " serialization")
8484
endif()

common/include/pcl/common/boost.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly."
4747
// Marking all Boost headers as system headers to remove warnings
4848
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
4949
#include <boost/mpl/size.hpp>
50-
#include <boost/date_time/posix_time/posix_time.hpp>
5150
#include <boost/signals2.hpp>
5251
#include <boost/signals2/slot.hpp>
5352
#include <boost/algorithm/string.hpp>

doc/tutorials/content/building_pcl.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -198,31 +198,31 @@ then a sample value is given for reference.
198198

199199
* Boost
200200

201-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
202-
| cache variable | meaning | sample value |
203-
+==================================+===============================================================+==========================================+
204-
| Boost_DATE_TIME_LIBRARY | full path to boost_date-time.[so,lib,a] | /usr/local/lib/libboost_date_time.so |
205-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
206-
| Boost_DATE_TIME_LIBRARY_DEBUG | full path to boost_date-time.[so,lib,a] (debug version) | /usr/local/lib/libboost_date_time-gd.so |
207-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
208-
| Boost_DATE_TIME_LIBRARY_RELEASE | full path to boost_date-time.[so,lib,a] (release version) | /usr/local/lib/libboost_date_time.so |
209-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
210-
| Boost_FILESYSTEM_LIBRARY | full path to boost_filesystem.[so,lib,a] | /usr/local/lib/libboost_filesystem.so |
211-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
212-
| Boost_FILESYSTEM_LIBRARY_DEBUG | full path to boost_filesystem.[so,lib,a] (debug version) | /usr/local/lib/libboost_filesystem-gd.so |
213-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
214-
| Boost_FILESYSTEM_LIBRARY_RELEASE | full path to boost_filesystem.[so,lib,a] (release version) | /usr/local/lib/libboost_filesystem.so |
215-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
216-
| Boost_INCLUDE_DIR | path to boost headers directory | /usr/local/include |
217-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
218-
| Boost_LIBRARY_DIRS | path to boost libraries directory | /usr/local/lib |
219-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
220-
| Boost_SYSTEM_LIBRARY | full path to boost_system.[so,lib,a] | /usr/local/lib/libboost_system.so |
221-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
222-
| Boost_SYSTEM_LIBRARY_DEBUG | full path to boost_system.[so,lib,a] (debug version) | /usr/local/lib/libboost_system-gd.so |
223-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
224-
| Boost_SYSTEM_LIBRARY_RELEASE | full path to boost_system.[so,lib,a] (release version) | /usr/local/lib/libboost_system.so |
225-
+----------------------------------+---------------------------------------------------------------+------------------------------------------+
201+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
202+
| cache variable | meaning | sample value |
203+
+=====================================+===============================================================+=============================================+
204+
| Boost_SERIALIZATION_LIBRARY | full path to boost_serialization.[so,lib,a] | /usr/local/lib/libboost_serialization.so |
205+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
206+
| Boost_SERIALIZATION_LIBRARY_DEBUG | full path to boost_serialization.[so,lib,a] (debug version) | /usr/local/lib/libboost_serialization-gd.so |
207+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
208+
| Boost_SERIALIZATION_LIBRARY_RELEASE | full path to boost_serialization.[so,lib,a] (release version) | /usr/local/lib/libboost_serialization.so |
209+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
210+
| Boost_FILESYSTEM_LIBRARY | full path to boost_filesystem.[so,lib,a] | /usr/local/lib/libboost_filesystem.so |
211+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
212+
| Boost_FILESYSTEM_LIBRARY_DEBUG | full path to boost_filesystem.[so,lib,a] (debug version) | /usr/local/lib/libboost_filesystem-gd.so |
213+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
214+
| Boost_FILESYSTEM_LIBRARY_RELEASE | full path to boost_filesystem.[so,lib,a] (release version) | /usr/local/lib/libboost_filesystem.so |
215+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
216+
| Boost_INCLUDE_DIR | path to boost headers directory | /usr/local/include |
217+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
218+
| Boost_LIBRARY_DIRS | path to boost libraries directory | /usr/local/lib |
219+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
220+
| Boost_SYSTEM_LIBRARY | full path to boost_system.[so,lib,a] | /usr/local/lib/libboost_system.so |
221+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
222+
| Boost_SYSTEM_LIBRARY_DEBUG | full path to boost_system.[so,lib,a] (debug version) | /usr/local/lib/libboost_system-gd.so |
223+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
224+
| Boost_SYSTEM_LIBRARY_RELEASE | full path to boost_system.[so,lib,a] (release version) | /usr/local/lib/libboost_system.so |
225+
+-------------------------------------+---------------------------------------------------------------+---------------------------------------------+
226226

227227

228228
* CMinpack

0 commit comments

Comments
 (0)