forked from SteveMacenski/slam_toolbox
-
Notifications
You must be signed in to change notification settings - Fork 1
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
[M3RSM] Implementation of basic classes #1
Open
LucasJSch
wants to merge
3
commits into
ekumenlabs:foxy-devel
Choose a base branch
from
LucasJSch:foxy-devel
base: foxy-devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
snap_ws/* | ||
|
||
build/ | ||
log/* | ||
install/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM ros:foxy-ros-base-focal | ||
|
||
# USE BASH | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# RUN LINE BELOW TO REMOVE debconf ERRORS (MUST RUN BEFORE ANY apt-get CALLS) | ||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | ||
|
||
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends apt-utils | ||
|
||
# slam_toolbox | ||
RUN mkdir -p colcon_ws/src | ||
RUN cd colcon_ws/src | ||
# RUN git clone -b foxy-devel https://github.com/SteveMacenski/slam_toolbox.git | ||
|
||
#RUN source /opt/ros/foxy/setup.bash \ | ||
# && cd colcon_ws \ | ||
# && rosdep update \ | ||
# && rosdep install -y -r --from-paths src --ignore-src --rosdistro=foxy -y | ||
|
||
#RUN source /opt/ros/foxy/setup.bash \ | ||
# && cd colcon_ws/ \ | ||
# && colcon build --cmake-args=-DCMAKE_BUILD_TYPE=Release \ | ||
# && colcon test | ||
|
||
# RUN apt-get update && apt-get install -y tmux | ||
|
||
CMD /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build -t m3rsm-image . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
source /opt/ros/foxy/setup.bash | ||
cd /colcon_ws/ | ||
colcon build --cmake-args=-DCMAKE_BUILD_TYPE=Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
apt-get update | ||
source /opt/ros/foxy/setup.bash | ||
cd /colcon_ws | ||
rosdep update | ||
rosdep install -y -r --from-paths src --ignore-src --rosdistro=foxy -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
source /opt/ros/foxy/setup.bash && cd /colcon_ws/ && colcon build --cmake-args=-DCMAKE_BUILD_TYPE=Release && colcon test && colcon test-result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
CONTAINER=m3rsm-image | ||
IMAGE_NAME=m3rsm-image | ||
|
||
SCRIPTS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
REPO_DIR=`readlink -f ${SCRIPTS_DIR}/../` | ||
|
||
DOCKER_MOUNT_ARGS="-v ${REPO_DIR}/:/colcon_ws/src" | ||
|
||
xhost + | ||
docker run --name ${IMAGE_NAME} --privileged --rm \ | ||
${DOCKER_MOUNT_ARGS} \ | ||
-e USER=$USER -e USERID=$UID \ | ||
--net=host \ | ||
-it ${CONTAINER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#ifndef M3RSM__H | ||
#define M3RSM__H | ||
|
||
#include <stdint.h> | ||
#include <map> | ||
#include <vector> | ||
#include <unordered_map> | ||
#include <queue> | ||
#include <algorithm> | ||
#include <chrono> | ||
#include <utility> | ||
#include <string> | ||
|
||
#include "Eigen/Core" | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "karto_sdk/Karto.h" | ||
#include "karto_sdk/Mapper.h" | ||
|
||
namespace { | ||
typedef std::vector<std::vector<uint8_t>> DataMatrix; | ||
} | ||
|
||
namespace karto | ||
{ | ||
|
||
class M3RSM_scan; | ||
|
||
// TODO: Implement this class. | ||
class LookupTable { | ||
|
||
public: | ||
// Builds highest resolution lookup table from base scans | ||
LookupTable(const std::vector<LocalizedRangeScan>& base_scans, int decimation_factor, int kernel_width); | ||
// Copy constructor | ||
LookupTable(const LookupTable& table); | ||
// Builds lower resolution lookup table from higher resolution lookup table | ||
static LookupTable GetLowerResTable(const LookupTable& higher_res_table); | ||
double computeCost(const LocalizedRangeScan& scan); | ||
bool isMaxResolution(); | ||
int getTableSize(); | ||
|
||
private: | ||
DataMatrix data_; | ||
bool is_max_res_; | ||
int decimation_factor_; | ||
int kernel_width_; | ||
|
||
}; // class LookupTable | ||
|
||
class MockLookupTable { | ||
|
||
public: | ||
MockLookupTable(const DataMatrix& data, int decimation_factor, int kernel_width); | ||
// Builds lower resolution lookup table from higher resolution lookup table | ||
MockLookupTable(const MockLookupTable& table); | ||
static MockLookupTable GetLowerResTable(const MockLookupTable& higher_res_table); | ||
double computeCost(const std::vector<std::pair<int, int>>& occupied_cells); | ||
bool isMaxResolution(); | ||
int getTableSize(); | ||
DataMatrix data_; | ||
bool is_max_res_; | ||
int decimation_factor_; | ||
int kernel_width_; | ||
}; // class MockLookupTable | ||
|
||
class LookupTableManager { | ||
|
||
public: | ||
// TODO: Implement this method when integrating with slam_toolbox codebase. | ||
// LookupTableManager(const std::vector<LocalizedRangeScan>& base_scans); | ||
LookupTableManager(const DataMatrix& full_res_matrix); | ||
MockLookupTable getTable(int resolution); | ||
int getAmountOfResolutions(); | ||
|
||
private: | ||
// Lookup tables ordered by resolution. | ||
// Each vector contains a vector of same-resolution lookup tables. | ||
// TODO: Use this attribute when integrating with slam_toolbox. | ||
//std::vector<std::vector<LookupTable>> tables_; | ||
std::vector<MockLookupTable> tables_; | ||
int n_resolutions_; | ||
|
||
}; // class LookupTableManager | ||
|
||
class EvaluationTask { | ||
public: | ||
EvaluationTask(const LookupTable& lookup_table); | ||
double computeCost(); | ||
std::vector<EvaluationTask> generateChildrenTasks(); | ||
bool isMaxResolution(); | ||
Pose2 getPose(); | ||
|
||
private: | ||
std::shared_ptr<LookupTable> lookup_table_; | ||
}; // class EvaluationTask | ||
|
||
class SearchHeap { | ||
|
||
public: | ||
SearchHeap(const LocalizedRangeScan& received_scan, const LookupTableManager& lookup_table_manager); | ||
Pose2 getEstimatedPose(); | ||
|
||
private: | ||
std::shared_ptr<LocalizedRangeScan> received_scan_; | ||
std::shared_ptr<LookupTableManager> lookup_table_manager_; | ||
std::vector<EvaluationTask> tasks; | ||
|
||
}; // class SearchHeap | ||
|
||
|
||
class M3RScanMatcher { | ||
|
||
public: | ||
M3RScanMatcher(); | ||
Pose2 MatchScan(LocalizedRangeScan received_scan, std::vector<LocalizedRangeScan> potential_scans); | ||
|
||
private: | ||
}; // M3RScanMatcher | ||
|
||
} // namespace karto | ||
|
||
#endif // M3RSM__H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
include_directories ( | ||
${PROJECT_SOURCE_DIR}/m3rsm_test/gtest/include | ||
${PROJECT_SOURCE_DIR}/m3rsm_test/gtest | ||
${PROJECT_SOURCE_DIR}/m3rsm_test | ||
${PROJECT_BINARY_DIR} | ||
) | ||
|
||
# configure_file (test_config.h.in ${PROJECT_BINARY_DIR}/include/rndf_gazebo_plugin/test_config.h) | ||
|
||
# Build gtest | ||
add_library(gtest STATIC gtest/src/gtest-all.cc) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LucasJSch FYI: you don't need all this, |
||
add_library(gtest_main STATIC gtest/src/gtest_main.cc) | ||
target_link_libraries(gtest_main gtest) | ||
|
||
set_target_properties(gtest PROPERTIES CXX_CPPLINT "") | ||
set_target_properties(gtest_main PROPERTIES CXX_CPPLINT "") | ||
|
||
set(GTEST_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest.a") | ||
set(GTEST_MAIN_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest_main.a") | ||
|
||
execute_process(COMMAND cmake -E remove_directory ${CMAKE_BINARY_DIR}/test_results) | ||
execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results) | ||
include_directories(${GTEST_INCLUDE_DIRS}) | ||
|
||
# This should be migrated to more fine control solution based on set_property APPEND | ||
# directories. It's present on cmake 2.8.8 while precise version is 2.8.7 | ||
link_directories(${PROJECT_BINARY_DIR}/test) | ||
include_directories("${PROJECT_SOURCE_DIR}/test/gtest/include") | ||
|
||
macro (m3rsm_tests_build) | ||
# Build all the tests | ||
foreach(GTEST_SOURCE_file ${ARGN}) | ||
string(REGEX REPLACE ".cc" "" BINARY_NAME ${GTEST_SOURCE_file}) | ||
message(${BINARY_NAME}) | ||
set(BINARY_NAME ${TEST_TYPE}_${BINARY_NAME}) | ||
if(USE_LOW_MEMORY_TESTS) | ||
add_definitions(-DUSE_LOW_MEMORY_TESTS=1) | ||
endif(USE_LOW_MEMORY_TESTS) | ||
|
||
include_directories( | ||
test/gtest/include | ||
) | ||
add_executable(${BINARY_NAME} ${GTEST_SOURCE_file}) | ||
|
||
add_dependencies(${BINARY_NAME} | ||
gtest | ||
gtest_main | ||
) | ||
|
||
target_link_libraries(${BINARY_NAME} | ||
kartoSlamToolbox | ||
) | ||
|
||
target_link_libraries(${BINARY_NAME} | ||
libgtest.a | ||
libgtest_main.a | ||
pthread | ||
) | ||
|
||
add_test(${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} | ||
--gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml) | ||
set_tests_properties(${BINARY_NAME} PROPERTIES TIMEOUT 240) | ||
endforeach() | ||
endmacro() | ||
|
||
add_subdirectory(src) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LucasJSch meta: only to not lose track of our discussion today.
Rasterized image pyramids can be cached (or managed) for a single scan matching request, but it is not clear how and if we can cache these pyramids across scan matching requests. We could simply persist the cache but it is unlikely we'll be given the same set of reference scans often enough for the cache to be worth it. We could cache a pyramid per scan and merge them, but the candidate scan pose (and thus the search window pose) changes over time. It is hard to tell whether we can freely apply translations and rotations to decimated rasterized images or not.
How can we maximize cache hits across scan matching runs? I'll sleep on it.