-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Car 5920 Traffic Incident ROS2 Migration (#230)
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description This PR migrates the `traffic_incident` package to ROS2. ## Related GitHub Issue NA ## Related Jira Key [CAR-5920](https://usdot-carma.atlassian.net/browse/CAR-5920) ## Motivation and Context Migration to ROS2 ## How Has This Been Tested? 1. Set the config and launched using `carma start all` 2. Entered the `messenger_ros2` container using `docker exec -it messenger_ros2 bash` 3. Verified that `/traffic_incident` shows up when running `ros2 node list` 4. Verified that the state of `/traffic_incident` automatically switches to `active` using `ros2 lifecycle get /traffic_incident` 5. Open the CARMA Messenger GUI and started a traffic event broadcast in the event management plugin a. Verified that the correct message starts publishing on `/outgoing_mobility_operation` b. Verified that publishing stops after clicking "Stop Broadcast" ## Types of changes - [ ] Defect fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: - [ ] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I have read the [**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) document. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed. [CAR-5920]: https://usdot-carma.atlassian.net/browse/CAR-5920?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
274a6b0
commit bb52d1b
Showing
14 changed files
with
691 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
carma-messenger-core/traffic_incident/include/traffic_incident_node.h
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
carma-messenger-core/traffic_incident/include/traffic_incident_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (C) 2024 LEIDOS. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
#ifndef TRAFFIC_INCIDENT_H | ||
#define TRAFFIC_INCIDENT_H | ||
|
||
#include <functional> | ||
#include <string> | ||
|
||
#include "traffic_incident_worker.hpp" | ||
#include <carma_ros2_utils/carma_ros2_utils.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_srvs/srv/trigger.hpp> | ||
|
||
#include <carma_msgs/srv/set_traffic_event.hpp> | ||
#include <carma_v2x_msgs/msg/mobility_operation.hpp> | ||
#include <gps_msgs/msg/gps_fix.hpp> | ||
|
||
namespace traffic | ||
{ | ||
class TrafficIncidentNode : public carma_ros2_utils::CarmaLifecycleNode | ||
{ | ||
public: | ||
/*! \fn TrafficIncidentNode() | ||
\brief TrafficIncidentNode constructor | ||
*/ | ||
explicit TrafficIncidentNode(const rclcpp::NodeOptions &); | ||
|
||
/*! \fn publishTrafficIncidentMobilityOperation() | ||
\brief Publish mobility operation message | ||
*/ | ||
void publishTrafficIncidentMobilityOperation( | ||
const carma_v2x_msgs::msg::MobilityOperation & traffic_msg); | ||
|
||
// Service callback | ||
bool startTrafficBroadcastCallback( | ||
const std::shared_ptr<rmw_request_id_t>, | ||
const carma_msgs::srv::SetTrafficEvent::Request::SharedPtr req, | ||
carma_msgs::srv::SetTrafficEvent::Response::SharedPtr resp); | ||
bool stopTrafficBroadcastCallback( | ||
const std::shared_ptr<rmw_request_id_t>, | ||
const std_srvs::srv::Trigger::Request::SharedPtr req, | ||
std_srvs::srv::Trigger::Response::SharedPtr resp); | ||
|
||
private: | ||
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &); | ||
|
||
carma_ros2_utils::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &); | ||
|
||
void spin_callback(void); | ||
|
||
// subscriber | ||
carma_ros2_utils::SubPtr<gps_msgs::msg::GPSFix> pinpoint_driver_sub_; | ||
|
||
// publisher | ||
carma_ros2_utils::PubPtr<carma_v2x_msgs::msg::MobilityOperation> traffic_mobility_operation_pub_; | ||
|
||
// services | ||
carma_ros2_utils::ServicePtr<carma_msgs::srv::SetTrafficEvent> | ||
start_broadcast_request_service_server; | ||
carma_ros2_utils::ServicePtr<std_srvs::srv::Trigger> stop_broadcast_request_service_server; | ||
|
||
// timer | ||
rclcpp::TimerBase::SharedPtr spin_timer_; | ||
|
||
// TrafficIncidentWorker class object | ||
TrafficIncidentWorker traffic_worker_; | ||
|
||
// ROS Params | ||
std::string sender_id_; | ||
std::string event_reason_; | ||
std::string event_type_; | ||
double down_track_; | ||
double up_track_; | ||
double min_gap_; | ||
}; | ||
|
||
} // namespace traffic | ||
|
||
#endif /* TRAFFIC_INCIDENT_H */ |
Oops, something went wrong.