Skip to content
Snippets Groups Projects
Commit 79ac383b authored by Christoph Kochendoerfer's avatar Christoph Kochendoerfer
Browse files

Added Trajectory and Polyline

parent 87f01366
No related branches found
No related tags found
1 merge request!14Trajectories
/*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file poly_line.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_POLY_LINE_H
#define MANTLEAPI_COMMON_POLY_LINE_H
#include <MantleAPI/Common/pose.h>
#include <MantleAPI/Common/time_utils.h>
#include <optional>
#include <vector>
namespace mantle_api
{
struct PolyLinePoint
{
Pose pose{};
std::optional<Time> time{};
bool operator== (const PolyLinePoint& other) const
{
return other.time == time
&& other.pose == pose;
}
friend std::ostream& operator<<(std::ostream& os, const PolyLinePoint& polyLinePoint);
};
inline std::ostream& operator<<(std::ostream& os, const PolyLinePoint& polyLinePoint)
{
os << polyLinePoint.pose;
if(polyLinePoint.time.has_value())
{
os << ", time in ms " << polyLinePoint.time.value().count();
}
return os;
}
using PolyLine = std::vector<PolyLinePoint>;
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_POLY_LINE_H
\ No newline at end of file
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <MantleAPI/Common/orientation.h> #include <MantleAPI/Common/orientation.h>
#include <MantleAPI/Common/vector.h> #include <MantleAPI/Common/vector.h>
#include <iostream>
namespace mantle_api namespace mantle_api
{ {
...@@ -24,8 +25,30 @@ struct Pose ...@@ -24,8 +25,30 @@ struct Pose
{ {
Vec3d position{}; Vec3d position{};
Orientation3d orientation{}; Orientation3d orientation{};
bool operator== (const Pose& other) const
{
return other.position == position
&& other.orientation == orientation;
}
friend inline std::ostream& operator<<(std::ostream& os, const Pose& pose);
}; };
std::ostream& operator<<(std::ostream& os, const Pose& pose)
{
os << "position ("
<< pose.position.x
<< ", " << pose.position.y
<< ", " << pose.position.z
<< "), orientation (" << pose.orientation.yaw
<< ", " << pose.orientation.pitch
<< ", " << pose.orientation.roll
<< ")";
return os;
}
} // namespace mantle_api } // namespace mantle_api
#endif // MANTLEAPI_COMMON_POSE_H #endif // MANTLEAPI_COMMON_POSE_H
/*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file trajectory.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_TRAJECTORY_H
#define MANTLEAPI_COMMON_TRAJECTORY_H
#include <string>
#include <variant>
#include <MantleAPI/Common/poly_line.h>
namespace mantle_api
{
struct Trajectory
{
std::string name;
std::variant<PolyLine> type;
friend std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory);
};
inline std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory)
{
os << "Trajectory \"" << trajectory.name;
if(std::holds_alternative<PolyLine>(trajectory.type))
{
const auto &polyLine = std::get<PolyLine>(trajectory.type);
for (const auto &polyLinePoint : polyLine)
{
os << polyLinePoint;
}
}
os << "\"\n";
return os;
}
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_TRAJECTORY_H
\ No newline at end of file
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <MantleAPI/Common/spline.h> #include <MantleAPI/Common/spline.h>
#include <MantleAPI/Common/vector.h> #include <MantleAPI/Common/vector.h>
#include <MantleAPI/Common/trajectory.h>
#include <vector> #include <vector>
...@@ -40,7 +41,8 @@ enum class ControlStrategyType ...@@ -40,7 +41,8 @@ enum class ControlStrategyType
kFollowLateralOffsetSpline, kFollowLateralOffsetSpline,
kFollowVelocitySpline, kFollowVelocitySpline,
kFollowRoute, kFollowRoute,
kAcquireLaneOffset kAcquireLaneOffset,
kFollowTrajectory
}; };
struct ControlStrategy struct ControlStrategy
...@@ -181,6 +183,25 @@ struct AcquireLaneOffsetControlStrategy : public ControlStrategy ...@@ -181,6 +183,25 @@ struct AcquireLaneOffsetControlStrategy : public ControlStrategy
TransitionDynamics transition_dynamics; TransitionDynamics transition_dynamics;
}; };
struct FollowTrajectoryControlStrategy : public ControlStrategy
{
struct TrajectoryTimeReference
{
std::string domainAbsoluteRelative;
double scale;
double offset;
};
FollowTrajectoryControlStrategy()
{
movement_domain = MovementDomain::kBoth;
type = ControlStrategyType::kAcquireLaneOffset;
}
Trajectory trajectory;
std::optional<TrajectoryTimeReference> timeReference;
};
} // namespace mantle_api } // namespace mantle_api
#endif // MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H #endif // MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H
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