Pedestrians check if a vehicle is near before crossing
This commit is contained in:
parent
3280e1bd6e
commit
1c4b8c4bea
|
@ -47,9 +47,9 @@ namespace nav {
|
|||
static const int MAX_AGENTS = 500;
|
||||
static const int MAX_QUERY_SEARCH_NODES = 2048;
|
||||
static const float AGENT_HEIGHT = 1.8f;
|
||||
static const float AGENT_RADIUS = 0.3f;
|
||||
static const float AGENT_RADIUS = 0.4f;
|
||||
|
||||
static const float AGENT_UNBLOCK_DISTANCE = 1.0f;
|
||||
static const float AGENT_UNBLOCK_DISTANCE = 0.5f;
|
||||
static const float AGENT_UNBLOCK_DISTANCE_SQUARED = AGENT_UNBLOCK_DISTANCE * AGENT_UNBLOCK_DISTANCE;
|
||||
static const float AGENT_UNBLOCK_TIME = 2.0f;
|
||||
|
||||
|
@ -545,8 +545,8 @@ namespace nav {
|
|||
DEBUG_ASSERT(_crowd != nullptr);
|
||||
|
||||
// get the bounding box extension plus some space around
|
||||
float hx = vehicle.bounding.extent.x + 1.5f;
|
||||
float hy = vehicle.bounding.extent.y + 1.5f;
|
||||
float hx = vehicle.bounding.extent.x + 1.0f;
|
||||
float hy = vehicle.bounding.extent.y + 1.0f;
|
||||
// define the 4 corners of the bounding box
|
||||
cg::Vector3D boxCorner1 {-hx, -hy, 0};
|
||||
cg::Vector3D boxCorner2 { hx, -hy, 0};
|
||||
|
@ -1160,5 +1160,24 @@ namespace nav {
|
|||
agent->paused = pause;
|
||||
}
|
||||
|
||||
bool Navigation::hasVehicleNear(ActorId id) {
|
||||
// get the internal index (walker or vehicle)
|
||||
auto it = _mappedWalkersId.find(id);
|
||||
if (it == _mappedWalkersId.end()) {
|
||||
it = _mappedVehiclesId.find(id);
|
||||
if (it == _mappedVehiclesId.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool result;
|
||||
{
|
||||
// critical section, force single thread running this
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
result = _crowd->hasVehicleNear(it->second);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace nav
|
||||
} // namespace carla
|
||||
|
|
|
@ -93,6 +93,8 @@ namespace nav {
|
|||
void SetPedestriansCrossFactor(float percentage);
|
||||
/// set an agent as paused for the crowd
|
||||
void PauseAgent(ActorId id, bool pause);
|
||||
/// return if the agent has a vehicle near (as neighbour)
|
||||
bool hasVehicleNear(ActorId id);
|
||||
|
||||
dtCrowd *GetCrowd() { return _crowd; };
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "carla/Logging.h"
|
||||
#include "carla/nav/Navigation.h"
|
||||
#include "carla/nav/WalkerEvent.h"
|
||||
|
||||
namespace carla {
|
||||
|
@ -21,9 +22,8 @@ namespace nav {
|
|||
}
|
||||
|
||||
bool WalkerEventVisitor::operator()(WalkerEventStopAndCheck &event, double delta) {
|
||||
// refresh time and check
|
||||
event.time -= delta;
|
||||
return (event.time <= 0.0f);
|
||||
// check if the agent has any vehicle around
|
||||
return (!event.nav->hasVehicleNear(event.id));
|
||||
}
|
||||
|
||||
} // namespace nav
|
||||
|
|
|
@ -8,9 +8,14 @@
|
|||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include "carla/rpc/ActorId.h"
|
||||
// #include "carla/nav/Navigation.h"
|
||||
|
||||
namespace carla {
|
||||
namespace nav {
|
||||
|
||||
class Navigation;
|
||||
|
||||
struct WalkerEventIgnore {
|
||||
};
|
||||
|
||||
|
@ -20,8 +25,9 @@ namespace nav {
|
|||
};
|
||||
|
||||
struct WalkerEventStopAndCheck {
|
||||
double time;
|
||||
WalkerEventStopAndCheck(double duration) : time(duration) {};
|
||||
ActorId id;
|
||||
Navigation *nav;
|
||||
WalkerEventStopAndCheck(ActorId id, Navigation *nav) : id(id), nav(nav) {};
|
||||
};
|
||||
|
||||
using WalkerEvent = boost::variant<WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck>;
|
||||
|
|
|
@ -123,8 +123,7 @@ namespace nav {
|
|||
// stop and check
|
||||
case SAMPLE_POLYAREA_ROAD:
|
||||
case SAMPLE_POLYAREA_CROSS:
|
||||
// info.route.emplace_back(WalkerEventStopAndCheck(4), std::move(path[i]));
|
||||
info.route.emplace_back(WalkerEventIgnore(), std::move(path[i]));
|
||||
info.route.emplace_back(WalkerEventStopAndCheck(id, _nav), std::move(path[i]));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -289,7 +289,7 @@ unset GTEST_BASENAME
|
|||
# -- Get Recast&Detour and compile it with libc++ ------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
RECAST_COMMIT="163651bfa4aab314a1a3e7b1c476b3cbc5e4fdf1"
|
||||
RECAST_COMMIT="8af33f0c5ae996fe4223d2d40852c5fd06cf9f36"
|
||||
RECAST_BASENAME=recast-${CXX_TAG}
|
||||
|
||||
RECAST_INCLUDE=${PWD}/${RECAST_BASENAME}-install/include
|
||||
|
|
|
@ -38,7 +38,7 @@ set RECAST_INSTALL=recast-install
|
|||
set RECAST_INSTALL_DIR=%BUILD_DIR%%RECAST_INSTALL%\
|
||||
set RECAST_BUILD_DIR=%RECAST_SRC_DIR%build
|
||||
|
||||
set RECAST_COMMIT="163651bfa4aab314a1a3e7b1c476b3cbc5e4fdf1"
|
||||
set RECAST_COMMIT="8af33f0c5ae996fe4223d2d40852c5fd06cf9f36"
|
||||
set RECAST_BASENAME=%RECAST_SRC%
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue