clynamen / nuscenes2bag

nuScenes dataset to rosbag format
136 stars 33 forks source link

Compile on Ubuntu 16.04, 18.04 #4

Open ChernoA opened 4 years ago

ChernoA commented 4 years ago

Thanks for making this useful tool. Unfortunately I am stuck using an older version of ROS.

I forked the code and modified it to compile on Ubuntu 16.04 or 18.04 using only the standard version of libraries that came with that distribution. I also added an alternative implementation of a thread pool, and the option to publish the 5th data field "ring" from the laser sensor.

Ubuntu 16.04 (ROS Kinetic Kame) Branch: ubuntu_1604
Ubuntu 18.04 (ROS Melodic Morenia) Branch: ubuntu_1604
Ubuntu 19+ Branch: master

I tested it on those two distributions only. I don't have any other linux to try.

The backported code uses precompiler logic that switches based on the detected library versions.
For example:

#if CMAKE_CXX_STANDARD >= 17
  std::optional<SceneInfo> getSceneInfo()
#else
  boost::shared_ptr<SceneInfo> getSceneInfo()
#endif

which means that the code is more messy, but this saves trying to maintain two very different branches.

The code in NuScenes2Bag.cpp uses a thread pool from Boost 1.66 so I found another implementation.

Functionality used Requires
std::unique_ptr C++14
std::filesystem C++17, CMake 3.8+
std::optional C++17, CMake 3.8+
boost::asio::thread_pool Boost 1.66.00
Distribution Packaged libraries
Ubuntu 16.04 CMake 3.5.1, Boost 1.58.00
Ubuntu 18.04 CMake 3.10.2, Boost 1.65.00
Ubuntu 19.04 CMake 3.13.4, Boost 1.67.00
anshulpaigwar commented 4 years ago

While compiling ubuntu_1604 I am getting an error in file SceneConverter.cpp

SceneConverter.cpp:114:20: error: no match for ‘operator!=’ (operand types are ‘nuscenes2bag::SceneInfo’ and ‘std::nullptr_t’)
   assert(sceneInfo != nullptr);

I am unable to understand the reason behind it. Seems like an error with boost::shared_ptr cannot be compared with nullptr.

Which boost version and GCC version you are using??

clynamen commented 4 years ago

Please, try to use https://github.com/clynamen/nuscenes2bag/pull/2

Unfortunately, I had not the chance to merge it yet.

anshulpaigwar commented 4 years ago

Sorry I forgot to tag @ChernoA I used his fork to compile on my system with ubuntu 16.04 and boost 1.58 and get this error.

ChernoA commented 4 years ago

Hello @anshulpaigwar

Yes that was a bug, a silly mistake :-)
I fixed it and updated my fork.
http://github.com/ChernoA/nuscenes2bag

There was a mistake in this line:
assert(sceneInfo != nullptr)
You saw a compilation error because when you compile the code in debug mode, the compiler tests the asserts.
However if you compile the code in release mode, that line with the assert is ignored by the compiler.

clynamen commented 4 years ago

Hello @ChernoA

I have eventually selected two version: master and ubuntu_16.04. The master branch works fine on ubuntu 18.04 and newer. The two github actions will check that the code compile succesfully.

I have downgraded the code to C++14, since there was no big advantage in using C++17. Do you think this setup is good?