Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Cartographer without ROS #1229

Closed
SubMishMar opened this issue Jul 2, 2018 · 14 comments
Closed

Using Cartographer without ROS #1229

SubMishMar opened this issue Jul 2, 2018 · 14 comments

Comments

@SubMishMar
Copy link

Is there any tutorial or API available where once can use the cartographer standalone library without using the ROS interface?

@ojura
Copy link
Contributor

ojura commented Jul 3, 2018

My approach to this is to use cartographer_ros without ros :) I yanked out into a separate library some ROS headers and a small subset of roscpp (rosbag and tf buffers) which is enough to build cartographer_ros. It even works on windows. I can share it if there's any interest.

@SubMishMar
Copy link
Author

That sounds cool! Please share @ojura !! Thanks :)

@ojura
Copy link
Contributor

ojura commented Jul 3, 2018

https://github.com/larics/cartographer_superbuild/tree/ros_stub

You should be able to build the offline node by calling

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make cartographer_offline_node -j8

Afterwards you can use the offline node to process ros bags. Do not source /opt/ros/setup.bash, it should be self-contained.

@SubMishMar
Copy link
Author

SubMishMar commented Jul 3, 2018

@ojura Thanks for the reply and I am going to look into this today. But could you please tell me briefly what is the basic difference between cartographer_ros and the repository you have provided here?

@SubMishMar
Copy link
Author

Here are some more queries:

  1. Do I still need ROS on my system to run this?
  2. Do I need to provide data as ros topics?

@SubMishMar
Copy link
Author

SubMishMar commented Jul 3, 2018

My cmake fails even though I have google-mock in my system.

-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "FindGMock.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "GMock", but
  CMake did not find one.

  Could not find a package configuration file provided by "GMock" with any of
  the following names:

    GMockConfig.cmake
    gmock-config.cmake

  Add the installation prefix of "GMock" to CMAKE_PREFIX_PATH or set
  "GMock_DIR" to a directory containing one of the above files.  If "GMock"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/perceptin/github-projects/cartographer_superbuild/build/CMakeFiles/CMakeOutput.log".

@ojura
Copy link
Contributor

ojura commented Jul 4, 2018

  1. You do not need to have ROS installed.

  2. You can use the cartographer offline node as a template. In your code you can call instantiate a cartographer node and call its Handle<Sensor> methods. You pass the data as ROS sensor messages, the headers for them are included in ros_stub.

    The offline node itself should be functional, i.e. it can process ROS bags and output .pbstreams. It cannot publish or subscribe to messages, the network functionality in ROS has all been replaced with noop functions.

Building on a clean Ubuntu 18.04 install:

sudo add-apt-repository universe
sudo apt update
sudo apt install git cmake bzip2 libbz2-dev libceres-dev libprotobuf-dev protobuf-compiler libpcl-dev liburdfdom-headers-dev liburdfdom-model liblz4-dev libtinyxml-dev liburdfdom-dev
git clone https://github.com/larics/cartographer_superbuild --branch ros_stub
./cartographer_superbuild/cartographer/scripts/install_debs_cmake.sh 
cd cartographer_superbuild
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make cartographer_offline_node -j8

cartographer and cartographer_ros folders contain unchanged code from current upstream. However, updating cartographer_ros might need new cartographer_ros_msgs message headers in ros_stub, have a look at the readme for more details.

@SubMishMar
Copy link
Author

Thanks @ojura

@aziesemer
Copy link

aziesemer commented Jul 18, 2018

I was able to compile it on my Mac installing similar packages to the ones from Ubuntu using brew.
However, using Clang it gives me some warnings during compilation and fails in some of the test cases. GCC (I installed using brew and added "SET(CMAKE_CXX_COMPILER /usr/local/Cellar/gcc/8.1.0/bin/g++-8)" to CMakeLists.txt) gives me no warning but fails to link.

I'm now trying to make it run with Clang, I created a small program to test it but I don't know yet how to display the map on the screen. Any idea?

@ojura
Copy link
Contributor

ojura commented Jul 19, 2018

Check out the occupancy grid node in cartographer_ros and how it constructs the map. Normally it publishes it as a message - you can try adapting it to display it on the screen instread.

@ZhiyuLiu1993
Copy link

@ojura Hello!I don't know how to get the trajectory without ROS,I cross-compiled the cartographer on the arm,Can you give some advice?

@ojura
Copy link
Contributor

ojura commented Nov 20, 2018

In node.cc, see calling map_builder_bridge_.GetTrajectoryNodeList()).

Or if you have a .pbstream from calling map_builder_bridge_.SerializeState, see https://gist.github.com/ojura/85507cd6c8be419357305b30d9bb949d

@ZhiyuLiu1993
Copy link

Thank you, I will try it.

@klintan
Copy link

klintan commented Oct 7, 2019

My cmake fails even though I have google-mock in my system.

-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "FindGMock.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "GMock", but
  CMake did not find one.

  Could not find a package configuration file provided by "GMock" with any of
  the following names:

    GMockConfig.cmake
    gmock-config.cmake

  Add the installation prefix of "GMock" to CMAKE_PREFIX_PATH or set
  "GMock_DIR" to a directory containing one of the above files.  If "GMock"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/perceptin/github-projects/cartographer_superbuild/build/CMakeFiles/CMakeOutput.log".

I had this issue as well I solved it by:

  1. Install googletest library using instructions on their github. (cmake, make, make install)
  2. In the CMakelists.txt file change line 250 from
    target_link_libraries(${TEST_LIB} PUBLIC ${GMOCK_LIBRARY}) --> to target_link_libraries(${TEST_LIB} PUBLIC gmock gtest)

This variables GMOCK_LIBRARY is empty, and I can't find where it would be set, however GMOCK_LIBRARIES are set, but couldn't get that to work.

You might need to add

find_packages(gmock REQUIRED)
find_packages(gtest REQUIRED)

But it shouldn't be necessary, since gmock contains gtest and the find_packages(gmock) is already in the functions file referenced in the cmakelists file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants