Skip to content
Snippets Groups Projects
Commit 8eadb734 authored by Reinhard Biegel's avatar Reinhard Biegel
Browse files

mod(Observation_Log): Restructure of observation data flow

- Implementation of BasicDataStore
- Usage if Publisher interface instead of Observations->Inserts
- Observations are parameterizable now
parent 67543b4d
No related branches found
No related tags found
No related merge requests found
Showing
with 550 additions and 350 deletions
BasedOnStyle: llvm
Language: Cpp
ColumnLimit: 0
IndentWidth: 4
AccessModifierOffset: -4
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<(gtest|gmock)/)'
Priority: -1
- Regex: '^<[^Q]'
Priority: 1
- Regex: '^<Q'
Priority: 2
AlignTrailingComments: true
BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AllowShortFunctionsOnASingleLine: None
KeepEmptyLinesAtTheStartOfBlocks: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
\ No newline at end of file
......@@ -35,6 +35,21 @@ Then the AgentType with the components and channels is build by the DynamicAgent
![AgentBlueprintProviderSequenceDiagram](AgentBlueprintProviderSequence.svg)
\section dev_framework_modules_datastore DataStore
The DataStore accepts arbitrary values from different components (from framework as well as agents).
The stored values if cyclic and acyclic type are associated with an timestamp, entity id and a key (topic).
Static values are only associated with a key.
Typically, Observers are using the DataStore to retrieve information about the simulation.
This can happen during the simulation run and/or at the end of a run.
For the keys, a generic datatype is used (strings).
For the values, a set of predefined datatypes is used (bool, char, int, size_t, float, double, string).
A value can also hold a vector of one of the mentioned datatypes.
For information about the usage, please refer to the implementation's inline documentation.
\section dev_framework_modules_eventdetectors EventDetectors
[//]: <> "Please refer to each section!"
......
/*******************************************************************************
* Copyright (c) 2017, 2018, 2019 in-tech GmbH
* Copyright (c) 2017, 2018, 2019, 2020 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
......@@ -20,6 +20,8 @@
#pragma once
#include <vector>
#include "Interfaces/eventInterface.h"
//-----------------------------------------------------------------------------
......@@ -30,115 +32,125 @@
class BasicEvent : public EventInterface
{
public:
BasicEvent(int time,
std::string eventName,
std::string source):
BasicEvent(int time, std::string eventName, std::string source,
const std::vector<int> triggeringAgents, const std::vector<int> actingAgents) :
time(time),
name(eventName),
source(source)
{}
BasicEvent(const BasicEvent&) = delete;
BasicEvent(BasicEvent&&) = delete;
BasicEvent& operator=(const BasicEvent&) = delete;
BasicEvent& operator=(BasicEvent&&) = delete;
source(source),
triggeringAgents(triggeringAgents),
actingAgents(actingAgents)
{
}
BasicEvent(int time, std::string eventName, std::string source) :
time(time),
name(eventName),
source(source),
triggeringAgents{},
actingAgents{}
{
}
virtual ~BasicEvent() override = default;
/*!
* \brief Sets the Id of the event.
*
* @param[in] Id of the event.
*/
virtual void SetId(const int eventId) override
{
this->eventId = eventId;
}
/*!
* \brief Returns the Id of the event.
*
* @return Id.
*/
virtual int GetId() const override
{
return eventId;
}
/*!
* \brief Returns the time of the event.
*
* @return Time in milliseconds.
*/
virtual int GetEventTime() const override
{
return time;
}
/*!
* \brief Returns the category of the event.
*
* @return EventCategory.
*/
virtual EventDefinitions::EventCategory GetCategory() const override
{
return EventDefinitions::EventCategory::Basic;
}
/*!
* \brief Sets the Id of the event which triggered this event.
*
* @param[in] Event Id.
*/
virtual void SetTriggeringEventId(const int triggeringEventId) override
{
this->triggeringEventId = triggeringEventId;
}
/*!
* \brief Returns the Id of the event which triggered this event.
*
* @return Event Id.
*/
virtual int GetTriggeringEventId() const override
{
return triggeringEventId;
}
/*!
* \brief Returns the name of the event.
*
* @return Name of the event as string.
*/
virtual std::string GetName() const override
{
return name;
}
/*!
* \brief Returns the name of the source component.
*
* @return Name of source component as string.
*/
virtual std::string GetSource() const override
{
return source;
}
/*!
* \brief Returns all parameters of the event as string list.
* \details Returns all parameters of the event as a generic string list.
* The parameter name and the value are returned as string.
*
* @return List of string pairs of the event parameters.
*/
virtual const std::vector<int> GetTriggeringAgents() const override
{
return triggeringAgents;
}
virtual const std::vector<int> GetActingAgents() const override
{
return actingAgents;
}
virtual EventParameters GetParametersAsString() override
{
return {};
EventParameters eventParameters;
std::string triggeringAgentsAsString{};
for (auto &triggeringAgentId : triggeringAgents)
{
triggeringAgentsAsString += std::to_string(triggeringAgentId) + ",";
}
std::string actingAgentsAsString;
for (auto &actingAgentId : actingAgents)
{
actingAgentsAsString += std::to_string(actingAgentId) + ",";
}
if (!triggeringAgentsAsString.empty())
{
triggeringAgentsAsString.pop_back();
eventParameters.push_back({"TriggeringAgentIds", triggeringAgentsAsString});
}
if (!actingAgentsAsString.empty())
{
actingAgentsAsString.pop_back();
eventParameters.push_back({"ActingAgentIds", actingAgentsAsString});
}
return eventParameters;
}
const openpass::type::FlatParameter &GetParameter() const noexcept override
{
return parameter;
}
private:
int eventId;
const int time;
int triggeringEventId {-1};
const std::string name;
const std::string source;
int eventId{};
int triggeringEventId{-1};
public:
const std::vector<int> triggeringAgents;
const std::vector<int> actingAgents;
protected:
openpass::type::FlatParameter parameter{};
};
......@@ -14,7 +14,6 @@
*
* This class contains all functionality of the module. */
//-----------------------------------------------------------------------------
#pragma once
#include "basicEvent.h"
......@@ -27,54 +26,32 @@
class CollisionEvent : public BasicEvent
{
public:
CollisionEvent(int time,
std::string source,
bool collisionWithAgent,
int collisionAgentId,
int collisionOpponentId):
BasicEvent(time,
"Collision",
source),
collisionWithAgent(collisionWithAgent),
collisionAgentId(collisionAgentId),
collisionOpponentId(collisionOpponentId)
{}
CollisionEvent(const CollisionEvent&) = delete;
CollisionEvent(CollisionEvent&&) = delete;
CollisionEvent& operator=(const CollisionEvent&) = delete;
CollisionEvent& operator=(CollisionEvent&&) = delete;
virtual ~CollisionEvent() override = default;
/*!
* \brief Returns the category of the event.
*
* @return EventCategory.
*/
virtual EventDefinitions::EventCategory GetCategory() const override
CollisionEvent(int time, std::string source, bool collisionWithAgent, int collisionAgentId, int collisionOpponentId) :
BasicEvent{time, "Collision", source, {collisionAgentId, collisionOpponentId}, {}},
collisionWithAgent{collisionWithAgent},
collisionAgentId{collisionAgentId},
collisionOpponentId{collisionOpponentId}
{
return EventDefinitions::EventCategory::Collision;
parameter.emplace("CollisionWithAgent", collisionWithAgent);
}
/*!
* \brief Returns all parameters of the event as string list.
* \details Returns the CollisionWithAgent flag and both worldobject ids as string list.
*
* @return List of string pairs of the event parameters.
*/
virtual EventParameters GetParametersAsString() override
~CollisionEvent() override = default;
EventDefinitions::EventCategory GetCategory() const override
{
EventParameters eventParameters;
return EventDefinitions::EventCategory::OpenPASS;
}
EventParameters GetParametersAsString() override
{
EventParameters eventParameters = BasicEvent::GetParametersAsString();
eventParameters.push_back({"CollisionWithAgent", collisionWithAgent ? "true" : "false"});
eventParameters.push_back({"CollisionAgentId", std::to_string(collisionAgentId)});
eventParameters.push_back({"CollisionOpponentId", std::to_string(collisionOpponentId)});
return eventParameters;
}
bool collisionWithAgent;
int collisionAgentId;
int collisionOpponentId;
[[deprecated("Will be replaced by BasicEvent::parameter")]] bool collisionWithAgent;
[[deprecated("Will be replaced by BasicEvent::parameter")]] int collisionAgentId;
[[deprecated("Will be replaced by BasicEvent::parameter")]] int collisionOpponentId;
};
......@@ -17,10 +17,11 @@
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <map>
#include <unordered_map>
#include <boost/algorithm/string/trim.hpp>
#include "globalDefinitions.h"
#include "vector2d.h"
......@@ -318,6 +319,27 @@ public:
}
};
namespace helper::vector {
/// \brief convenience function to convert a vector into a string using a constom delimiter
/// \remark Please refer to the standard, how decimals are converted
/// \param values vector of strings
/// \param delimiter string in between the individual values
/// \return delimiter seperated list as string
template <typename T>
std::string to_string(const std::vector<T>& values, const std::string& delimiter = ",")
{
if (values.empty())
{
return "";
}
std::ostringstream oss;
std::copy(values.begin(), values.end(), std::ostream_iterator<T>(oss, delimiter.c_str()));
return {oss.str(), 0, oss.str().length() - delimiter.size()};
}
} // namespace helper::vector
namespace helper::map {
/// @brief queries a map for a given key and returns the value if available
......
......@@ -33,44 +33,43 @@
class ComponentChangeEvent : public ConditionalEvent
{
public:
ComponentChangeEvent(int time,
const std::string& eventName,
const std::string& source,
std::vector<int> triggeringAgents,
std::vector<int> actingAgents,
const std::string& componentName,
const std::string& goalStateName):
ConditionalEvent(time,
eventName,
source,
triggeringAgents,
actingAgents),
componentName(componentName),
goalStateName(goalStateName)
ComponentChangeEvent(int time, const std::string &eventName, const std::string &source,
std::vector<int> triggeringAgents, std::vector<int> actingAgents,
const std::string &componentName, const std::string &goalStateName) :
ConditionalEvent{time, eventName, source, triggeringAgents, actingAgents},
componentName{componentName},
goalStateName{goalStateName}
{
goalState = ComponentStateMapping.at(goalStateName);
parameter.emplace("ComponentName", componentName);
parameter.emplace("GoalStateName", goalStateName);
}
ComponentChangeEvent(const ComponentChangeEvent&) = delete;
ComponentChangeEvent(ComponentChangeEvent&&) = delete;
ComponentChangeEvent& operator=(const ComponentChangeEvent&) = delete;
ComponentChangeEvent& operator=(ComponentChangeEvent&&) = delete;
virtual ~ComponentChangeEvent() override = default;
/*!
* \brief Returns the category of the event.
*
* @return EventCategory.
*/
virtual EventDefinitions::EventCategory GetCategory() const override
~ComponentChangeEvent() override = default;
EventDefinitions::EventCategory GetCategory() const override
{
return EventDefinitions::EventCategory::ComponentStateChange;
}
EventParameters GetParametersAsString() override
{
EventParameters eventParameters = ConditionalEvent::GetParametersAsString();
eventParameters.push_back({"ComponentName", componentName});
eventParameters.push_back({"State", goalStateName});
return eventParameters;
}
/*!
* \brief Returns the component name for which the event is targeted
* @return Component Name
*/
std::string GetComponentName() const {
std::string GetComponentName() const
{
return componentName;
}
......@@ -78,7 +77,8 @@ public:
* \brief Returns the goal state name for which the event is targeted
* @return State Name
*/
std::string GetGoalStateName() const {
std::string GetGoalStateName() const
{
return goalStateName;
}
......@@ -86,24 +86,9 @@ public:
* \brief Returns the goal state as a result of the event
* @return State
*/
ComponentState GetGoalState() const {
return goalState;
}
/*!
* \brief Returns all parameters of the event as string list.
* \details Returns the agentId as string list.
*
* @return List of string pairs of the event parameters.
*/
virtual EventParameters GetParametersAsString() override
ComponentState GetGoalState() const
{
EventParameters eventParameters = ConditionalEvent::GetParametersAsString();
eventParameters.push_back({"ComponentName", componentName});
eventParameters.push_back({"State", goalStateName});
return eventParameters;
return goalState;
}
private:
......
/*******************************************************************************
* Copyright (c) 2019 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include "vehicleComponentEvent.h"
#include "Interfaces/signalInterface.h"
/*!
* ----------------------------------------------------------------------------
* \brief The ComponentWarningEvent class contains all information related to
* an event emitted in response to a Component Warning.
* ----------------------------------------------------------------------------
*/
class ComponentWarningEvent : public VehicleComponentEvent
{
public:
ComponentWarningEvent(const int time,
const std::string& source,
const int agentId,
const std::string& componentName,
const ComponentWarningInformation& warning):
VehicleComponentEvent(time,
"",
source,
agentId),
componentName(componentName),
warning(warning)
{}
ComponentWarningEvent(const ComponentWarningEvent&) = delete;
ComponentWarningEvent(ComponentWarningEvent&&) = delete;
ComponentWarningEvent& operator=(const ComponentWarningEvent&) = delete;
ComponentWarningEvent& operator=(ComponentWarningEvent&&) = delete;
virtual ~ComponentWarningEvent() override = default;
/*!
* \brief Returns the component name for which the event is targeted
* @return Component Name
*/
std::string GetComponentName() const
{
return componentName;
}
/*!
* \brief GetComponentWarningInformation gets the information regarding the warning from the event
* \return Component warning information
*/
ComponentWarningInformation GetComponentWarningInformation() const
{
return warning;
}
/*!
* \brief Returns all parameters of the event as string list.
* \details Returns the agentId as string list.
*
* @return List of string pairs of the event parameters.
*/
virtual EventParameters GetParametersAsString() override
{
auto eventParameters = VehicleComponentEvent::GetParametersAsString();
eventParameters.push_back({"ComponentName", componentName});
eventParameters.push_back({"Activity", warning.activity ? "true" : "false"});
eventParameters.push_back({"Level", ComponentWarningLevelMapping.at(warning.level)});
eventParameters.push_back({"Type", ComponentWarningTypeMapping.at(warning.type)});
eventParameters.push_back({"Intensity", ComponentWarningIntensityMapping.at(warning.intensity)});
return eventParameters;
}
private:
const std::string componentName; //!< The name of the component that has a warning
const ComponentWarningInformation warning; //!< The collected information regarding the warning
};
/*******************************************************************************
* Copyright (c) 2017, 2018, 2019 in-tech GmbH
* Copyright (c) 2017, 2018, 2019, 2020 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
......@@ -8,13 +8,6 @@
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file AgentBasedEvent.h
* @brief This file contains all functions for agent based events.
*
* This class contains all functionality of the module. */
//-----------------------------------------------------------------------------
#pragma once
#include <vector>
......@@ -22,71 +15,23 @@
#include "basicEvent.h"
//-----------------------------------------------------------------------------
/** This class implements all functionality of the AgentBasedEvent.
/** This class implements all functionality of the ConditionalEvent.
*
* \ingroup Event */
//-----------------------------------------------------------------------------
class ConditionalEvent : public BasicEvent
{
public:
ConditionalEvent(int time,
std::string eventName,
std::string source,
std::vector<int> triggeringAgents,
std::vector<int> actingAgents):
BasicEvent(time,
eventName,
source),
triggeringAgents(triggeringAgents),
actingAgents(actingAgents)
{}
~ConditionalEvent() override = default;
/*!
* \brief Returns the category of the event.
*
* @return EventCategory.
*/
virtual EventDefinitions::EventCategory GetCategory() const override
ConditionalEvent(int time, std::string eventName, std::string source,
std::vector<int> triggeringAgents, std::vector<int> actingAgents) :
BasicEvent{time, eventName, source, triggeringAgents, actingAgents}
{
return EventDefinitions::EventCategory::Conditional;
}
/*!
* \brief Returns all parameters of the event as string list.
* \details Returns the agentId as string list.
*
* @return List of string pairs of the event parameters.
*/
EventParameters GetParametersAsString() override
{
EventParameters eventParameters;
std::string triggeringAgentsAsString{};
for (auto &triggeringAgentId : triggeringAgents) {
triggeringAgentsAsString += std::to_string(triggeringAgentId) + ",";
}
std::string actingAgentsAsString;
for (auto &actingAgentId : actingAgents) {
actingAgentsAsString += std::to_string(actingAgentId) + ",";
}
if(triggeringAgentsAsString.size() > 0)
{
triggeringAgentsAsString.pop_back();
eventParameters.push_back({"TriggeringAgentIds", triggeringAgentsAsString});
}
if(actingAgentsAsString.size() > 0)
{
actingAgentsAsString.pop_back();
eventParameters.push_back({"ActingAgentIds", actingAgentsAsString});
}
~ConditionalEvent() override = default;
return eventParameters;
EventDefinitions::EventCategory GetCategory() const override
{
return EventDefinitions::EventCategory::OpenSCENARIO;
}
const std::vector<int> triggeringAgents;
const std::vector<int> actingAgents;
};
......@@ -266,10 +266,13 @@ using Condition = std::variant<ReachPositionRoadCondition,
TimeHeadwayCondition>;
using ConditionCollection = std::vector<Condition>;
///
/// \brief Event specific information collected from an openSCENARIO story
///
struct ConditionalEventDetectorInformation
{
ActorInformation actorInformation{};
int numberOfExecutions{};
int numberOfExecutions{}; ///< Specifies number of executions. Use -1 for "unrestricted"
std::string eventName{};
ConditionCollection conditions{};
};
......
......@@ -14,20 +14,83 @@
#include <map>
#include <string>
namespace EventDefinitions
#include "Common/openPassTypes.h"
#include "Interfaces/dataStoreInterface.h" // TODO: RP: make datastore types (Acyclic, TriggeringEntites,...) explicitly available
namespace openpass::narrator {
class EventBase
{
public:
EventBase() = default;
EventBase(std::string name) :
name{std::move(name)}
{
}
EventBase(std::string name, TriggeringEntities triggeringEntities, AffectedEntities affectedEntities) :
name{std::move(name)},
triggeringEntities{std::move(triggeringEntities)},
affectedEntities{std::move(affectedEntities)}
{
}
std::string name;
TriggeringEntities triggeringEntities;
AffectedEntities affectedEntities;
virtual explicit operator Acyclic() const = 0;
// We do not allow copy to force move semantics
EventBase(const EventBase &) = delete;
EventBase &operator=(const EventBase &) = delete;
// Explicitly allow move
EventBase(EventBase &&) = default;
EventBase &operator=(EventBase &&) = default;
// Neccesary evil
virtual ~EventBase() = default;
};
}
namespace EventDefinitions {
enum struct EventCategory
{
Basic = 0,
Conditional,
Collision,
ComponentStateChange,
LaneChange,
CustomLaneChange,
SetTrajectory,
SetGazeFollower,
VehicleComponent
Basic, // deprecated
Conditional, // deprecated
Collision, // deprecated
ComponentStateChange, // deprecated
LaneChange, // deprecated
CustomLaneChange, // deprecated ?
SetTrajectory, // deprecated ?
SetGazeFollower, // deprecated ?
VehicleComponent, // deprecated
OpenPASS,
OpenSCENARIO
};
}//namespace EventDefinitions
namespace helper {
static constexpr std::array<const char *, 11> EventCategoryMapping{
"Basic",
"Conditional",
"Collision",
"ComponentStateChange",
"LaneChange",
"CustomLaneChange",
"SetTrajectory",
"SetGazeFollower",
"VehicleComponent",
"OpenPASS",
"OpenSCENARIO"};
constexpr auto GetAsString(EventCategory category)
{
return EventCategoryMapping[static_cast<size_t>(category)];
}
} // namespace helper
} //namespace EventDefinitions
/*******************************************************************************
* Copyright (c) 2017, 2018, 2019 in-tech GmbH
* Copyright (c) 2017, 2018, 2019, 2020 in-tech GmbH
* 2018, 2019 AMFD GmbH
* 2016, 2017, 2018, 2019 ITK Engineering GmbH
*
......@@ -15,8 +15,7 @@
//! @brief This file contains several classes for global purposes
//-----------------------------------------------------------------------------
#ifndef GLOBALDEFINITIONS
#define GLOBALDEFINITIONS
#pragma once
#include <list>
#include <map>
......@@ -103,20 +102,19 @@ inline AgentVehicleType GetAgentVehicleType(const std::string &strVehicleType)
// convert a AgentVehicleType to VehicleType string
inline std::string GetAgentVehicleTypeStr(const AgentVehicleType &vehicleType)
{
return (vehicleType == AgentVehicleType::Car) ? "Car" :
(vehicleType == AgentVehicleType::Pedestrian) ? "Pedestrian" :
(vehicleType == AgentVehicleType::Motorbike) ? "Motorbike" :
(vehicleType == AgentVehicleType::Bicycle) ? "Bicycle" :
(vehicleType == AgentVehicleType::Truck) ? "Truck" : "unknown type";
return (vehicleType == AgentVehicleType::Car) ? "Car" : (vehicleType == AgentVehicleType::Pedestrian) ? "Pedestrian" : (vehicleType == AgentVehicleType::Motorbike) ? "Motorbike" : (vehicleType == AgentVehicleType::Bicycle) ? "Bicycle" : (vehicleType == AgentVehicleType::Truck) ? "Truck" : "unknown type";
}
// convert a string of type code to VehicleType string
inline std::string GetAgentVehicleTypeStr(const std::string &vehicleTypeCode)
{
try{
try
{
AgentVehicleType vehicleType = static_cast<AgentVehicleType>(std::stoi(vehicleTypeCode));
return GetAgentVehicleTypeStr(vehicleType);
} catch(...) {
}
catch (...)
{
return "unknown type";
}
}
......@@ -139,23 +137,26 @@ enum class IndicatorState
struct Position
{
Position() {}
Position()
{
}
Position(double x,
double y,
double yaw,
double curvature):
double curvature) :
xPos(x),
yPos(y),
yawAngle(yaw),
curvature(curvature) {}
curvature(curvature)
{
}
double xPos {0};
double yPos {0};
double yawAngle {0};
double curvature {0};
double xPos{0};
double yPos{0};
double yawAngle{0};
double curvature{0};
};
//! Enum of potential types of marks.
enum class MarkType
{
......@@ -178,10 +179,10 @@ enum class ObjectType
enum ObjectTypeOSI : int
{
None = 0x00, // default at initialization
None = 0x00, // default at initialization
Vehicle = 0x01,
Object = 0x02,
Any = Vehicle | Object
Object = 0x02,
Any = Vehicle | Object
};
using CollisionPartner = std::pair<ObjectTypeOSI, int>;
......@@ -301,10 +302,9 @@ enum class AdasType
Undefined
};
const std::map<AdasType, std::string> adasTypeToString = { { AdasType::Safety, "Safety" },
{ AdasType::Comfort, "Comfort" },
{ AdasType::Undefined, "Undefined" }
};
const std::map<AdasType, std::string> adasTypeToString = {{AdasType::Safety, "Safety"},
{AdasType::Comfort, "Comfort"},
{AdasType::Undefined, "Undefined"}};
enum class ComponentType
{
......@@ -330,7 +330,8 @@ public:
weekday(weekday),
timeOfDay(timeOfDay),
libraryName(libraryName)
{}
{
}
WorldParameter(const WorldParameter &) = delete;
WorldParameter(WorldParameter &&) = delete;
WorldParameter &operator=(const WorldParameter &) = delete;
......@@ -367,7 +368,8 @@ public:
AgentSpawnItem(int id, int reference) :
id(id),
reference(reference)
{}
{
}
AgentSpawnItem(const AgentSpawnItem &) = delete;
AgentSpawnItem(AgentSpawnItem &&) = delete;
AgentSpawnItem &operator=(const AgentSpawnItem &) = delete;
......@@ -538,6 +540,3 @@ private:
double accelerationY;
double yawAngle;
};
#endif // GLOBALDEFINITIONS
/*******************************************************************************
* Copyright (c) 2020 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
namespace openpass::type {
template <typename T, typename Tag>
struct NamedType
{
T value;
NamedType(T value) :
value(value)
{
}
operator T() const
{
return value;
}
};
} // namespace openpass::type
......@@ -12,6 +12,7 @@
#include <string>
#include <vector>
#include "parameter.h"
#include "Interfaces/dataStoreInterface.h"
/**
* @brief Wrapper for building an ObservationInstance
......
......@@ -14,17 +14,74 @@
#define OBSERVATION_LOG_VALUE_UNDEFINED ""
#include <string>
#include <unordered_map>
#include <vector>
enum class LoggingGroup
//! Defines the cyclic coloumn names associated with each logging group
const std::unordered_map<std::string, std::vector<std::string>> LOGGINGGROUP_DEFINITIONS
{
Trace,
Visualization,
RoadPosition,
RoadPositionExtended,
Vehicle,
Sensor,
SensorExtended,
Driver
{ "RoadPosition", {
"AgentInFront",
"Lane",
"PositionRoute",
"Road",
"TCoordinate"
}
},
{ "RoadPositionExtended", {
"SecondaryLanes"
}
},
{ "Trace", {
"XPosition",
"YPosition",
"YawAngle"
}
},
{ "Sensor", {
}
},
{ "SensorExtended", {
"Sensor0_DetectedAgents",
"Sensor1_DetectedAgents",
"Sensor2_DetectedAgents",
"Sensor3_DetectedAgents",
"Sensor4_DetectedAgents",
"Sensor5_DetectedAgents",
"Sensor6_DetectedAgents",
"Sensor7_DetectedAgents",
"Sensor8_DetectedAgents",
"Sensor9_DetectedAgents",
"Sensor0_VisibleAgents",
"Sensor1_VisibleAgents",
"Sensor2_VisibleAgents",
"Sensor3_VisibleAgents",
"Sensor4_VisibleAgents",
"Sensor5_VisibleAgents",
"Sensor6_VisibleAgents",
"Sensor7_VisibleAgents",
"Sensor8_VisibleAgents",
"Sensor9_VisibleAgents"
}
},
{ "Vehicle", {
"AccelerationPedalPosition",
"BrakePedalPosition",
"EngineMoment",
"Gear",
"SteeringAngle",
"TotalDistanceTraveled",
"YawRate",
}
},
{ "Visualization", {
"AccelerationEgo",
"BrakeLight",
"IndicatorState",
"LightStatus",
"VelocityEgo"
}
}
};
const std::string AgentCategoryStrings[] =
......
/*******************************************************************************
* Copyright (c) 2020 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <functional>
#include <string>
#include <variant>
#include "namedType.h"
namespace openpass::type {
// TODO: MOVE TO CORE ONLY!
static constexpr int CoreId = 67798269; // ASCII: C O R E
using AgentId = int;
using EntityId = NamedType<AgentId, struct EntityIdType>;
using Timestamp = NamedType<int, struct TimestampType>;
using EntityIds = std::vector<EntityId>;
using FlatParameterKey = std::string;
using FlatParameterValue = std::variant<
bool, std::vector<bool>,
char, std::vector<char>,
int, std::vector<int>,
size_t, std::vector<size_t>,
float, std::vector<float>,
double, std::vector<double>,
std::string, std::vector<std::string>>;
using FlatParameter = std::unordered_map<FlatParameterKey, FlatParameterValue>;
} // namespace openpass::type
/*******************************************************************************
* Copyright (c) 2020 in-tech GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <functional>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
template <class... Ts>
struct overload : Ts...
{
using Ts::operator()...;
};
template <class... Ts>
overload(Ts...)->overload<Ts...>;
namespace openpass::utils {
namespace vector {
/// \brief convenience function to convert a vector into a string using a constom delimiter
/// \remark Please refer to the standard, how decimals are converted
/// \param values vector of strings
/// \param delimiter string in between the individual values
/// \return delimiter seperated list as string
template <typename T>
std::string to_string(const std::vector<T> &values, const std::string &delimiter = ",")
{
if (values.empty())
{
return "";
}
std::ostringstream oss;
std::copy(values.begin(), values.end(), std::ostream_iterator<T>(oss, delimiter.c_str()));
return {oss.str(), 0, oss.str().length() - delimiter.size()};
}
} // namespace vector
namespace FlatParameter {
/// \brief visitor for parameter values of events
/// Converts the visitor values into strings and forwards the result to writer callable
/// Values in vectors are converted and seperated by a delimiter.
/// If value is 12.34 => writer("12.34");
/// If value is {12.34, 23.45} => writer("12.34,23.45");
/// \see openpass::type::FlatParameterValue
/// \see openpass::utils::vector::to_string
/// \param[in] writer callable collecting the converted value
/// \param[in] delimiter used for vector type (default = ",")
[[maybe_unused]] static auto to_string(std::function<void(std::string)> writer, const std::string &delimiter = ",")
{
return overload{
//[&](std::string &value) { writer(value); },
[&](const std::string &value) { writer(value); },
[&](auto &value) {
if constexpr (std::is_arithmetic_v<std::decay_t<decltype(value)>>)
{
writer(std::to_string(value));
}
else // path for std::vector types
{
if (!value.empty())
{
writer(vector::to_string(value, delimiter));
}
}
},
};
}
} // namespace FlatParameter
} // namespace openpass::utils
......@@ -56,7 +56,7 @@ struct StochasticAttribute
struct ActorInformation
{
std::optional<bool> triggeringAgentsAsActors{};
bool actorIsTriggeringEntity{false};
std::optional<std::vector<std::string>> actors{};
};
......
......@@ -9,9 +9,11 @@
*******************************************************************************/
#pragma once
#include <optional>
#include <string>
#include <utility>
#include <variant>
#include <vector>
#include <optional>
#include "Common/stochasticDefinitions.h"
......
......@@ -32,12 +32,18 @@ public:
VehicleComponentEvent(int time,
const std::string &eventName,
std::string source,
int agentId):
int agentId) :
BasicEvent(time,
eventName,
source),
source,
{agentId},
{}),
agentId(agentId)
{}
{
parameter.emplace("Source", source);
parameter.emplace("State", eventName);
}
VehicleComponentEvent(const VehicleComponentEvent&) = delete;
VehicleComponentEvent(VehicleComponentEvent&&) = delete;
VehicleComponentEvent& operator=(const VehicleComponentEvent&) = delete;
......
......@@ -10,6 +10,8 @@
#pragma once
#include <limits>
#include "globalDefinitions.h"
#include <set>
#include "boost/graph/adjacency_list.hpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment