Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cd099e2
use binary archive for serialization, initialize laser to get sensor …
ivonaj Aug 30, 2018
5a40a57
connect visualization markers with submaps
ivonaj Aug 31, 2018
4e10f23
try merging
ivonaj Sep 8, 2018
18aa3d8
add transforms
ivonaj Sep 13, 2018
4bc85ad
SAD SAD transforms
ivonaj Sep 15, 2018
b417641
working transform
ivonaj Sep 24, 2018
6968d4c
put submap origins in to zeros, map submap id and transform
ivonaj Sep 25, 2018
c790171
fix case when there is no transform applied
ivonaj Sep 25, 2018
a45b840
submap markers put in the center of each submap, requested fixes
ivonaj Sep 26, 2018
fafb986
small changes
ivonaj Sep 26, 2018
6194d6b
add typedefs for iterators, rename vars
ivonaj Sep 26, 2018
fd5f1c8
requested fixes
ivonaj Sep 27, 2018
afe8f36
fix
ivonaj Sep 27, 2018
49e8299
fix
ivonaj Sep 27, 2018
21c6ff7
again fix
ivonaj Sep 27, 2018
4ae2d3f
refactor ApplyCorrection fcn
ivonaj Sep 27, 2018
200c73a
switch to unique pointers
ivonaj Sep 27, 2018
6a3dce6
add ref
ivonaj Sep 28, 2018
ef26cf7
prepare for merginggg
ivonaj Nov 16, 2018
f77a194
load laser dataset
ivonaj Nov 17, 2018
3d183af
add continuous slamming
ivonaj Nov 22, 2018
592fb23
add continuous slamming, gui buttons for rviz tool
ivonaj Dec 1, 2018
c845136
add merge_map_kietic header
ivonaj Dec 1, 2018
e907a1f
register sensor, add to laser map
ivonaj Dec 3, 2018
7151ae2
fix
ivonaj Dec 6, 2018
b2b6acb
remove mem alloc, leak, rename buttons, functions
ivonaj Dec 6, 2018
ff3c5e8
remove merge optimization work for PR
ivonaj Dec 6, 2018
4d4eab7
organize
ivonaj Dec 6, 2018
cb364e5
unnecessary function input
ivonaj Dec 6, 2018
a30a7e3
fix naming
ivonaj Dec 6, 2018
6456fda
switch lines in rviz gui
ivonaj Dec 7, 2018
10b72d8
lineup
ivonaj Dec 7, 2018
7a1adf4
change {sub}map names
ivonaj Dec 7, 2018
97e0d86
fixes
ivonaj Dec 7, 2018
d593dd4
fix service name
ivonaj Dec 12, 2018
815b4d5
add service namespace, rename, change tf handling
ivonaj Dec 12, 2018
5da41e1
fix
ivonaj Dec 12, 2018
3f46952
line lengths, renaming, header func fix
ivonaj Dec 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(slam_toolbox)

add_compile_options(-std=c++11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/")
set(CMAKE_CXX_FLAGS "-fpermissive -std=c++11")
set(CMAKE_CXX_FLAGS "-fpermissive -std=c++11")

find_package(Boost REQUIRED system serialization filesystem)

Expand Down Expand Up @@ -80,6 +80,7 @@ add_service_files(DIRECTORY srvs
LoopClosure.srv
MergeMaps.srv
AddSubmap.srv
AddMap.srv
SerializePoseGraph.srv
)
generate_messages(
Expand Down Expand Up @@ -145,11 +146,11 @@ add_dependencies(slam_toolbox ${PROJECT_NAME}_generate_messages_cpp)
target_link_libraries(slam_toolbox ${catkin_LIBRARIES} ${Boost_LIBRARIES})

#### Merging maps tool
add_executable(merge_maps_tool src/merge_maps_tool.cpp)
add_dependencies(merge_maps_tool ${PROJECT_NAME}_generate_messages_cpp)
target_link_libraries(merge_maps_tool ${catkin_LIBRARIES} ${Boost_LIBRARIES})
add_executable(merge_maps_kinematic src/merge_maps_kinematic.cpp)
add_dependencies(merge_maps_kinematic ${PROJECT_NAME}_generate_messages_cpp)
target_link_libraries(merge_maps_kinematic ${catkin_LIBRARIES} ${Boost_LIBRARIES})

install(TARGETS slam_toolbox merge_maps_tool spa_solver_plugin g2O_solver_plugin ceres_solver_plugin SlamToolboxPlugin
install(TARGETS slam_toolbox merge_maps_kinematic spa_solver_plugin g2O_solver_plugin ceres_solver_plugin SlamToolboxPlugin
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
Expand Down
6 changes: 5 additions & 1 deletion config/mapper_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ ceres_loss_function: None
# ROS Parameters
odom_frame: odom
map_frame: map
base_frame: base_link
base_frame: base_footprint
laser_frame: base_laser_link
debug_logging: false
throttle_scans: 1
publish_occupancy_map: true
Expand Down Expand Up @@ -63,3 +64,6 @@ coarse_angle_resolution: 0.0349
minimum_angle_penalty: 0.9
minimum_distance_penalty: 0.5
use_response_expansion: true

# Load Map Parameters
inverted_laser: true
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,27 @@
#include <unistd.h>
#include <fstream>

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/string.hpp>

#define MAP_IDX(sx, i, j) ((sx) * (j) + (i))

class MergeMapTool
class MergeMapsKinematic
{

public:
MergeMapTool();
~MergeMapTool();
MergeMapsKinematic();
~MergeMapsKinematic();

private:

// setup
void SetConfigs();

// callbacks
// callback
bool MergeMapCallback(slam_toolbox::MergeMaps::Request &req, slam_toolbox::MergeMaps::Response &resp);
bool AddSubmapCallback(slam_toolbox::AddSubmap::Request &req, slam_toolbox::AddSubmap::Response &resp);
void ProcessInteractiveFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback);
void KartoToROSOccupancyGrid(const karto::LocalizedRangeScanVector& scans);

inline bool FileExists(const std::string& name)
{
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0);
}
void KartoToROSOccupancyGrid(const karto::LocalizedRangeScanVector& scans, nav_msgs::GetMap::Response& map);
typedef std::vector<karto::LocalizedRangeScanVector>::iterator localized_range_scans_vec_it;
typedef karto::LocalizedRangeScanVector::iterator localized_range_scans_it;

// ROS-y-ness
ros::NodeHandle nh_;
Expand All @@ -89,12 +80,21 @@ class MergeMapTool
double resolution_;
double max_laser_range_;
int num_submaps_;
nav_msgs::GetMap::Response map_;

//karto bookkeeping
std::map<std::string, karto::LaserRangeFinder*> lasers_;
std::vector<karto::Dataset*> dataset_vec_;

// TF
tf::TransformBroadcaster* tfB_;

// visualization
interactive_markers::InteractiveMarkerServer* interactive_server_;
std::map<int, Eigen::Vector3d> submap_locations_;
std::vector<karto::LocalizedRangeScanVector> scans_vec_;
std::map<int, tf::Transform> submap_marker_transform_;

//apply transformation to correct pose
karto::Pose2 ApplyCorrection(const karto::Pose2& pose, const tf::Transform& submap_correction);
karto::Vector2<kt_double> ApplyCorrection(const karto::Vector2<kt_double>& pose, const tf::Transform& submap_correction);
};
7 changes: 5 additions & 2 deletions include/slam_toolbox/slam_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "slam_toolbox/SaveMap.h"
#include "slam_toolbox/LoopClosure.h"
#include "slam_toolbox/SerializePoseGraph.h"
#include "slam_toolbox/AddMap.h"

#include <string>
#include <map>
Expand Down Expand Up @@ -135,18 +136,20 @@ class SlamToolbox
// state
bool IsPaused(const PausedApplication& app);

bool LoadMapperCallback(slam_toolbox::AddMap::Request &req, slam_toolbox::AddMap::Response &resp);

// ROS-y-ness
ros::NodeHandle nh_;
tf::TransformListener tf_;
tf::TransformBroadcaster* tfB_;
message_filters::Subscriber<sensor_msgs::LaserScan>* scan_filter_sub_;
tf::MessageFilter<sensor_msgs::LaserScan>* scan_filter_;
ros::Publisher sst_, sstm_, marker_publisher_, scan_publisher_;
ros::ServiceServer ssMap_, ssClear_, ssInteractive_, ssLoopClosure_, ssPause_processing_, ssPause_measurements_, ssClear_manual_, ssSave_map_, ssSerialize_;
ros::ServiceServer ssMap_, ssClear_, ssInteractive_, ssLoopClosure_, ssPause_processing_, ssPause_measurements_, ssClear_manual_, ssSave_map_, ssSerialize_, ssLoadMap_;
nav_msgs::GetMap::Response map_;

// Storage for ROS parameters
std::string odom_frame_, map_frame_, base_frame_;
std::string odom_frame_, map_frame_, base_frame_, laser_frame_;
int throttle_scans_;
ros::Duration map_update_interval_;
double resolution_, minimum_time_interval_, minimum_travel_distance_;
Expand Down
8 changes: 3 additions & 5 deletions launch/build_map_w_params.launch
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<launch>

<node pkg="slam_toolbox" type="slam_toolbox" name="slam_toolbox" output="screen">
<rosparam command="load" file="$(find slam_toolbox)/config/mapper_params.yaml" />
</node>

<node pkg="slam_toolbox" type="slam_toolbox" name="slam_toolbox" output="screen">
<rosparam command="load" file="$(find slam_toolbox)/config/mapper_params.yaml" />
</node>
</launch>
6 changes: 6 additions & 0 deletions launch/merge_maps_kinematic.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<launch>

<node pkg="slam_toolbox" type="merge_maps_kinematic" name="merge_maps_kinematic" output="screen">
</node>

</launch>
6 changes: 0 additions & 6 deletions launch/merge_maps_tool.launch

This file was deleted.

57 changes: 39 additions & 18 deletions mapping_plugin/slam_toolbox_rviz_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
nh.getParam("/slam_toolbox/paused_new_measurements", paused_measure);
nh.getParam("/slam_toolbox/paused_processing", paused_process);
nh.getParam("/slam_toolbox/interactive_mode", interactive);

_serialize = nh.serviceClient<slam_toolbox::SerializePoseGraph>("/slam_toolbox/serialize_map");
_load_map = nh.serviceClient<slam_toolbox::AddMap>("/slam_toolbox/load_map");
_clearChanges = nh.serviceClient<slam_toolbox::Clear>("/slam_toolbox/clear_changes");
_saveChanges = nh.serviceClient<slam_toolbox::LoopClosure>("/slam_toolbox/manual_loop_closure");
_saveMap = nh.serviceClient<slam_toolbox::SaveMap>("/slam_toolbox/save_map");
_clearQueue = nh.serviceClient<slam_toolbox::ClearQueue>("/slam_toolbox/clear_queue");
_interactive = nh.serviceClient<slam_toolbox::ToggleInteractive>("/slam_toolbox/toggle_interactive_mode");
_pause_processing = nh.serviceClient<slam_toolbox::Pause>("/slam_toolbox/pause_processing");
_pause_measurements = nh.serviceClient<slam_toolbox::Pause>("/slam_toolbox/pause_new_measurements");
_load_submap = nh.serviceClient<slam_toolbox::AddSubmap>("/merge_maps_tool/add_submap");
_merge = nh.serviceClient<slam_toolbox::MergeMaps>("/merge_maps_tool/merge_maps");
_serialize = nh.serviceClient<slam_toolbox::SerializePoseGraph>("/slam_toolbox/serialize_map");
_load_submap_for_merging = nh.serviceClient<slam_toolbox::AddSubmap>("/map_merging/add_submap");
_merge = nh.serviceClient<slam_toolbox::MergeMaps>("/map_merging/merge_submaps");

_vbox = new QVBoxLayout();
_hbox1 = new QHBoxLayout();
Expand All @@ -63,6 +63,7 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
_hbox5 = new QHBoxLayout();
_hbox6 = new QHBoxLayout();
_hbox7 = new QHBoxLayout();
_hbox8 = new QHBoxLayout();

QFrame* _line = new QFrame();
_line->setFrameShape(QFrame::HLine);
Expand All @@ -81,14 +82,17 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
_button4->setText("Clear Measurement Queue");
connect(_button4, SIGNAL(clicked()), this, SLOT(ClearQueue()));
_button5 = new QPushButton(this);
_button5->setText("Load Pose Graph");
connect(_button5, SIGNAL(clicked()), this, SLOT(LoadPoseGraph()));
_button5->setText("Add Submap");
connect(_button5, SIGNAL(clicked()), this, SLOT(LoadSubmap()));
_button6 = new QPushButton(this);
_button6->setText("Generate Map");
connect(_button6, SIGNAL(clicked()), this, SLOT(GenerateMap()));
_button7 = new QPushButton(this);
_button7->setText("Serialize Map");
connect(_button7, SIGNAL(clicked()), this, SLOT(SerializeMap()));
_button8 = new QPushButton(this);
_button8->setText("Load Map");
connect(_button8, SIGNAL(clicked()), this, SLOT(LoadMap()));

_label1 = new QLabel(this);
_label1->setText("Interactive");
Expand Down Expand Up @@ -116,6 +120,7 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
_line1 = new QLineEdit();
_line2 = new QLineEdit();
_line3 = new QLineEdit();
_line4 = new QLineEdit();

_button1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
_button2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Expand All @@ -133,6 +138,7 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
_hbox1->addWidget(_check3);
_hbox1->addWidget(_label3);


_hbox2->addWidget(_button1);
_hbox2->addWidget(_button2);

Expand All @@ -149,11 +155,15 @@ SlamToolboxPlugin::SlamToolboxPlugin(QWidget* parent):
_hbox7->addWidget(_button7);
_hbox7->addWidget(_line3);

_hbox8->addWidget(_button8);
_hbox8->addWidget(_line4);

_vbox->addWidget(_label5);
_vbox->addLayout(_hbox1);
_vbox->addLayout(_hbox2);
_vbox->addLayout(_hbox3);
_vbox->addLayout(_hbox7);
_vbox->addLayout(_hbox8);
_vbox->addLayout(_hbox4);
_vbox->addWidget(_line);
_vbox->addWidget(_label4);
Expand Down Expand Up @@ -183,30 +193,41 @@ void SlamToolboxPlugin::SerializeMap()
msg.request.filename = _line3->text().toStdString();
if (!_serialize.call(msg))
{
ROS_WARN("Failed to serialize pose graph to file, is service running?");
ROS_WARN("SlamToolbox: Failed to serialize pose graph to file, is service running?");
}
}

/*****************************************************************************/
void SlamToolboxPlugin::LoadPoseGraph()
void SlamToolboxPlugin::LoadMap()
/*****************************************************************************/
{
slam_toolbox::AddSubmap msg;
msg.request.filename = _line2->text().toStdString();
if (!_load_submap.call(msg))
msg.request.filename = _line4->text().toStdString();
if (!_load_map.call(msg))
{
ROS_WARN("Failed to load pose graph from file, is service running?");
ROS_WARN("SlamToolbox: Failed to load mapper object from file, is service running?");
}
}

/*****************************************************************************/
void SlamToolboxPlugin::LoadSubmap()
/*****************************************************************************/
{
slam_toolbox::AddSubmap msg;
msg.request.filename = _line2->text().toStdString();
if (!_load_submap_for_merging.call(msg))
{
ROS_WARN("MergeMaps: Failed to load pose graph from file, is service running?");
}
}
/*****************************************************************************/
void SlamToolboxPlugin::GenerateMap()
/*****************************************************************************/
{
slam_toolbox::MergeMaps msg;
if (!_merge.call(msg))
{
ROS_WARN("Failed to merge maps, is service running?");
ROS_WARN("MergeMaps: Failed to merge maps, is service running?");
}
}

Expand All @@ -217,7 +238,7 @@ void SlamToolboxPlugin::ClearChanges()
slam_toolbox::Clear msg;
if (!_clearChanges.call(msg))
{
ROS_WARN("Failed to clear changes, is service running?");
ROS_WARN("SlamToolbox: Failed to clear changes, is service running?");
}
}

Expand All @@ -229,7 +250,7 @@ void SlamToolboxPlugin::SaveChanges()

if (!_saveChanges.call(msg))
{
ROS_WARN("Failed to save changes, is service running?");
ROS_WARN("SlamToolbox: Failed to save changes, is service running?");
}
}

Expand All @@ -241,7 +262,7 @@ void SlamToolboxPlugin::SaveMap()
msg.request.name.data = _line1->text().toStdString();
if (!_saveMap.call(msg))
{
ROS_WARN("Failed to save map as %s, is service running?",
ROS_WARN("SlamToolbox: Failed to save map as %s, is service running?",
msg.request.name.data.c_str());
}
}
Expand All @@ -264,7 +285,7 @@ void SlamToolboxPlugin::InteractiveCb(int state)
slam_toolbox::ToggleInteractive msg;
if (!_interactive.call(msg))
{
ROS_WARN("Failed to toggle interactive mode, is service running?");
ROS_WARN("SlamToolbox: Failed to toggle interactive mode, is service running?");
}
}

Expand All @@ -275,7 +296,7 @@ void SlamToolboxPlugin::PauseProcessingCb(int state)
slam_toolbox::Pause msg;
if (!_pause_processing.call(msg))
{
ROS_WARN("Failed to toggle pause processing, is service running?");
ROS_WARN("SlamToolbox: Failed to toggle pause processing, is service running?");
}
}

Expand All @@ -286,7 +307,7 @@ void SlamToolboxPlugin::PauseMeasurementsCb(int state)
slam_toolbox::Pause msg;
if (!_pause_measurements.call(msg))
{
ROS_WARN("Failed to toggle pause measurements, is service running?");
ROS_WARN("SlamToolbox: Failed to toggle pause measurements, is service running?");
}
}

Expand Down
Loading