Skip to content

Commit

Permalink
WIP: multiple obstacle sources
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Jun 28, 2021
1 parent 8029686 commit 461045d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void prepare_selfdriving(mvsim::World& world)
grid->getOccGrid().getAsPointCloud(*obsPts);
});

sd.navigator.config_.obstacleSource =
sd.navigator.config_.globalMapObstacleSource =
selfdriving::ObstacleSource::FromStaticPointcloud(obsPts);

// Vehicle interface:
Expand Down
3 changes: 2 additions & 1 deletion libselfdriving/include/selfdriving/algos/TPS_RRTstar.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class TPS_RRTstar : public mrpt::system::COutputLogger

mrpt::maps::CPointsMap::Ptr cached_local_obstacles(
const MotionPrimitivesTreeSE2& tree, const TNodeID nodeID,
const mrpt::maps::CPointsMap& globalObstacles, double MAX_XY_DIST);
const std::vector<mrpt::maps::CPointsMap::Ptr>& globalObstacles,
double MAX_XY_DIST);

/** for use in cached_local_obstacles(), local_obstacles_cache_ */
struct LocalObstaclesInfo
Expand Down
3 changes: 2 additions & 1 deletion libselfdriving/include/selfdriving/algos/WaypointSequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class WaypointSequencer : public mrpt::system::COutputLogger
* @{ */
VehicleMotionInterface::Ptr vehicleMotionInterface;

ObstacleSource::Ptr obstacleSource;
ObstacleSource::Ptr globalMapObstacleSource;
ObstacleSource::Ptr localSensedObstacleSource;

TrajectoriesAndRobotShape ptgs;

Expand Down
8 changes: 4 additions & 4 deletions libselfdriving/include/selfdriving/data/PlannerInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace selfdriving
{
struct PlannerInput
{
SE2_KinState stateStart, stateGoal;
mrpt::math::TPose2D worldBboxMin, worldBboxMax; //!< World bounds
ObstacleSource::Ptr obstacles;
TrajectoriesAndRobotShape ptgs;
SE2_KinState stateStart, stateGoal;
mrpt::math::TPose2D worldBboxMin, worldBboxMax; //!< World bounds
std::vector<ObstacleSource::Ptr> obstacles;
TrajectoriesAndRobotShape ptgs;
};

} // namespace selfdriving
9 changes: 6 additions & 3 deletions libselfdriving/src/algos/TPS_RRTstar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ PlannerOutput TPS_RRTstar::plan(const PlannerInput& in)
const DrawFreePoseParams drawParams(in, tree, searchRadius, goalNodeId);

// obstacles (TODO: dynamic over future time?):
const auto obstaclePoints = in.obstacles->obstacles();
std::vector<mrpt::maps::CPointsMap::Ptr> obstaclePoints;
for (const auto& os : in.obstacles)
if (os) obstaclePoints.emplace_back(os->obstacles());

// 3 | for i \in [1,N] do
for (size_t rrtIter = 0; rrtIter < params_.maxIterations; rrtIter++)
Expand Down Expand Up @@ -194,7 +196,7 @@ PlannerOutput TPS_RRTstar::plan(const PlannerInput& in)
// if (dist < params_.minStepLength)break;

const auto& localObstacles = cached_local_obstacles(
tree, nodeId, *obstaclePoints, MAX_XY_DIST);
tree, nodeId, obstaclePoints, MAX_XY_DIST);

const auto& srcNode = tree.nodes().at(nodeId);
auto& ptg = *in.ptgs.ptgs.at(ptgIdx);
Expand Down Expand Up @@ -883,7 +885,8 @@ TPS_RRTstar::path_to_nodes_list_t TPS_RRTstar::find_reachable_nodes_from(

mrpt::maps::CPointsMap::Ptr TPS_RRTstar::cached_local_obstacles(
const MotionPrimitivesTreeSE2& tree, const TNodeID nodeID,
const mrpt::maps::CPointsMap& globalObstacles, double MAX_XY_DIST)
const std::vector<mrpt::maps::CPointsMap::Ptr>& globalObstacles,
double MAX_XY_DIST)
{
// reuse?
const auto& node = tree.nodes().at(nodeID);
Expand Down
28 changes: 20 additions & 8 deletions libselfdriving/src/algos/WaypointSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void WaypointSequencer::initialize()

// Check that config_ holds all the required fields:
ASSERT_(config_.vehicleMotionInterface);
ASSERT_(config_.obstacleSource);
ASSERT_(config_.globalMapObstacleSource);
ASSERT_(config_.ptgs.initialized());

// sanity check: PTG max distance must be >= than RRT* step lengths:
Expand Down Expand Up @@ -396,8 +396,6 @@ waypoint_idx_t WaypointSequencer::find_next_waypoint_for_planner()
WaypointSequencer::PathPlannerOutput WaypointSequencer::path_planner_function(
WaypointSequencer::PathPlannerInput ppi)
{
ppi.pi.obstacles = config_.obstacleSource;

const double RRT_BBOX_MARGIN = 4.0; // [meters]

mrpt::math::TBoundingBoxf bbox;
Expand Down Expand Up @@ -439,19 +437,33 @@ WaypointSequencer::PathPlannerOutput WaypointSequencer::path_planner_function(
// time profiler:
planner.profiler_.enable(false);

// Add cost maps:
MRPT_TODO("Add the static world cost map");
// ~~~~~~~~~~~~~~
// Add cost maps
// ~~~~~~~~~~~~~~

// cost map #1: obstacles from current sensors
// =============
#if 0
{
// cost map:
auto costmap =
selfdriving::CostEvaluatorCostMap::FromStaticPointObstacles(
*obsPts);

planner.costEvaluators_.push_back(costmap);
}
#endif
MRPT_TODO("Add the preferred waypoints cost map");

// cost map #2: prefer to go thru waypoints
// =============
MRPT_TODO("Add this cost map");

// ~~~~~~~~~~~~~~~~~~
// Obstacles sources
// ~~~~~~~~~~~~~~~~~~
if (config_.globalMapObstacleSource)
ppi.pi.obstacles.push_back(config_.globalMapObstacleSource);

if (config_.localSensedObstacleSource)
ppi.pi.obstacles.push_back(config_.localSensedObstacleSource);

// verbosity level:
planner.setMinLoggingLevel(this->getMinLoggingLevel());
Expand Down
15 changes: 9 additions & 6 deletions libselfdriving/src/algos/render_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,18 @@ auto selfdriving::render_tree(
// Obstacles:
if (ro.draw_obstacles)
{
auto obj = mrpt::opengl::CPointCloud::Create();
for (const auto& os : pi.obstacles)
{
auto obj = mrpt::opengl::CPointCloud::Create();

const auto obs = pi.obstacles->obstacles();
const auto obs = os->obstacles();

obj->loadFromPointsMap(obs.get());
obj->loadFromPointsMap(obs.get());

obj->setPointSize(ro.point_size_obstacles);
obj->setColor_u8(ro.color_obstacles);
scene.insert(obj);
obj->setPointSize(ro.point_size_obstacles);
obj->setColor_u8(ro.color_obstacles);
scene.insert(obj);
}
}

// The current set of local obstacles:
Expand Down

0 comments on commit 461045d

Please sign in to comment.