Skip to content

Commit

Permalink
Extend RSS integration support
Browse files Browse the repository at this point in the history
Introduced more straight forward interface on intermediate functions to
support better integration of the single calls into an external
framework: SituationSnapshot, RssStateSnapshot, ProperResponse.

Moved the timeIndex from the individual elements into these high level
types to support the propagation of the timeIndex even if there are no
other vehicles in the surrounding (and therefore the respective vectors
are empty).

Renamed ResponseState -> RssState, ResponseStateVector ->
RssStateVector, ResponseInformation -> RssStateInformation,
ResponseEvaluator -> RssStateEvaluator to clarify by naming that the
individual calcuated states only consider a snapshot in time without the
analysis of dangerous threshold. They have nothing to do with the actual
proper response yet.

The ProperResponse as a new datatype got an own overall isSafe flag and
a list of dangerousObjects.

Added ObjectId to Situation and RssState to preserve the mapping to the
originating object which was lost with the introduction of multiple
situations per object.

Increase amount of allowed situations because with multiple  situations
per object the amount of 100 might be hit too fast.

Improved merge of input scenarios to facilitate scene variations of the
same situation introduced by e.g.:
- vehicle in the process of changing lane resulting in two scenes of the
same situation having different isInCorrectLane flags
- vehicles driving through an intersection having multiple potential
current lanes with different geometry resulting in multiple routes to be
treated as the same situation, but having different relative positions
and different velocities (situation:VehicleState::velocity became a
VelocityRange to cope with that)

RssIntersectionChecker: since new situations may pop up when e.g. a
previously occluded object is entering the field of view, one cannot
guarantee that a previous safe state can be found. In this case we have
to brake instead of returning false.

Change-Id: I2dec7bdf584aa62289a744fc2fc7ed788c699af9
  • Loading branch information
berndgassmann authored and fabianoboril committed May 27, 2019
1 parent fdb7c16 commit 337ecc3
Show file tree
Hide file tree
Showing 103 changed files with 7,303 additions and 3,215 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
## Latest changes
* Introduced more straight forward interface on intermediate functions to support better integration of the single calls into an external
framework: SituationSnapshot, RssStateSnapshot, ProperResponse. Moved the timeIndex from the individual elements into these high level
types to support the propagation of the timeIndex even if there are no other vehicles in the surrounding.
* Did some renaming (e.g. ResponseState->RssState, ResponseStateVector->RssStateVector, ResponseInformation->RssStateInformation,
ResponseEvaluator->RssStateEvaluator) to clarify by naming that the individual calcuated states only consider a snapshot in time without
analysis of the dangerous threshold. The ProperResponse became its own type and got an own overall isSafe flag and a list of dangerousObjects.
* Added ObjectId to Situation and RssState to preserve the mapping to the originating object which was lost with the introduction of multiple
situations per object.
* Increase amount of allowed situations because with multiple situations per object the amount of 100 might be hit too fast.
* Improved merge of input scenarios to facilitate scene variations of the same situation
* RssIntersectionChecker: since new situations may pop up when e.g. a previously occluded object is entering the field of view, one cannot guarantee that a previous safe state can be found. In this case, we have to brake instead of returning false.
* Made some RssState operations available via public interface
* Add option to select library build type (static/dynamic)

Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ option(BUILD_SHARED_LIBS "Libraries will be built as shared libraries" On)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
project(ad-rss-lib VERSION 1.3.0)
project(ad-rss-lib VERSION 1.4.0)

set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -100,7 +100,7 @@ set(GENERATED_SOURCES
src/generated/situation/SituationType.cpp
src/generated/state/LateralResponse.cpp
src/generated/state/LongitudinalResponse.cpp
src/generated/state/ResponseEvaluator.cpp
src/generated/state/RssStateEvaluator.cpp
src/generated/world/LaneDrivingDirection.cpp
src/generated/world/LaneSegmentType.cpp
src/generated/world/ObjectType.cpp
Expand Down Expand Up @@ -236,4 +236,3 @@ if(BUILD_STATIC_ANALYSIS)
-I${CMAKE_CURRENT_SOURCE_DIR}/src/generated/
)
endif()

46 changes: 36 additions & 10 deletions include/ad_rss/core/RssResponseResolving.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#pragma once

#include <map>
#include "ad_rss/state/ResponseStateVector.hpp"
#include "ad_rss/state/ProperResponse.hpp"
#include "ad_rss/state/RssStateSnapshot.hpp"

/*!
* @brief namespace ad_rss
Expand Down Expand Up @@ -67,32 +68,57 @@ class RssResponseResolving
/**
* @brief Calculate the proper response out of the current responses
*
* @param[in] currentStates all the response states gathered for the current situations
* @param[out] responseState the proper overall response state
* @param[in] currentStateSnapshot all the rss states gathered for the current situations
* @param[out] response the proper overall response state
*
* @return true if response could be calculated, false otherwise
* If false is returned the internal state has not been updated
*/
bool provideProperResponse(state::ResponseStateVector const &currentStates, state::ResponseState &responseState);
bool provideProperResponse(state::RssStateSnapshot const &currentStateSnapshot, state::ProperResponse &response);

private:
struct RssState
/**
* @brief determine the resulting RSS response
*
* @param[in] previousResponse the previous RSS response
* @param[in] newResponse the RSS response to be considered in addition
*
* The RSS responses are combined in a form that the most severe response of both becomes the resulting response.
* The responses are compared with each other based on the enumeration values.
* Therefore, these values need have to be ordered strictly ascending in respect to their severity.
*
* @returns the resulting RSS response
*/
template <typename Response>
static Response combineResponse(Response const &previousResponse, Response const &newResponse)
{
if (previousResponse > newResponse)
{
return previousResponse;
}
else
{
return newResponse;
}
}

struct RssSafeState
{
bool longitudinalSafe{false};
bool lateralSafe{false};
};

/**
* @brief typedef for the mapping of object id to the corresponding RssState before the danger threshold time
* @brief typedef for the mapping of object id to the corresponding RssSafeState before the danger threshold time
*/
typedef std::map<situation::SituationId, RssState> RssStateBeforeDangerThresholdTimeMap;
typedef std::map<situation::SituationId, RssSafeState> RssSafeStateBeforeDangerThresholdTimeMap;

/**
* @brief the state of all responses before the danger threshold time of each response
* @brief the state of each situation before the danger threshold time
*
* Needs to be stored to check which is the response that changed and required to solve an unclear situation
* Needs to be stored to check which is the proper response required to solve an unclear situation
*/
RssStateBeforeDangerThresholdTimeMap mStatesBeforeDangerThresholdTime;
RssSafeStateBeforeDangerThresholdTimeMap mStatesBeforeDangerThresholdTime;
};

} // namespace core
Expand Down
4 changes: 2 additions & 2 deletions include/ad_rss/core/RssResponseTransformation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#pragma once

#include "ad_rss/state/ResponseState.hpp"
#include "ad_rss/state/ProperResponse.hpp"
#include "ad_rss/world/AccelerationRestriction.hpp"
#include "ad_rss/world/WorldModel.hpp"

Expand Down Expand Up @@ -68,7 +68,7 @@ namespace RssResponseTransformation {
* @return return true if the acceleration restrictions could be calculated, false otherwise.
*/
bool transformProperResponse(world::WorldModel const &worldModel,
state::ResponseState const &response,
state::ProperResponse const &response,
world::AccelerationRestriction &accelerationRestriction);

} // namespace RssResponseTransformation
Expand Down
27 changes: 11 additions & 16 deletions include/ad_rss/core/RssSituationChecking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#pragma once

#include <memory>
#include "ad_rss/situation/SituationVector.hpp"
#include "ad_rss/state/ResponseStateVector.hpp"
#include "ad_rss/situation/SituationSnapshot.hpp"
#include "ad_rss/state/RssStateSnapshot.hpp"

/*!
* @brief namespace ad_rss
Expand Down Expand Up @@ -76,40 +76,35 @@ class RssSituationChecking
/*!
* @brief Checks if the current situations are safe.
*
* @param [in] situationVector the vector of situations that should be analyzed
* @param[out] responseStateVector the vector of response states for the current situations
* @param [in] situationSnapshot the situation snapshot in time that should be analyzed
* @param[out] rssStateSnapshot the rss state snapshot of these situations
*
* @return true if the situations could be analyzed, false if an error occurred during evaluation.
*/
bool checkSituations(situation::SituationVector const &situationVector,
state::ResponseStateVector &responseStateVector);
bool checkSituations(situation::SituationSnapshot const &situationSnapshot,
state::RssStateSnapshot &rssStateSnapshot);

private:
/*!
* @brief Check if the current situation is safe.
*
* @param[in] situation the Situation that should be analyzed
* @param[in] nextTimeStep indidicates that a new time step occurred
* @param[out] response the response state for the current situation
* @param[out] rssState the rssState state for the current situation
*
* @return true if situation could be analyzed, false if there was an error during evaluation
*/
bool checkSituationInputRangeChecked(situation::Situation const &situation,
bool const nextTimeStep,
state::ResponseState &response);
bool checkSituationInputRangeChecked(situation::Situation const &situation, state::RssState &rssState);

/*!
* @brief check to ensure situation time is consistent
* @brief check to ensure time index is consistent
*
* @param[in] situation the Situation that should be analyzed
* @param[in] nextTimeStep indidicates that a new time step occurred
* @param[in] nextTimeIndex the new time index
*
* @return true if the time is constantly increasing
*/
bool checkTimeIncreasingConsistently(situation::Situation const &situation, bool const nextTimeStep);
bool checkTimeIncreasingConsistently(physics::TimeIndex const &nextTimeIndex);

std::unique_ptr<ad_rss::situation::RssIntersectionChecker> mIntersectionChecker;
physics::TimeIndex mLastTimeIndex{0u};
physics::TimeIndex mCurrentTimeIndex{0u};
};
} // namespace core
Expand Down
14 changes: 10 additions & 4 deletions include/ad_rss/core/RssSituationExtraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#pragma once

#include "ad_rss/situation/SituationVector.hpp"
#include "ad_rss/situation/SituationSnapshot.hpp"
#include "ad_rss/world/WorldModel.hpp"

/*!
Expand Down Expand Up @@ -79,11 +79,11 @@ class RssSituationExtraction
* @brief Extract all RSS situations to be checked from the world model.
*
* @param [in] worldModel - the current world model information
* @param [out] situationVector - the vector of situations to be analyzed with RSS
* @param [out] situationSnapshot - the vector of situations to be analyzed with RSS
*
* @return true if the situations could be created, false if there was an error during the operation.
*/
bool extractSituations(world::WorldModel const &worldModel, situation::SituationVector &situationVector);
bool extractSituations(world::WorldModel const &worldModel, situation::SituationSnapshot &situationSnapshot);

private:
void calcluateRelativeLongitudinalPosition(physics::MetricRange const &egoMetricRange,
Expand Down Expand Up @@ -118,7 +118,13 @@ class RssSituationExtraction
world::RssDynamics const &egoVehicleRssDynamics,
world::Scene const &currentScene,
situation::Situation &situation);
bool mergeVehicleStates(situation::VehicleState const &otherVehicleState,
enum class MergeMode
{
EgoVehicle,
OtherVehicle
};
bool mergeVehicleStates(MergeMode const &mergeMode,
situation::VehicleState const &otherVehicleState,
situation::VehicleState &mergedVehicleState);
bool mergeSituations(situation::Situation const &otherSituation, situation::Situation &mergedSituation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#pragma once

#include "ad_rss/state/ResponseState.hpp"
#include "ad_rss/state/RssState.hpp"

/*!
* @brief namespace ad_rss
Expand All @@ -46,39 +46,39 @@ namespace ad_rss {
namespace state {

/**
* @brief is response state longitudinal safe
* @brief is rss state longitudinal safe
*
* @param[in] responseState to check
* @param[in] rssState to check
*
* true if safe, false if not
*/
inline bool isLongitudinalSafe(ResponseState const &responseState)
inline bool isLongitudinalSafe(RssState const &rssState)
{
return responseState.longitudinalState.isSafe;
return rssState.longitudinalState.isSafe;
}

/**
* @brief is response state lateral safe
* @brief is rss state lateral safe
*
* @param[in] responseState to check
* @param[in] rssState to check
*
* true if safe, false if not
*/
inline bool isLateralSafe(ResponseState const &responseState)
inline bool isLateralSafe(RssState const &rssState)
{
return responseState.lateralStateRight.isSafe && responseState.lateralStateLeft.isSafe;
return rssState.lateralStateRight.isSafe && rssState.lateralStateLeft.isSafe;
}

/**
* @brief is response state dangerous
* @brief is rss state dangerous
*
* @param[in] responseState to check
* @param[in] rssState to check
*
* true if dangerous, false if not
*/
inline bool isDangerous(ResponseState const &responseState)
inline bool isDangerous(RssState const &rssState)
{
return !isLongitudinalSafe(responseState) && !isLateralSafe(responseState);
return !isLongitudinalSafe(rssState) && !isLateralSafe(rssState);
}

} // namespace state
Expand Down
Loading

0 comments on commit 337ecc3

Please sign in to comment.