rakeshshrestha31 / map_prediction_enhanced_exploration

Open-source modules for ICRA 2019 submission "Learned Map Prediction for Enhanced Mobile Robot Exploration"
20 stars 7 forks source link

Can't catkin_make #1

Open lericson opened 4 years ago

lericson commented 4 years ago

Hi, it seems the Hector planner stuff is using the pre-catkin ROS build system, so catkin_make or catkin build does not work. Here is the output.

-- +++ processing catkin package: 'stage_frontier_datagen'
-- ==> add_subdirectory(stage_frontier_datagen)
-- Using these message generators: gencpp;genlisp;genpy
CMake Warning at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
  Could not find a package configuration file provided by
  "hector_exploration_planner" with any of the following names:

    hector_exploration_plannerConfig.cmake
    hector_exploration_planner-config.cmake

  Add the installation prefix of "hector_exploration_planner" to
  CMAKE_PREFIX_PATH or set "hector_exploration_planner_DIR" to a directory
  containing one of the above files.  If "hector_exploration_planner"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  stage_frontier_datagen/CMakeLists.txt:10 (find_package)

-- Could not find the required component 'hector_exploration_planner'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by
  "hector_exploration_planner" with any of the following names:

    hector_exploration_plannerConfig.cmake
    hector_exploration_planner-config.cmake

  Add the installation prefix of "hector_exploration_planner" to
  CMAKE_PREFIX_PATH or set "hector_exploration_planner_DIR" to a directory
  containing one of the above files.  If "hector_exploration_planner"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  stage_frontier_datagen/CMakeLists.txt:10 (find_package)

-- Configuring incomplete, errors occurred!

Catkin doesn't find the packages, as is evident. I will prod at this for a while but was hoping you'd know how to solve this.

Sincerely

lericson commented 4 years ago

I managed to get hector_exploration_planner to build with rosmake, trying to figure out how to get catkin_make to actually find it.

lericson commented 4 years ago

It is not possible to migrate a rosbuild package to catkin before all the ROS packages it depends on have equally been migrated to catkin.

http://wiki.ros.org/catkin/Tutorials/using_rosbuild_with_catkin

Seems to me that this is not possible?

lericson commented 4 years ago

I have now made these packages build with Catkin, and it seems a file is missing, hector_exploration_planner/custom_costmap_2d_ros.h?

lericson commented 4 years ago

Ah, turns out I had missed your updates. Seems you did the same. I will publish a Docker image when this eventually works, makes reproducing it a lot easier.

lericson commented 4 years ago

Changes I had to make to build:

hector_planning

diff --git a/hector_exploration_planner/CMakeLists.txt b/hector_exploration_planner/CMakeLists.txt
index c64ead9..aa98e84 100644
--- a/hector_exploration_planner/CMakeLists.txt
+++ b/hector_exploration_planner/CMakeLists.txt
@@ -1,6 +1,8 @@
 cmake_minimum_required(VERSION 2.8.3)
 project(hector_exploration_planner)

+add_compile_options(-std=c++11)
+
 ## Find catkin macros and libraries
 ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
 ## is used, also find other catkin packages
diff --git a/hector_exploration_planner/include/hector_exploration_planner/info_gain_client.h b/hector_exploration_planner/include/hector_exploration_planner/info_gain_client.h
index 8bed0b9..eb11140 100644
--- a/hector_exploration_planner/include/hector_exploration_planner/info_gain_client.h
+++ b/hector_exploration_planner/include/hector_exploration_planner/info_gain_client.h
@@ -15,7 +15,7 @@
 #include <geometry_msgs/PoseStamped.h>
 #include <sensor_msgs/Image.h>

-#include <opencv2/core.hpp>
+#include <opencv2/core/core.hpp>

 #include <hector_exploration_planner/custom_costmap_2d_ros.h>
 #include <hector_exploration_planner/frontier_analysis.h>
diff --git a/hector_exploration_planner/src/hector_exploration_planner.cpp b/hector_exploration_planner/src/hector_exploration_planner.cpp
index 9c49be2..51ded61 100644
--- a/hector_exploration_planner/src/hector_exploration_planner.cpp
+++ b/hector_exploration_planner/src/hector_exploration_planner.cpp
@@ -959,8 +959,8 @@ bool HectorExplorationPlanner::clusterFrontiers(const std::vector<int>& all_fron
     return false;

   const int FRONTIER_VALUE = -1;
-  int frontier_cluster_map[num_map_cells_] = {0};
-  //boost::scoped_array<int> frontier_cluster_map(new int[num_map_cells_]);
+  //int frontier_cluster_map[num_map_cells_] {0};
+  boost::scoped_array<int> frontier_cluster_map(new int[num_map_cells_]);

   // set all frontiers points value as -1 in frontier_cluster_map
   for(int i = 0; i < all_frontiers.size(); i++)

ground_truth_layer

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0355dd0..1c57d36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3)
 project(ground_truth_layer)

 ## Compile as C++11, supported in ROS Kinetic and newer
-add_compile_options(-std=c++14)
+add_compile_options(-std=c++11)

 ## openmp support
 find_package(OpenMP)
@@ -28,7 +28,7 @@ find_package(catkin REQUIRED COMPONENTS
 ## System dependencies are found with CMake's conventions
 find_package(Boost REQUIRED COMPONENTS system thread)
 # find_package(stage 4.3 REQUIRED)
-find_package(OpenCV 3)
+find_package(OpenCV)

 ## Uncomment this if the package has a setup.py. This macro ensures

stage_frontier_datagen

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb22d74..c7e18bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3)
 project(stage_frontier_datagen)

 ## Compile as C++11, supported in ROS Kinetic and newer
-add_compile_options(-std=c++14)
+add_compile_options(-std=c++11)

 ## Find catkin macros and libraries
 ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
@@ -36,7 +36,9 @@ link_directories(${LIB_FLOORPLAN_DIR}/output)
 find_package(stage 4.3 REQUIRED)

 find_package(OpenCV) #  2.4)
-find_package(jsoncpp REQUIRED)
+find_package(PkgConfig)
+pkg_check_modules(JSONCPP REQUIRED jsoncpp)
+#find_package(jsoncpp REQUIRED)

 ## Uncomment this if the package has a setup.py. This macro ensures
diff --git a/src/kth_stage_node.cpp b/src/kth_stage_node.cpp
index 00f752f..6223a88 100644
--- a/src/kth_stage_node.cpp
+++ b/src/kth_stage_node.cpp
@@ -48,6 +48,10 @@

 #include <opencv2/imgproc/imgproc.hpp>

+namespace cv {
+  typedef Size_<double> Size2d;
+}
+
 using namespace stage_frontier_datagen;
 using namespace hector_exploration_planner;

libfloorplan

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d77f573..2cf0958 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,13 @@
 cmake_minimum_required(VERSION 2.8)
 Project(LibFloorPlan)

-add_compile_options("-std=c++14")
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)

 get_filename_component(PROJECT_ROOT . ABSOLUTE)
 # You can prepare verbose Makefile to see what's going.
-set(CMAKE_VERBOSE_MAKEFILE false)
+# set(CMAKE_VERBOSE_MAKEFILE false)
 # Set build type
 # set(CMAKE_BUILD_TYPE Debug)

diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index eb0523d..7e09e4c 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -1,5 +1,4 @@

-
 include_directories(/usr/include/boost)
 find_package(Boost COMPONENTS graph serialization REQUIRED)

diff --git a/src/lib/FloorPlanGraph.hpp b/src/lib/FloorPlanGraph.hpp
index 01ee201..cdc7c9b 100644
--- a/src/lib/FloorPlanGraph.hpp
+++ b/src/lib/FloorPlanGraph.hpp
@@ -126,7 +126,7 @@ public:
         extent = std::accumulate(
             roomLayout.begin(), roomLayout.end(),
             extent,
-            [](auto &extent, const auto &segment) {
+            [](std::array<double, 4> &extent, const LineSegment &segment) {
                 double current_min_x = std::min(segment.startPos.x, segment.endPos.x);
                 double current_min_y = std::min(segment.startPos.y, segment.endPos.y);
                 double current_max_x = std::max(segment.startPos.x, segment.endPos.x);
diff --git a/src/lib/GraphDatabase.cpp b/src/lib/GraphDatabase.cpp
index 639aad5..5f6d1a3 100644
--- a/src/lib/GraphDatabase.cpp
+++ b/src/lib/GraphDatabase.cpp
@@ -8,6 +8,7 @@
 #include "GraphUtils.hpp"

 #include <boost/serialization/list.hpp>
+#include <boost/serialization/array.hpp>
 #include <boost/serialization/vector.hpp>
 #include <boost/serialization/map.hpp>
 #include <boost/serialization/set.hpp>
diff --git a/src/lib/GraphDatabase.hpp b/src/lib/GraphDatabase.hpp
index 6e88eeb..6f05233 100644
--- a/src/lib/GraphDatabase.hpp
+++ b/src/lib/GraphDatabase.hpp
@@ -11,6 +11,7 @@

 #include <fstream>
+#include <array>

 #ifndef GRAPHDATABASE_HPP
 #define GRAPHDATABASE_HPP
lericson commented 4 years ago

Here is the Dockerfile that actually builds

FROM ros:indigo

RUN apt-get update

# Cannot use OpenCV 3.x because ROS is built against OpenCV 2, which cannot be
# installed simultaneously as 3.x.
#RUN apt-get install -y software-properties-common && \
#    add-apt-repository -y ppa:amarburg/opencv3
#RUN apt-get update

# Miscellaneous dependencies
RUN apt-get install -y build-essential fltk1.1-dev libjpeg8-dev libpng12-dev \
      libglu1-mesa-dev libltdl-dev libopencv-dev python-catkin-tools \
      libjsoncpp-dev ros-indigo-urdf libceres-dev ros-indigo-orocos-kdl \
      ros-indigo-tf2-geometry-msgs ros-indigo-image-transport \
      ros-indigo-tf2-eigen ros-indigo-costmap-2d ros-indigo-nav-core \
      ros-indigo-cv-bridge ros-indigo-hector-map-tools \
      ros-indigo-hector-nav-msgs ros-indigo-geodesy

# Need CMake 3.x for some things, but cannot install because again ROS is built
# with the system default CMake install.
RUN mkdir /cmake3 && curl -q "https://cmake.org/files/v3.15/cmake-3.15.3-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /cmake3

# Copy the code and build it
COPY Stage /ws/src/map_prediction/Stage
COPY libfloorplan /ws/src/map_prediction/libfloorplan
COPY path-smoothing-ros /ws/src/map_prediction/path-smoothing-ros
COPY ground_truth_layer /ws/src/map_prediction/ground_truth_layer
COPY hector_navigation /ws/src/map_prediction/hector_navigation
COPY online_map_completion /ws/src/map_prediction/online_map_completion
COPY online_map_completion_msgs /ws/src/map_prediction/online_map_completion_msgs
COPY stage_frontier_datagen /ws/src/map_prediction/stage_frontier_datagen

WORKDIR /ws/src/map_prediction
COPY build.sh .
RUN /ros_entrypoint.sh ./build.sh

With the build script build.sh as follows

#!/bin/bash

silsource() {
    set +xe
    source "$@" || exit
    set -xe
}

set -xe

cd Stage
mkdir build
cd build
/cmake3/bin/cmake ..
make -j4
make install
cd ../..

cd libfloorplan
mkdir build
cd build
/cmake3/bin/cmake ..
make -j4
make install
cd ../..

silsource /opt/ros/indigo/setup.bash
export LIB_FLOORPLAN_PATH=$PWD/libfloorplan
cd /ws
catkin init
catkin build stage_frontier_datagen
lericson commented 4 years ago

I pushed it to Docker hub, you can pull it with docker pull lericson/experiments:map_exploration!

lericson commented 4 years ago

I suggest putting this information in a Wiki page or something, building this software takes a lot of poking about.

w0617 commented 4 years ago

@lericson Hi, I catkin_make successfully, but don't know how to run these ros pakages, would you give some help?

lericson commented 4 years ago

I can publish a newer build with instructions in the coming week. If you enter a shell, it should be in the bash history!

My new build has OpenGL and all working on NVIDIA cards

w0617 commented 4 years ago

Looking forward to your new version!

wecacuee commented 4 years ago

@lericson Were you able to run this code out of the box? I tried running it on bionic/melodic and I had to migrate tf to tf2 because costmap_2d uses tf2 while hectormap uses tf. You can checkout my forks of the code if you want to run it on bionic/melodic.

BTW do you have pre-trained models from this code?

lericson commented 4 years ago

Hi Vikas, no I was not able to run it as is. The author disappeared somewhere in the middle of the process.

I managed to get something working but the performance of the network was not very good at all, and it looks as if though the published results have memorized the training set.

On 24 Feb 2020, at 08:43, Vikas Dhiman notifications@github.com wrote:

 @lericson Were you able to run this code out of the box? I tried running it on bionic/melodic and I had to migrate tf to tf2 because costmap_2d uses tf2 while hectormap uses tf. You can checkout my forks of the code if you want to run it on bionic/melodic.

BTW do you have pre-trained models from this code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ArlenCHEN commented 4 years ago

@lericson @wecacuee @w0617 Did you guys successfully run the exploration after training the model?

Quest2GM commented 1 year ago

Hi @lericson and @wecacuee,

Could you elaborate on what you did to get things working? For context, I am able to get catkin_make to work using Vikas' implementation in ROS Melodic, but I don't know how to proceed further. Running rosrun stage_frontier_datagen kth_stage_node _dataset_dir:=<kth_dataset_dir> _data_record_dir:=<generated_dataset_dir> results in:

[ INFO] [1663459112.222657887]: planner failed [ INFO] [1663459112.222663440]: Received new plan [ INFO] [1663459112.224257456]: running planner... [ WARN] [1663459112.247933702]: [hector_exploration_planner] exploration: No valid frontiers found!

I don't really get why generating a partial dataset has anything to do with the planner, soooo I am not sure what I need to run and in what order. Would really really help getting a hint as to how this repository works.

Thanks for any help! Quest2GM

lericson commented 1 year ago

Hi! We can perhaps have a brief chat or video call tomorrow if you would like. - LudvigOn 18 Sep 2022, at 02:12, Siddarth Narasimhan @.***> wrote: Hi @lericson and @wecacuee, Could you elaborate on what you did to get things working? Would really really help getting a hint as to how this repository works. Thanks! Quest2GM

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Quest2GM commented 1 year ago

Hi Ludvig, sure that sounds good! I will reach out to you by email soon.

ktushar14 commented 1 year ago

Hi @lericson, I was reading this thread and just wanted to ask if you have a version of this that builds with melodic. I've poked around and encountered the tf/tf2 mismatch also mentioned above. Not sure what else I'll encounter, so just wanted to check. Thanks!

Quest2GM commented 1 year ago

@ktushar14 I recommend checking Vikas' implementation: https://github.com/wecacuee/map_prediction_enhanced_exploration. I verified that this compiles on melodic, but I didn't confirm that the simulation works so I recommend you try that out. Let me know if you come across any bugs, and I can try to help you out.