Skip to content

Commit

Permalink
Make some ResponseStateOperations public
Browse files Browse the repository at this point in the history
  • Loading branch information
berndgassmann authored and fabianoboril committed May 14, 2019
1 parent 1920cc3 commit fdb7c16
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 49 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Latest changes
* Made some RssState operations available via public interface
* Add option to select library build type (static/dynamic)

## Release 1.3.0
* Allow multiple situations per ego vehicle/object pair: Add RssSituationIdProvider and made RssSituationExtraction a class holding RssSituationIdProvider instance to keep track of the different situation classes
* Renamed world::Dynamics in world::RssDynamics, extended it by responseTime and separated it from world::Object; world::Scene got the objectRssDynamics and world::WorldModel the egoVehicleRssDynamics each as separate elements
Expand Down
85 changes: 85 additions & 0 deletions include/ad_rss/state/ResponseStateOperation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// ----------------- BEGIN LICENSE BLOCK ---------------------------------
//
// Copyright (c) 2018-2019 Intel Corporation
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ----------------- END LICENSE BLOCK -----------------------------------
/**
* @file
*/

#pragma once

#include "ad_rss/state/ResponseState.hpp"

/*!
* @brief namespace ad_rss
*/
namespace ad_rss {
/*!
* @brief namespace for RSS state datatypes and operations
*/
namespace state {

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

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

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

} // namespace state
} // namespace ad_rss
2 changes: 1 addition & 1 deletion src/core/RssCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool RssCheck::calculateAccelerationRestriction(world::WorldModel const &worldMo
// if the worldModel contains no relevant object (or no objects at all)
// the responseStateVector will be empty. Thus, we need to add a "all safe" response
state::ResponseState const safeResponse
= state::createResponseState(worldModel.timeIndex, situation::SituationId(0), state::IsSafe::Yes);
= createResponseState(worldModel.timeIndex, situation::SituationId(0), IsSafe::Yes);
responseStateVector.push_back(safeResponse);
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/RssResponseResolving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "ad_rss/core/RssResponseResolving.hpp"
#include <algorithm>
#include "ad_rss/state/ResponseStateOperation.hpp"
#include "ad_rss/state/ResponseStateVectorValidInputRange.hpp"
#include "core/RssState.hpp"

Expand All @@ -53,7 +54,7 @@ bool RssResponseResolving::provideProperResponse(state::ResponseStateVector cons
// global try catch block to ensure this library call doesn't throw an exception
try
{
responseState = state::createResponseState(physics::TimeIndex(0u), situation::SituationId(0), state::IsSafe::Yes);
responseState = createResponseState(physics::TimeIndex(0u), situation::SituationId(0), IsSafe::Yes);

RssStateBeforeDangerThresholdTimeMap newStatesBeforeDangerThresholdTime;

Expand Down
4 changes: 2 additions & 2 deletions src/core/RssSituationChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ bool RssSituationChecking::checkSituationInputRangeChecked(situation::Situation
return false;
}

response = state::createResponseState(situation.timeIndex, situation.situationId, state::IsSafe::No);
response = createResponseState(situation.timeIndex, situation.situationId, IsSafe::No);

switch (situation.situationType)
{
case situation::SituationType::NotRelevant:
response = state::createResponseState(situation.timeIndex, situation.situationId, state::IsSafe::Yes);
response = createResponseState(situation.timeIndex, situation.situationId, IsSafe::Yes);
result = true;
break;
case situation::SituationType::SameDirection:
Expand Down
42 changes: 3 additions & 39 deletions src/core/RssState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,9 @@
*/
namespace ad_rss {
/*!
* @brief namespace for RSS state datatypes and operations
* @brief namespace core
*/
namespace state {

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

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

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

/**
* @brief determine the resulting RSS state
Expand Down Expand Up @@ -147,5 +111,5 @@ inline state::ResponseState createResponseState(physics::TimeIndex const &timeIn
return safeResponse;
}

} // namespace state
} // namespace core
} // namespace ad_rss
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ set(RSS_TEST_SOURCES
core/RssSituationExtractionSameDirectionTests.cpp
core/RssSituationIdProviderTests.cpp
core/RssStateCombineRssStateTests.cpp
core/RssStateSafeTests.cpp
physics/MathUnitTestsDistanceOffsetAfterResponseTime.cpp
physics/MathUnitTestsInputRangeChecks.cpp
physics/MathUnitTestsStoppingDistance.cpp
physics/MathUnitTestsTimeToCoverDistance.cpp
physics/MathUnitTestsVelocityAfterResponseTime.cpp
state/RssStateSafeTests.cpp
situation/RssFormulaTestsCalculateDistanceAfterStatedBrakingPattern.cpp
situation/RssFormulaTestsCalculateSafeLateralDistance.cpp
situation/RssFormulaTestsCalculateSafeLongitudinalDistanceSameDirection.cpp
Expand Down
4 changes: 2 additions & 2 deletions tests/core/RssStateCombineRssStateTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "core/RssState.hpp"

namespace ad_rss {
namespace state {
namespace core {

TEST(RssStateCombineRssStateTests, longitudinal_previous_Safe)
{
Expand Down Expand Up @@ -105,5 +105,5 @@ TEST(RssStateCombineRssStateTests, lateral_previous_BrakeMin)
cTestSupport.cLateralBrakeMin);
}

} // namespace state
} // namespace core
} // namespace ad_rss
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
//
// ----------------- END LICENSE BLOCK -----------------------------------

#include <ad_rss/state/ResponseStateOperation.hpp>
#include "TestSupport.hpp"
#include "core/RssState.hpp"

namespace ad_rss {
namespace core {
namespace state {

TEST(RssStateSafeTests, isSafe)
{
Expand Down Expand Up @@ -153,5 +153,5 @@ TEST(RssStateSafeTests, longitudinal_lateralLeft_BrakeMin)
ASSERT_FALSE(isLateralSafe(responseState));
}

} // namespace core
} // namespace state
} // namespace ad_rss

0 comments on commit fdb7c16

Please sign in to comment.