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

Feat/obstacle height dynamic reconf #1

Open
wants to merge 2 commits into
base: noetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_service_files(DIRECTORY msgs

generate_dynamic_reconfigure_options(
cfg/SpatioTemporalVoxelLayer.cfg
cfg/MeasurementBuffer.cfg
)

generate_messages(
Expand Down
11 changes: 11 additions & 0 deletions cfg/MeasurementBuffer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
PACKAGE = 'spatio_temporal_voxel_layer'

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

gen.add("min_obstacle_height", double_t, 0, "Minimum height of obstacles to detect", 0.0, 0.0, 3.0)
gen.add("max_obstacle_height", double_t, 0, "Maximum height of obstacles to detect", 0.0, 0.0, 3.0)

exit(gen.generate(PACKAGE, "buffer", "MeasurementBuffer"))
12 changes: 11 additions & 1 deletion include/spatio_temporal_voxel_layer/measurement_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

// measurement structs
#include <spatio_temporal_voxel_layer/measurement_reading.h>
#include <spatio_temporal_voxel_layer/MeasurementBufferConfig.h>
// PCL
#include <pcl_ros/transforms.h>
#include <pcl/filters/voxel_grid.h>
Expand All @@ -53,6 +54,7 @@
// ROS
#include <ros/ros.h>
#include <ros/time.h>
#include <dynamic_reconfigure/server.h>
// TF
#include <tf2_ros/buffer.h>
#include "message_filters/subscriber.h"
Expand All @@ -77,6 +79,8 @@ enum class Filters
// conveniences for line lengths
typedef std::list<observation::MeasurementReading>::iterator readings_iter;
typedef sensor_msgs::PointCloud2::Ptr point_cloud_ptr;
typedef spatio_temporal_voxel_layer::MeasurementBufferConfig dynamicReconfigureType;
typedef dynamic_reconfigure::Server<dynamicReconfigureType> dynamicReconfigureServerType;

// Measurement buffer
class MeasurementBuffer
Expand Down Expand Up @@ -105,7 +109,8 @@ class MeasurementBuffer
const int& voxel_min_points, \
const bool& enabled, \
const bool& clear_buffer_after_reading, \
const ModelType& model_type);
const ModelType& model_type, \
ros::NodeHandle& nh);

~MeasurementBuffer(void);

Expand Down Expand Up @@ -133,6 +138,11 @@ class MeasurementBuffer
// Removing old observations from buffer
void RemoveStaleObservations(void);

// Dynamic reconfigure
void DynamicReconfigureCallback(spatio_temporal_voxel_layer::MeasurementBufferConfig &config , uint32_t level);

ros::NodeHandle _node;
dynamicReconfigureServerType* _dynamic_reconfigure_server;
tf2_ros::Buffer& _buffer;
const ros::Duration _observation_keep_time, _expected_update_rate;
boost::recursive_mutex _lock;
Expand Down
3 changes: 2 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<package>
<name>spatio_temporal_voxel_layer</name>
<version>1.4.5</version>
<version>1.5.0</version>
<description>The spatio-temporal 3D obstacle costmap package</description>

<maintainer email="[email protected]">Steve Macenski</maintainer>
<maintainer email="[email protected]">Roberto Carta</maintainer>

<license>LGPL v2.1</license>

Expand Down
22 changes: 20 additions & 2 deletions src/measurement_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ MeasurementBuffer::MeasurementBuffer(const std::string& topic_name, \
const int& voxel_min_points, \
const bool& enabled, \
const bool& clear_buffer_after_reading, \
const ModelType& model_type) :
const ModelType& model_type, \
ros::NodeHandle& nh) :
/*****************************************************************************/
_buffer(tf), _observation_keep_time(observation_keep_time),
_expected_update_rate(expected_update_rate),_last_updated(ros::Time::now()),
Expand All @@ -79,14 +80,25 @@ MeasurementBuffer::MeasurementBuffer(const std::string& topic_name, \
_marking(marking), _clearing(clearing), _voxel_size(voxel_size),
_filter(filter), _voxel_min_points(voxel_min_points),
_enabled(enabled), _clear_buffer_after_reading(clear_buffer_after_reading),
_model_type(model_type)
_model_type(model_type), _node(nh)
{
// Dynamic reconfigure
_dynamic_reconfigure_server = new dynamicReconfigureServerType(_node);
dynamicReconfigureServerType::CallbackType f;
f = boost::bind(&MeasurementBuffer::DynamicReconfigureCallback, this, _1, _2);
_dynamic_reconfigure_server->setCallback(f);

}

/*****************************************************************************/
MeasurementBuffer::~MeasurementBuffer(void)
/*****************************************************************************/
{
if(_dynamic_reconfigure_server)
{
delete _dynamic_reconfigure_server;
_dynamic_reconfigure_server = nullptr;
}
}

/*****************************************************************************/
Expand Down Expand Up @@ -237,6 +249,12 @@ void MeasurementBuffer::RemoveStaleObservations(void)
}
}

void MeasurementBuffer::DynamicReconfigureCallback(spatio_temporal_voxel_layer::MeasurementBufferConfig &config , uint32_t level)
{
_min_obstacle_height = config.min_obstacle_height;
_max_obstacle_height = config.max_obstacle_height;
}

/*****************************************************************************/
void MeasurementBuffer::ResetAllMeasurements(void)
/*****************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions src/spatio_temporal_voxel_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
nh.param("observation_sources", topics_string, std::string(""));
// timeout in seconds for transforms
nh.param("transform_tolerance", transform_tolerance, 0.2);
// whether to default on
// whether to default on
nh.param("enabled", _enabled, true);
enabled_ = _enabled; // costmap_2d for some unexplicable reason uses globals
// publish the voxel grid to visualize
Expand Down Expand Up @@ -230,7 +230,7 @@ void SpatioTemporalVoxelLayer::onInitialize(void)
transform_tolerance, min_z, max_z, vFOV, vFOVPadding, hFOV, \
decay_acceleration, marking, clearing, _voxel_size, \
filter, voxel_min_points, enabled, clear_after_reading, \
model_type)));
model_type, source_node)));

// Add buffer to marking observation buffers
if (marking == true)
Expand Down