Skip to content

Commit

Permalink
Allow an envelope to be specified for is_in_lift
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey committed Nov 24, 2023
1 parent 9ce2aa0 commit a57591d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions rmf_traffic/include/rmf_traffic/agv/Graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ class Graph
Eigen::Vector2d dimensions() const;

/// Get whether the specified position, given in RMF canonical coordinates,
/// is inside the lift.
bool is_in_lift(Eigen::Vector2d position) const;
/// is inside the lift. The envelope will expand the footprint of the lift
/// that is used in the calculation.
bool is_in_lift(Eigen::Vector2d position, double envelope = 0.0) const;

/// Constructor
LiftProperties(
Expand Down
8 changes: 5 additions & 3 deletions rmf_traffic/src/rmf_traffic/agv/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ Eigen::Vector2d Graph::LiftProperties::dimensions() const
}

//==============================================================================
bool Graph::LiftProperties::is_in_lift(Eigen::Vector2d position) const
bool Graph::LiftProperties::is_in_lift(
Eigen::Vector2d position,
double envelope) const
{
Eigen::Vector2d p_local = _pimpl->tf_inv * position;
for (int i = 0; i < 2; ++i)
{
if (p_local[i] < -_pimpl->half_dimensions[i])
if (p_local[i] < -_pimpl->half_dimensions[i] - envelope)
return false;

if (_pimpl->half_dimensions[i] < p_local[i])
if (_pimpl->half_dimensions[i] + envelope < p_local[i])
return false;
}

Expand Down

0 comments on commit a57591d

Please sign in to comment.