Skip to content

Commit

Permalink
Merge release/lavida (4.5.0) branch into carma-master (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN authored Apr 9, 2024
2 parents 7f810c7 + 07e0577 commit a4c819d
Show file tree
Hide file tree
Showing 86 changed files with 7,071 additions and 2,728 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# Pull docker image from docker hub
# XTERM used for better catkin_make output
docker:
- image: usdotfhwastol/carma-base:carma-system-4.4.0
- image: usdotfhwastol/carma-base:carma-system-4.5.0
user: carma
environment:
TERM: xterm
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Docker
name: Docker build

on:
push:
branches-ignore:
- "carma-develop"
- "master"
- "release/*"
pull_request:
types: [opened, synchronize, reopened]

jobs:
docker:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-8-cores
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -16,4 +20,4 @@ jobs:
- name: Build
uses: docker/build-push-action@v3
with:
context: .
context: .
30 changes: 10 additions & 20 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
name: DockerHub
name: Docker Hub build

on:
push:
branches:
- "carma-develop"

- "master"
- "release/*"
tags:
- "carma-system-*"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: usdotfhwastoldev/${{ github.event.repository.name }}:develop
dockerhub:
uses: usdot-fhwa-stol/actions/.github/workflows/dockerhub.yml@main
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM usdotfhwastol/carma-base:carma-system-4.4.0 AS base_image
FROM usdotfhwastol/carma-base:carma-system-4.5.0 AS base_image

FROM base_image AS build

Expand Down
3 changes: 3 additions & 0 deletions common/autoware_build_flags/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ else() #ROS2

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS
cmake/autoware_build_flags-extras.cmake
)
ament_auto_package()

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
endif()

find_package(ros_environment REQUIRED)
set(ROS_VERSION $ENV{ROS_VERSION})

if (${ROS_VERSION} EQUAL 1)
# Enable support for C++14
if(${CMAKE_VERSION} VERSION_LESS "3.1.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
set(CMAKE_CXX_STANDARD 14)
if(${CMAKE_VERSION} VERSION_LESS "3.1.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
set(CMAKE_CXX_STANDARD 14)
endif()
else() # ROS2
set(CMAKE_CXX_STANDARD 17)
endif()

message(STATUS "CUDA compilation status: $ENV{AUTOWARE_COMPILE_WITH_CUDA}.")
Expand Down
1 change: 1 addition & 0 deletions common/autoware_build_flags/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<license>Apache 2</license>

<buildtool_depend>ros_environment</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake_auto</buildtool_depend>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ namespace hardcoded_params
namespace control_limits
{
/**
* The maximum allowable longitudinal velocity of the vehicle in m/s
* The maximum allowable longitudinal velocity of the vehicle in m/s
*/
constexpr double MAX_LONGITUDINAL_VELOCITY_MPS = 35.7632;
constexpr double MAX_LONGITUDINAL_ACCEL_MPS2 = 3.5;

/**
* The maximum allowable simulation parameters
* At the time of writing this, platform uses CARLA 0.9.10 as the vehicle's physics simulator.
* CARLA 0.9.10 uses below hardcoded value for its vehicles (so even if increasing this value,
* actual simulation won't support larger values unless forked and compiled)
* https://github.com/carla-simulator/ros-bridge/blob/0.9.10.1/carla_ackermann_control/src/carla_ackermann_control/carla_control_physics.py#L254
*/
constexpr double MAX_SIMULATION_LONGITUDINAL_ACCEL_MPS2 = 8.0;

}
} // namespace hardcoded_params
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
namespace lanelet
{
/**
* @brief: Enum representing Traffic Light States.
* @brief: Enum representing Traffic Light States.
* These states match the SAE J2735 PhaseState definitions used for SPaT messages
*
*
* UNAVAILABLE : No data available
* DARK : Light is non-functional
* STOP_THEN_PROCEED : Flashing Red
Expand All @@ -53,6 +53,15 @@ enum class CarmaTrafficSignalState {
CAUTION_CONFLICTING_TRAFFIC=9
};

namespace time{

//This int is max representable number by 32bit which the posix::time library is using.
//It corresponds to 03:14:07 on Tuesday, 19 January 2038.

constexpr auto INFINITY_END_TIME_FOR_NOT_ENOUGH_STATES{2147483647};

}

struct CarmaTrafficSignalRoleNameString
{
static constexpr char ControlStart[] = "control_start";
Expand All @@ -67,7 +76,7 @@ std::ostream& operator<<(std::ostream& os, CarmaTrafficSignalState s);
/**
* @brief: Class representing a known timing traffic light.
* Normally the traffic light timing information is provided by SAE J2735 SPaT messages although alternative data sources can be supported
*
*
* @ingroup RegulatoryElementPrimitives
* @ingroup Primitives
*/
Expand All @@ -79,7 +88,7 @@ class CarmaTrafficSignal : public lanelet::RegulatoryElement

int revision_ = 0; //indicates when was this last modified
boost::posix_time::time_duration fixed_cycle_duration;
std::vector<boost::posix_time::ptime> recorded_start_time_stamps; //user must ensure it's 1 to 1 with recorded_time_stamps ,
std::vector<boost::posix_time::ptime> recorded_start_time_stamps; //user must ensure it's 1 to 1 with recorded_time_stamps ,
//used in dynamic SPAT processing
std::vector<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> recorded_time_stamps;
std::unordered_map<CarmaTrafficSignalState, boost::posix_time::time_duration> signal_durations;
Expand All @@ -98,11 +107,11 @@ class CarmaTrafficSignal : public lanelet::RegulatoryElement
* NOTE: Order of the lanelets does not correlate to the order of the control_end lanelets
*/
lanelet::ConstLanelets getControlStartLanelets() const;

/**
* @brief getControlEndLanelets function returns lanelets where this element's control ends
* NOTE: Order of the lanelets does not correlate to the order of the control_start lanelets
*
*
*/
lanelet::ConstLanelets getControlEndLanelets() const;

Expand All @@ -115,7 +124,7 @@ class CarmaTrafficSignal : public lanelet::RegulatoryElement
* @throw InvalidInputError if timestamps recorded somehow did not have full cycle
*/
boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> predictState(boost::posix_time::ptime time_stamp);

/**
* @brief Return the stop_lines related to the entry lanelets in order if exists.
*/
Expand All @@ -124,16 +133,16 @@ class CarmaTrafficSignal : public lanelet::RegulatoryElement

/**
* @brief Return the stop_lines related to the specified entry lanelet
* @param llt entry_lanelet
* @return optional stop line linestring.
* Empty optional if no stopline, or no entry lanelets, or if specified entry lanelet is not recorded.
* @param llt entry_lanelet
* @return optional stop line linestring.
* Empty optional if no stopline, or no entry lanelets, or if specified entry lanelet is not recorded.
*/
Optional<ConstLineString3d> getConstStopLine(const ConstLanelet& llt);
Optional<LineString3d> getStopLine(const ConstLanelet& llt);

explicit CarmaTrafficSignal(const lanelet::RegulatoryElementDataPtr& data);
/**
* @brief: Creating one is not directly usable unless setStates is called
* @brief: Creating one is not directly usable unless setStates is called
* Static helper function that creates a stop line data object based on the provided inputs
*
* @param id The lanelet::Id of this element
Expand Down
34 changes: 15 additions & 19 deletions common/lanelet2_extension/lib/CarmaTrafficSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ LineStrings3d CarmaTrafficSignal::stopLine()
return getParameters<LineString3d>(RoleName::RefLine);
}

Optional<LineString3d> CarmaTrafficSignal::getStopLine(const ConstLanelet& llt)
Optional<LineString3d> CarmaTrafficSignal::getStopLine(const ConstLanelet& llt)
{
auto sl = stopLine();
if (sl.empty()) {
Expand All @@ -78,15 +78,15 @@ Optional<LineString3d> CarmaTrafficSignal::getStopLine(const ConstLanelet& llt)
return sl.at(size_t(std::distance(llts.begin(), it)));
}

Optional<ConstLineString3d> CarmaTrafficSignal::getConstStopLine(const ConstLanelet& llt)
Optional<ConstLineString3d> CarmaTrafficSignal::getConstStopLine(const ConstLanelet& llt)
{
Optional<LineString3d> mutable_stop_line = getStopLine(llt);

if (!mutable_stop_line)
return boost::none;

ConstLineString3d const_stop_line = mutable_stop_line.get();

return const_stop_line;
}

Expand Down Expand Up @@ -120,18 +120,13 @@ boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> Ca
return boost::none;
}

if (recorded_time_stamps.size() == 1) // if only 1 timestamp recorded, this signal doesn't change
{
return std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>(recorded_time_stamps.front().first, recorded_time_stamps.front().second);
}

if (lanelet::time::toSec(fixed_cycle_duration) < 1.0) // there are recorded states, but no fixed_cycle_duration means it is dynamic
{
if (recorded_time_stamps.size() != recorded_start_time_stamps.size())
{
throw std::invalid_argument("recorded_start_time_stamps size is not equal to recorded_time_stamps size");
}

// if requested time is BEFORE recorded states' time interval, return STOP_AND_REMAIN
if (recorded_start_time_stamps.front() >= time_stamp)
{
Expand All @@ -141,11 +136,11 @@ boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> Ca
// if requested time is AFTER recorded states' time interval, return STOP_AND_REMAIN
if (recorded_time_stamps.back().first <= time_stamp)
{
auto end_infinity_time = timeFromSec(2147483647); //corresponds to 03:14:07 on Tuesday, 19 January 2038.
LOG_WARN_STREAM("CarmaTrafficSignal doesn't have enough state saved, so returning STOP_AND_REMAIN state! End_time: " << end_infinity_time);
auto end_infinity_time = timeFromSec(time::INFINITY_END_TIME_FOR_NOT_ENOUGH_STATES); //corresponds to 03:14:07 on Tuesday, 19 January 2038.
LOG_DEBUG_STREAM("CarmaTrafficSignal doesn't have enough state saved, so returning STOP_AND_REMAIN state! End_time: " << end_infinity_time);
return std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>(end_infinity_time, CarmaTrafficSignalState::STOP_AND_REMAIN);
}

// iterate through states in the dynamic states to get the signal.
for (size_t i = 0; i < recorded_time_stamps.size(); i++)
{
Expand All @@ -155,15 +150,16 @@ boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> Ca
}
}
}


// This part of the code is used for predicting state if fixed_cycle_duration is set using setStates function
// shift starting time to the future or to the past to fit input into a valid cycle
boost::posix_time::time_duration accumulated_offset_duration;
double offset_duration_dir = recorded_time_stamps.front().first > time_stamp ? -1.0 : 1.0; // -1 if past, +1 if time_stamp is in future

int num_of_cycles = std::abs(lanelet::time::toSec(recorded_time_stamps.front().first - time_stamp) / lanelet::time::toSec(fixed_cycle_duration));
accumulated_offset_duration = durationFromSec( num_of_cycles * lanelet::time::toSec(fixed_cycle_duration));
if (offset_duration_dir < 0)

if (offset_duration_dir < 0)
{
while (recorded_time_stamps.front().first - accumulated_offset_duration > time_stamp)
{
Expand All @@ -175,7 +171,7 @@ boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> Ca
{
double end_time = lanelet::time::toSec(recorded_time_stamps[i].first) + offset_duration_dir * lanelet::time::toSec(accumulated_offset_duration);
if (end_time >= lanelet::time::toSec(time_stamp))
{
{
return std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>(timeFromSec(end_time), recorded_time_stamps[i].second);
}
}
Expand All @@ -186,7 +182,7 @@ boost::optional<std::pair<boost::posix_time::ptime, CarmaTrafficSignalState>> Ca
lanelet::ConstLanelets CarmaTrafficSignal::getControlStartLanelets() const
{
return getParameters<ConstLanelet>(CarmaTrafficSignalRoleNameString::ControlStart);
}
}

lanelet::ConstLanelets CarmaTrafficSignal::getControlEndLanelets() const
{
Expand Down Expand Up @@ -235,4 +231,4 @@ namespace
lanelet::RegisterRegulatoryElement<lanelet::CarmaTrafficSignal> reg;
} // namespace

} // namespace lanelet
} // namespace lanelet
Loading

0 comments on commit a4c819d

Please sign in to comment.