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

Initial draft of changes for online map / planner updates #12

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
745d2d0
Add functionality to update map (and the planner state space boundari…
meychr Apr 5, 2021
51f0bac
Make class member of StateValidator private
meychr May 13, 2021
c8ad75d
Make some class functions constant
meychr May 13, 2021
0d0bcc0
Unify name of state space boundaries to StateSpaceBoundaries
meychr May 13, 2021
07efb89
Reorder member variables
meychr May 13, 2021
b492b7f
Implement getStartingState and getGoalState for OmplReedsSheppPlanner
meychr May 14, 2021
85723b8
Move ROS publishers and services to base class PlannerRos, use Planne…
meychr May 14, 2021
f24ce13
Make isStateValid constant
meychr May 14, 2021
11075fe
Fix typo
meychr May 14, 2021
8c0bc04
Move StateValidator functions to Planner interface
meychr May 14, 2021
0072859
Adapt se2_grid_map_generator config and add TODOs to fix frames
meychr May 19, 2021
db4a618
Set state space bounds changes
meychr May 19, 2021
2735940
Fix formatting
meychr May 19, 2021
6b3863b
Move getStateSpaceBoundaries to OmplPlanner
meychr May 19, 2021
4704095
Remove comment
meychr May 19, 2021
808bd65
Reorder code and remove TODO
meychr May 29, 2021
21e3385
Fix format
meychr Jun 7, 2021
5c1afb2
Implement map interface and occupancy map & adapt height map
meychr Jun 7, 2021
fc57077
Add ROS class for occupancy map
meychr Jun 7, 2021
632a7f6
Integrate new map for state space boundaries update, adapt tests
meychr Jun 7, 2021
db5da4d
Uncomment isTraversable again
meychr Jun 7, 2021
80db121
Make GridMapLazyStateValidatorRos similar to OccupancyMapRos
meychr Jun 7, 2021
ad3095d
Change config file to use elevation for collision checking in state v…
meychr Jun 7, 2021
d07c579
Increase footprint size in car_demo
meychr Jun 7, 2021
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
Prev Previous commit
Next Next commit
Unify name of state space boundaries to StateSpaceBoundaries
  • Loading branch information
meychr committed May 13, 2021
commit 0d0bcc061f20563fb01b03194bbd5181cd9bb672
2 changes: 1 addition & 1 deletion se2_planning/include/se2_planning/OmplPlanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OmplPlanner : public Planner {
void getInterpolatedPath(Path* interpolatedPath, unsigned int numPoints) const;
ompl::geometric::SimpleSetupPtr getSimpleSetup() const;
void setOmplPlanner(ompl::base::PlannerPtr planner);
virtual void updateStateSpaceBounds(const ompl::base::RealVectorBounds& bounds);
virtual void updateStateSpaceBoundaries(const ompl::base::RealVectorBounds& bounds);

protected:
virtual void initializeStateSpace() = 0;
Expand Down
4 changes: 2 additions & 2 deletions se2_planning/include/se2_planning/OmplReedsSheppPlanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class OmplReedsSheppPlanner final : public OmplPlanner {
void lockStateValidator();
void unlockStateValidator();
bool isLocked() const;
void updateStateSpaceBounds(const ompl::base::RealVectorBounds& bounds) override;
bool satisfiesStateSpaceBounds(const se2_planning::ReedsSheppState& state) const;
void updateStateSpaceBoundaries(const ompl::base::RealVectorBounds& bounds) override;
bool satisfiesStateSpaceBoundaries(const se2_planning::ReedsSheppState& state) const;
const ompl::base::RealVectorBounds& getStateSpaceBoundaries() const;

private:
Expand Down
2 changes: 1 addition & 1 deletion se2_planning/src/OmplPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool OmplPlanner::initialize() {
return true;
}

void OmplPlanner::updateStateSpaceBounds(const ompl::base::RealVectorBounds& bounds) {
void OmplPlanner::updateStateSpaceBoundaries(const ompl::base::RealVectorBounds& bounds) {
throw std::runtime_error("Not implemented");
}

Expand Down
4 changes: 2 additions & 2 deletions se2_planning/src/OmplReedsSheppPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ompl::base::RealVectorBounds& OmplReedsSheppPlanner::getStateSpaceBoundari
return stateSpace_->as<ompl::base::SE2StateSpace>()->getBounds();
}

void OmplReedsSheppPlanner::updateStateSpaceBounds(const ompl::base::RealVectorBounds& bounds) {
void OmplReedsSheppPlanner::updateStateSpaceBoundaries(const ompl::base::RealVectorBounds& bounds) {
bounds_->low[0] = bounds.low[0];
bounds_->low[1] = bounds.low[1];
bounds_->high[0] = bounds.high[0];
Expand All @@ -90,7 +90,7 @@ void OmplReedsSheppPlanner::updateStateSpaceBounds(const ompl::base::RealVectorB
// << bounds_->low[1] << ", " << bounds_->high[1] << "]" << std::endl;
}

bool OmplReedsSheppPlanner::satisfiesStateSpaceBounds(const se2_planning::ReedsSheppState& state) const {
bool OmplReedsSheppPlanner::satisfiesStateSpaceBoundaries(const se2_planning::ReedsSheppState& state) const {
ompl::base::ScopedStatePtr stateOmpl(std::make_shared<ompl::base::ScopedState<> >(stateSpace_));
auto s = ((*stateOmpl)())->as<ompl::base::SE2StateSpace::StateType>();
auto rsState = state.as<ReedsSheppState>();
meychr marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ class OmplReedsSheppPlannerRos : public PlannerRos {
void initRos();
void publishPathNavMsgs() const;
void publishStartGoalMsgs(const ReedsSheppState& start, const ReedsSheppState& goal) const;
void initializeStateSpaceMarker();
void publishStateSpaceMarker();
void initializeStateSpaceBoundaryMarker();
void publishStateSpaceBoundaryMarker();
bool planningService(PlanningService::Request& req, PlanningService::Response& res) override;

ros::Publisher pathNavMsgsPublisher_;
ros::Publisher pathPublisher_;
ros::Publisher startPublisher_;
meychr marked this conversation as resolved.
Show resolved Hide resolved
ros::Publisher goalPublisher_;
ros::Publisher stateSpacePublisher_;
visualization_msgs::Marker stateSpaceMarker_;

visualization_msgs::Marker stateSpaceBoundaryMarker_;
OmplReedsSheppPlannerRosParameters parameters_;
ros::ServiceServer planningService_;
int planSeqNumber_ = -1;
Expand Down
71 changes: 35 additions & 36 deletions se2_planning_ros/src/OmplReedsSheppPlannerRos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void OmplReedsSheppPlannerRos::setParameters(const OmplReedsSheppPlannerRosParam
bool OmplReedsSheppPlannerRos::initialize() {
bool result = BASE::initialize();
initRos();
initializeStateSpaceMarker();
initializeStateSpaceBoundaryMarker();
return result;
}
bool OmplReedsSheppPlannerRos::plan() {
Expand Down Expand Up @@ -65,30 +65,30 @@ bool OmplReedsSheppPlannerRos::planningService(PlanningService::Request& req, Pl
// TODO expose stateSpaceBoundsMargin_ as param => depends on footprint size?
// TODO move to OMPLReedsSheppPlanner.cpp?
const double stateSpaceBoundsMargin_ = parameters_.stateSpaceBoundsMargin_;
if (!planner_->as<OmplReedsSheppPlanner>()->satisfiesStateSpaceBounds(start)) {
if (!planner_->as<OmplReedsSheppPlanner>()->satisfiesStateSpaceBoundaries(start)) {
ROS_DEBUG("Initial state not in grid map. Enlarge state space boundaries.");
const auto bounds = planner_->as<OmplReedsSheppPlanner>()->getStateSpaceBoundaries();
ompl::base::RealVectorBounds newBounds(reedsSheppStateSpaceDim_);
newBounds.high[0] = std::max(bounds.high[0], start.x_ + stateSpaceBoundsMargin_);
newBounds.high[1] = std::max(bounds.high[1], start.y_ + stateSpaceBoundsMargin_);
newBounds.low[0] = std::min(bounds.low[0], start.x_ - stateSpaceBoundsMargin_);
newBounds.low[1] = std::min(bounds.low[1], start.y_ - stateSpaceBoundsMargin_);
planner_->as<OmplReedsSheppPlanner>()->updateStateSpaceBounds(newBounds);
planner_->as<OmplReedsSheppPlanner>()->updateStateSpaceBoundaries(newBounds);
}
if (!planner_->as<OmplReedsSheppPlanner>()->satisfiesStateSpaceBounds(goal)) {
if (!planner_->as<OmplReedsSheppPlanner>()->satisfiesStateSpaceBoundaries(goal)) {
ROS_DEBUG("Goal state not in grid map. Enlarge state space boundaries.");
const auto bounds = planner_->as<OmplReedsSheppPlanner>()->getStateSpaceBoundaries();
ompl::base::RealVectorBounds newBounds(reedsSheppStateSpaceDim_);
newBounds.high[0] = std::max(bounds.high[0], goal.x_ + stateSpaceBoundsMargin_);
newBounds.high[1] = std::max(bounds.high[1], goal.y_ + stateSpaceBoundsMargin_);
newBounds.low[0] = std::min(bounds.low[0], goal.x_ - stateSpaceBoundsMargin_);
newBounds.low[1] = std::min(bounds.low[1], goal.y_ - stateSpaceBoundsMargin_);
planner_->as<OmplReedsSheppPlanner>()->updateStateSpaceBounds(newBounds);
planner_->as<OmplReedsSheppPlanner>()->updateStateSpaceBoundaries(newBounds);
}

// TODO move to detach? Better to publish this info for debugging before checking validity of states.
publishStartGoalMsgs(start, goal);
publishStateSpaceMarker();
publishStateSpaceBoundaryMarker();

// Use state validator only after lock mutex is active and state space is updated
// Checks only for non-traversable terrain not for state space bounds
Expand Down Expand Up @@ -157,47 +157,46 @@ void OmplReedsSheppPlannerRos::publishStartGoalMsgs(const ReedsSheppState& start
goalPublisher_.publish(goalPose);
}

void OmplReedsSheppPlannerRos::initializeStateSpaceMarker() {
// TODO expose as params?
double lineWidth_ = 0.01;
std_msgs::ColorRGBA color_;
void OmplReedsSheppPlannerRos::initializeStateSpaceBoundaryMarker() {
double lineWidth = 0.01;
std_msgs::ColorRGBA color;
// No transparency
color_.a = 1;
color.a = 1;
// Black
color_.r = 0;
color_.g = 0;
color_.b = 0;
color.r = 0;
color.g = 0;
color.b = 0;
// Init marker
int nVertices_ = 5;
stateSpaceMarker_.ns = "state_space";
stateSpaceMarker_.lifetime = ros::Duration();
stateSpaceMarker_.action = visualization_msgs::Marker::ADD;
stateSpaceMarker_.type = visualization_msgs::Marker::LINE_STRIP;
stateSpaceMarker_.scale.x = lineWidth_;
stateSpaceMarker_.points.resize(nVertices_); // Initialized to [0.0, 0.0, 0.0]
stateSpaceMarker_.colors.resize(nVertices_, color_);
int nVertices = 5;
stateSpaceBoundaryMarker_.ns = "state_space";
stateSpaceBoundaryMarker_.lifetime = ros::Duration();
stateSpaceBoundaryMarker_.action = visualization_msgs::Marker::ADD;
stateSpaceBoundaryMarker_.type = visualization_msgs::Marker::LINE_STRIP;
stateSpaceBoundaryMarker_.scale.x = lineWidth;
stateSpaceBoundaryMarker_.points.resize(nVertices); // Initialized to [0.0, 0.0, 0.0]
stateSpaceBoundaryMarker_.colors.resize(nVertices, color);
}

void OmplReedsSheppPlannerRos::publishStateSpaceMarker() {
void OmplReedsSheppPlannerRos::publishStateSpaceBoundaryMarker() {
// Set marker info.
stateSpaceMarker_.header.frame_id = parameters_.pathFrame_;
stateSpaceMarker_.header.stamp = planTimeStamp_;
stateSpaceBoundaryMarker_.header.frame_id = parameters_.pathFrame_;
stateSpaceBoundaryMarker_.header.stamp = planTimeStamp_;

// Set positions of markers.
const auto bounds = planner_->as<OmplReedsSheppPlanner>()->getStateSpaceBoundaries();
stateSpaceMarker_.points[0].x = bounds.low[0];
stateSpaceMarker_.points[0].y = bounds.low[1];
stateSpaceMarker_.points[1].x = bounds.high[0];
stateSpaceMarker_.points[1].y = bounds.low[1];
stateSpaceMarker_.points[2].x = bounds.high[0];
stateSpaceMarker_.points[2].y = bounds.high[1];
stateSpaceMarker_.points[3].x = bounds.low[0];
stateSpaceMarker_.points[3].y = bounds.high[1];
stateSpaceBoundaryMarker_.points[0].x = bounds.low[0];
stateSpaceBoundaryMarker_.points[0].y = bounds.low[1];
stateSpaceBoundaryMarker_.points[1].x = bounds.high[0];
stateSpaceBoundaryMarker_.points[1].y = bounds.low[1];
stateSpaceBoundaryMarker_.points[2].x = bounds.high[0];
stateSpaceBoundaryMarker_.points[2].y = bounds.high[1];
stateSpaceBoundaryMarker_.points[3].x = bounds.low[0];
stateSpaceBoundaryMarker_.points[3].y = bounds.high[1];
// Close the rectangle with the fifth point
stateSpaceMarker_.points[4].x = stateSpaceMarker_.points[0].x;
stateSpaceMarker_.points[4].y = stateSpaceMarker_.points[0].y;
stateSpaceBoundaryMarker_.points[4].x = stateSpaceBoundaryMarker_.points[0].x;
stateSpaceBoundaryMarker_.points[4].y = stateSpaceBoundaryMarker_.points[0].y;

stateSpacePublisher_.publish(stateSpaceMarker_);
stateSpacePublisher_.publish(stateSpaceBoundaryMarker_);
}

} /* namespace se2_planning */
2 changes: 1 addition & 1 deletion se2_planning_ros/src/se2_planner_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void gridMapCallback(const grid_map_msgs::GridMap& msg) {
bounds.high[1] = mapPosition.y() + mapLength.y() / 2.0;

if (!planner->isLocked()) {
planner->updateStateSpaceBounds(bounds);
planner->updateStateSpaceBoundaries(bounds);
ROS_DEBUG_STREAM("OMPL State Space Update: pos: " << mapPosition.x() << ", " << mapPosition.y() << ", length: " << mapLength.x() << ", "
<< mapLength.y());
} else {
Expand Down