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
Move ROS publishers and services to base class PlannerRos, use Planne…
…r state to publish start and goal state
  • Loading branch information
meychr committed May 14, 2021
commit 85723b842a65413c8e1fee98f81cf119f68a8b4c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,16 @@ class OmplReedsSheppPlannerRos : public PlannerRos {
bool plan() override;
void setParameters(const OmplReedsSheppPlannerRosParameters& parameters);
void publishPath() const final;
void publishPathNavMsgs() const final;
void publishStartState() const final;
void publishGoalState() const final;
void publishStateSpaceBoundaryMarker() final;

private:
void initRos();
void publishPathNavMsgs() const;
void publishStartGoalMsgs(const ReedsSheppState& start, const ReedsSheppState& goal) const;
void initializeStateSpaceBoundaryMarker();
void publishStateSpaceBoundaryMarker();
bool planningService(PlanningService::Request& req, PlanningService::Response& res) override;

ros::Publisher pathNavMsgsPublisher_;
ros::Publisher pathPublisher_;
ros::Publisher startPublisher_;
ros::Publisher goalPublisher_;
ros::Publisher stateSpacePublisher_;

ros::ServiceServer planningService_;

const int reedsSheppStateSpaceDim_ = 2;
int planSeqNumber_ = -1;
ros::Time planTimeStamp_{0.0};
Expand Down
11 changes: 11 additions & 0 deletions se2_planning_ros/include/se2_planning_ros/PlannerRos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class PlannerRos : public Planner {

void setPlanningStrategy(std::shared_ptr<Planner> planner);
virtual void publishPath() const;
virtual void publishPathNavMsgs() const;
virtual void publishStartState() const;
virtual void publishGoalState() const;
virtual void publishStateSpaceBoundaryMarker();

protected:
using PlanningService = se2_navigation_msgs::RequestPathSrv;
Expand All @@ -36,6 +40,13 @@ class PlannerRos : public Planner {

ros::NodeHandlePtr nh_;
std::shared_ptr<Planner> planner_;
ros::ServiceServer planningService_;

ros::Publisher pathNavMsgsPublisher_;
ros::Publisher pathPublisher_;
ros::Publisher startPublisher_;
ros::Publisher goalPublisher_;
ros::Publisher stateSpacePublisher_;
};

} /* namespace se2_planning*/
80 changes: 44 additions & 36 deletions se2_planning_ros/src/OmplReedsSheppPlannerRos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ bool OmplReedsSheppPlannerRos::planningService(PlanningService::Request& req, Pl
}

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

// Use state validator only after lock mutex is active and state space is updated
Expand All @@ -114,23 +115,32 @@ bool OmplReedsSheppPlannerRos::planningService(PlanningService::Request& req, Pl
}

void OmplReedsSheppPlannerRos::initRos() {
pathNavMsgsPublisher_ = nh_->advertise<nav_msgs::Path>(parameters_.pathNavMsgTopic_, 1, true);
planningService_ = nh_->advertiseService(parameters_.planningSerivceName_, &OmplReedsSheppPlannerRos::planningService, this);
pathNavMsgsPublisher_ = nh_->advertise<nav_msgs::Path>(parameters_.pathNavMsgTopic_, 1, true);
pathPublisher_ = nh_->advertise<se2_navigation_msgs::PathMsg>(parameters_.pathMsgTopic_, 1);
startPublisher_ = nh_->advertise<geometry_msgs::PoseStamped>("start", 1);
goalPublisher_ = nh_->advertise<geometry_msgs::PoseStamped>("goal", 1);
stateSpacePublisher_ = nh_->advertise<visualization_msgs::Marker>("state_space", 1);
}

void OmplReedsSheppPlannerRos::publishPathNavMsgs() const {
ReedsSheppPath rsPath;
planner_->as<OmplPlanner>()->getInterpolatedPath(&rsPath, parameters_.pathNavMsgResolution_);
nav_msgs::Path msg = se2_planning::copyAllPoints(rsPath);
msg.header.frame_id = parameters_.pathFrame_;
msg.header.stamp = planTimeStamp_;
msg.header.seq = planSeqNumber_;
pathNavMsgsPublisher_.publish(msg);
ROS_INFO_STREAM("Publishing ReedsShepp path nav msg, num states: " << msg.poses.size());
void OmplReedsSheppPlannerRos::initializeStateSpaceBoundaryMarker() {
double lineWidth = 0.01;
std_msgs::ColorRGBA color;
// No transparency
color.a = 1;
// Black
color.r = 0;
color.g = 0;
color.b = 0;
// Init marker
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::publishPath() const {
Expand All @@ -144,37 +154,35 @@ void OmplReedsSheppPlannerRos::publishPath() const {
ROS_INFO_STREAM("Publishing ReedsShepp path, num states: " << rsPath.numPoints());
}

void OmplReedsSheppPlannerRos::publishStartGoalMsgs(const ReedsSheppState& start, const ReedsSheppState& goal) const {
void OmplReedsSheppPlannerRos::publishPathNavMsgs() const {
ReedsSheppPath rsPath;
planner_->as<OmplPlanner>()->getInterpolatedPath(&rsPath, parameters_.pathNavMsgResolution_);
nav_msgs::Path msg = se2_planning::copyAllPoints(rsPath);
msg.header.frame_id = parameters_.pathFrame_;
msg.header.stamp = planTimeStamp_;
msg.header.seq = planSeqNumber_;
pathNavMsgsPublisher_.publish(msg);
ROS_INFO_STREAM("Publishing ReedsShepp path nav msg, num states: " << msg.poses.size());
}

void OmplReedsSheppPlannerRos::publishStartState() const {
geometry_msgs::PoseStamped startPose;
startPose.header.frame_id = parameters_.pathFrame_;
startPose.header.stamp = planTimeStamp_;
startPose.pose = se2_planning::convert(start);
ReedsSheppState startState{};
getStartingState(&startState);
startPose.pose = se2_planning::convert(startState);
startPublisher_.publish(startPose);
geometry_msgs::PoseStamped goalPose;
goalPose.header.frame_id = parameters_.pathFrame_;
goalPose.header.stamp = planTimeStamp_;
goalPose.pose = se2_planning::convert(goal);
goalPublisher_.publish(goalPose);
}

void OmplReedsSheppPlannerRos::initializeStateSpaceBoundaryMarker() {
double lineWidth = 0.01;
std_msgs::ColorRGBA color;
// No transparency
color.a = 1;
// Black
color.r = 0;
color.g = 0;
color.b = 0;
// Init marker
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::publishGoalState() const {
geometry_msgs::PoseStamped startPose;
startPose.header.frame_id = parameters_.pathFrame_;
startPose.header.stamp = planTimeStamp_;
ReedsSheppState goalState{};
getStartingState(&goalState);
startPose.pose = se2_planning::convert(goalState);
startPublisher_.publish(startPose);
}

void OmplReedsSheppPlannerRos::publishStateSpaceBoundaryMarker() {
Expand Down
23 changes: 23 additions & 0 deletions se2_planning_ros/src/PlannerRos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,54 @@ void PlannerRos::publishPath() const {
throw std::runtime_error("Publish path not implemented");
}

void PlannerRos::publishPathNavMsgs() const {
throw std::runtime_error("Publish path nav msgs not implemented");
}

void PlannerRos::publishStartState() const {
throw std::runtime_error("Publish start state not implemented");
}

void PlannerRos::publishGoalState() const {
throw std::runtime_error("Publish goal state not implemented");
}

void PlannerRos::publishStateSpaceBoundaryMarker() {
throw std::runtime_error("Publish state space boundary marker not implemented");
}

void PlannerRos::setPlanningStrategy(std::shared_ptr<Planner> planner) {
planner_ = planner;
}

void PlannerRos::setStartingState(const State& startingState) {
planner_->setStartingState(startingState);
}

void PlannerRos::setGoalState(const State& goalState) {
planner_->setGoalState(goalState);
}

bool PlannerRos::plan() {
return planner_->plan();
}

void PlannerRos::getPath(Path* path) const {
planner_->getPath(path);
}

bool PlannerRos::reset() {
return planner_->reset();
}

bool PlannerRos::initialize() {
return planner_->initialize();
}

void PlannerRos::getStartingState(State* startingState) const {
planner_->getStartingState(startingState);
}

void PlannerRos::getGoalState(State* goalState) const {
planner_->getGoalState(goalState);
}
Expand Down