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

Feature/filtered elevation layer #84

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5af50a9
added elevation layer package as a plugin of costmap_2d
chisarie Oct 19, 2018
b3d8ac0
deleted .idea files
chisarie Oct 19, 2018
55ea64e
implemented elevation layer for costmap_2d. It takes elevaton mapping…
chisarie Oct 22, 2018
fd906f5
fixed namespace bug
chisarie Oct 22, 2018
2655dfd
working on including filter to find edges of elevation layer
chisarie Oct 22, 2018
addee5c
adding grid_map_filters to the elevation layer to detect edges of the…
chisarie Oct 23, 2018
105f9a5
elevation layer using filter done. Still one small bug with combinati…
chisarie Oct 25, 2018
4ed82cf
tried height treshold and filter treshold together, not good
chisarie Oct 26, 2018
d505d15
halfing the trshold if map filtered
chisarie Oct 26, 2018
afbfd7d
putting the elevation data outside the for loop
chisarie Oct 26, 2018
0a5a674
made filter thread safe
chisarie Oct 29, 2018
c8abffb
combination method and footprint clearing working
chisarie Oct 30, 2018
12d5302
label free space explicitly
chisarie Oct 30, 2018
c05ebbe
add config file for elevation filters
hogabrie Oct 31, 2018
68c83bb
Updated README file
chisarie Nov 5, 2018
88dec09
making changes from pull request feedback
chisarie Nov 6, 2018
b2cfdea
added elevation_filters.yaml in here
chisarie Nov 6, 2018
a0387bc
added param_io, throttled some warnings and now dividing by 2.0 inste…
chisarie Nov 6, 2018
f721df4
moved layer names in yaml file
chisarie Nov 6, 2018
cdc2d1a
added smart pointer
chisarie Nov 6, 2018
3c8ee6a
converted combination_method to enum
chisarie Nov 7, 2018
a15f192
set current_ to false if last received elevation map to old
chisarie Nov 7, 2018
570622c
converted param_io back to standard Ros
chisarie Nov 7, 2018
d927d28
added doxygen comments to header file
chisarie Nov 7, 2018
eb2d3fd
added max_allowed_blind_time, taken from parameter server
chisarie Nov 8, 2018
0e0a86a
last cleaning ups, and also made combination_method case insensitive
chisarie Nov 12, 2018
437f3f6
deleted useless nodehandles and made one as member of the class
chisarie Nov 12, 2018
9c7860b
Merge branch 'feature/filtered_elevation_layer' into test/new_nav
harmishhk Nov 13, 2018
927731a
refactored variable names, include order and doxygen format
chisarie Dec 4, 2018
34c43c8
New software added to the main readme and removed comments in elevati…
chisarie Dec 5, 2018
cb4e2d6
minor readme.md chenges
chisarie Dec 5, 2018
3b3dc76
elevation_layer renamed as elevation_maping_costmap_2d_plugin. Someho…
chisarie Dec 5, 2018
a5b78aa
Merge remote-tracking branch 'origin/test/new_nav' into feature/filte…
chisarie Dec 6, 2018
1833bfc
fixed typo in folder
chisarie Dec 7, 2018
463fa92
formatted code and made warnings throttles at 0.5 hz
chisarie Dec 7, 2018
ae5817c
Update README.md
Mar 11, 2019
0c350f1
Update costmap_plugins.xml
pfankhauser Mar 11, 2019
c8d01e9
All comments start with a capital letter and end with a period.
chisarie Mar 11, 2019
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
77 changes: 77 additions & 0 deletions elevation_layer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# use c++11
set(CMAKE_CXX_COMPILER_ARG1 -std=c++11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this in the build section of the cmake and use
add_definitions(-std=c++11)


cmake_minimum_required(VERSION 2.8.3)
project(elevation_layer)

find_package(Boost REQUIRED COMPONENTS thread)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You never actually use boost in the cmake.
See here for a how-to.

find_package(catkin REQUIRED COMPONENTS
roscpp
tf
costmap_2d
dynamic_reconfigure
grid_map_ros
filters
)

# add dynamic reconfigure configs
generate_dynamic_reconfigure_options(
cfg/ElevationPlugin.cfg
)

## declare catkin package
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
elevation_layer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${PROJECT_NAME}

CATKIN_DEPENDS
roscpp
tf
costmap_2d
dynamic_reconfigure
grid_map_ros
filters
)



## build ##

include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can have a single include_directories and list the elements


## declare a cpp library
add_library(elevation_layer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can use ${PROJECT_NAME} whenever you have elevation_layer.

src/elevation_layer.cpp
)


## cmake target dependencies of the executable/library

# build config headers
add_dependencies(elevation_layer elevation_layer_gencfg)

## libraries to link a library or executable target against
target_link_libraries(elevation_layer
${catkin_LIBRARIES}
)



## install ##

## executables and/or libraries for installation
install(TARGETS elevation_layer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${PROJECT_NAME}

ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## cpp-header files for installation
install(DIRECTORY include/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:
install(DIRECTORY include/${PROJECT_NAME}/

DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)
3 changes: 3 additions & 0 deletions elevation_layer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Elevation layer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add README files for each package, but please document the new software in the main README.


A plugin for [costmap_2d]](http://wiki.ros.org/costmap_2d). It takes the elevation map as input and generates a layer of obstacles in the local costmap_2d.
9 changes: 9 additions & 0 deletions elevation_layer/cfg/ElevationPlugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python
PACKAGE = "elevation_layer"

from dynamic_reconfigure.parameter_generator_catkin import ParameterGenerator, bool_t, double_t, int_t

gen = ParameterGenerator()
gen.add("enabled", bool_t, 0, "Whether to apply this plugin or not", True)

exit(gen.generate("elevation_layer", "elevation_layer", "ElevationPlugin"))
7 changes: 7 additions & 0 deletions elevation_layer/costmap_plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<class_libraries>
<library path="lib/libelevation_layer">
<class type="elevation_layer::ElevationLayer" base_class_type="costmap_2d::Layer">
<description>adds elevation map info to costmap_2d.</description>
</class>
</library>
</class_libraries>
82 changes: 82 additions & 0 deletions elevation_layer/include/elevation_layer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow this packages file naming:
e.g.

/*
 * ElevationMapping.cpp
 *
 *  Created on: Nov 12, 2013
 *      Author: Péter Fankhauser
 *	 Institute: ETH Zurich, ANYbotics
 */

// Created by eugenio on 15.10.18.
//

#ifndef ELEVATION_LAYER_H
#define ELEVATION_LAYER_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use #pragma once, a more modern way of doing this.



#include <atomic>
#include <mutex>

#include <ros/ros.h>
#include <costmap_2d/costmap_layer.h>
#include <costmap_2d/layered_costmap.h>
#include <costmap_2d/observation_buffer.h>
#include <message_filters/subscriber.h>
#include "grid_map_ros/GridMapRosConverter.hpp"
#include <filters/filter_chain.h>

#include <nav_msgs/OccupancyGrid.h>
#include <dynamic_reconfigure/server.h>
#include <costmap_2d/footprint.h>
#include <elevation_layer/ElevationPluginConfig.h>


namespace elevation_layer
{
class ElevationLayer : public costmap_2d::CostmapLayer
{
public:
ElevationLayer();
virtual ~ElevationLayer();
virtual void onInitialize();
virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use override instead of virtual see here

double* max_x, double* max_y);
virtual void updateCosts(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);

virtual void activate();
virtual void deactivate();
virtual void reset();

void elevationMapCallback(const grid_map_msgs::GridMapConstPtr& occupancy_grid);

protected:
std::string global_frame_; ///< @brief The global frame for the costmap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use camelCase_ for members.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a plugin for costmap_2d, I am following its syntax. Is it bad?

std::vector<boost::shared_ptr<message_filters::SubscriberBase> > elevation_subscribers_; ///< @brief Used for the observation message filters
dynamic_reconfigure::Server<elevation_layer::ElevationPluginConfig> *dsrv_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a std::unique_ptr for this, you can get rid of deletion in the destructor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this ?
std::unique_ptr< dynamic_reconfigure::Server<elevation_layer::ElevationPluginConfig> > dsrv_;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a smart pointer here, you do not need to care about memory handling (calling delete)

virtual void setupDynamicReconfigure(ros::NodeHandle& nh);


int combination_method_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use an enum or an enum class for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is possible to get an enum type from a yaml file, is it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but you could use a string that you transform to an enum. This makes it easier for the user to tweak the parameters of your layer (0, 1 or 2 is not very descriptive)

std::vector<geometry_msgs::Point> transformed_footprint_;
bool rolling_window_;
bool footprint_clearing_enabled_;
std::atomic_bool elevation_map_received_;
void updateFootprint(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y,
double* max_x, double* max_y);

private:
void reconfigureCB(elevation_layer::ElevationPluginConfig &config, uint32_t level);
grid_map::GridMap elevation_map_;
std::mutex elevation_map_mutex_;
ros::Subscriber elevation_subscriber_;
double height_treshold_;
double edges_sharpness_treshold_;
std::string elevation_topic_;

//! Filter chain.
filters::FilterChain<grid_map::GridMap> filterChain_;

//! Filter chain parameters name.
std::string filter_chain_parameters_name_;

bool filters_configuration_loaded_;
std::string elevation_layer_name_;
std::string edges_layer_name_;
};

} // namespace elevation_layer


#endif //ELEVATION_LAYER_H
32 changes: 32 additions & 0 deletions elevation_layer/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<package>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use package version 2 here, so you only have <depend> instead of <build_depend> and <run_depend>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<name>elevation_layer</name>

<version>0.0.2</version>

<description>adds elevation mapping informations to costmap_2d</description>

<!-- <author email="[email protected]">Eugenio Chisari</author> -->
<maintainer email="[email protected]">Eugenio Chisari</maintainer>

<license>BSD</license>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we open sourcing this plugin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already open source, if we keep it in this repo 😉


<buildtool_depend>catkin</buildtool_depend>

<build_depend>roscpp</build_depend>
<build_depend>tf</build_depend>
<build_depend>costmap_2d</build_depend>
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>grid_map_ros</build_depend>
<build_depend>filters</build_depend>

<run_depend>roscpp</run_depend>
<run_depend>tf</run_depend>
<run_depend>costmap_2d</run_depend>
<run_depend>dynamic_reconfigure</run_depend>
<run_depend>grid_map_ros</run_depend>
<run_depend>filters</run_depend>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<export>
<costmap_2d plugin="${prefix}/costmap_plugins.xml" />
</export>
</package>
Loading