Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
|
#include <port_drayage_worker.hpp>
Public Member Functions | |
PortDrayageWorker (rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger, rclcpp::Clock::SharedPtr clock, std::function< void(carma_v2x_msgs::msg::MobilityOperation)> mobility_operations_publisher, std::function< void(carma_msgs::msg::UIInstructions)> ui_instructions_publisher, std::function< bool(std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request >)> call_set_active_route) | |
Standard constructor for the PortDrayageWorker. More... | |
void | setVehicleID (const std::string &cmv_id) |
Setter function to set this object's cmv_id_ string. More... | |
void | setCargoID (const std::string &cargo_id) |
Setter function to set this object's cargo_id_ string. More... | |
void | setEnablePortDrayageFlag (bool enable_port_drayage) |
Setter function to set this object's enable_port_drayage flag. More... | |
void | setStartingAtStagingAreaFlag (bool starting_at_staging_area) |
Setter function to set this object's starting_at_staging_area flag. More... | |
void | onArrivedAtDestination () |
Callback for usage by the PortDrayageStateMachine when the vehicle has arrived at a destination. More... | |
void | onReceivedNewDestination () |
Callback for usage by the PortDrayageStateMachine when the vehicle has received a new destination. More... | |
std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request > | composeSetActiveRouteRequest (boost::optional< double > dest_latitude, boost::optional< double > dest_longitude) const |
Create a SetActiveRoute service request to set a new active route for the system based on the destination points contained in the most recently-received Port Drayage MobilityOperation message intended for this vehicle. More... | |
carma_msgs::msg::UIInstructions | composeUIInstructions (const std::string ¤t_operation, const std::string &previous_operation) |
Creates a UIInstructions message that can be used to create a pop-up on the Web UI to notify a user that a new route has been received for a specified destination type, and that the system can be engaged on that route. More... | |
carma_v2x_msgs::msg::MobilityOperation | composeArrivalMessage () const |
Assemble the current dataset into a MobilityOperations message with a JSON formatted body containing CMV ID and cargo ID. More... | |
void | onNewGeoreference (std_msgs::msg::String::UniquePtr msg) |
Callback for map projection string to define lat/lon <--> map conversion. More... | |
void | onNewPose (geometry_msgs::msg::PoseStamped::UniquePtr msg) |
Callback for the pose subscriber. The pose will be converted into lat/lon and stored locally. More... | |
void | onInboundMobilityOperation (carma_v2x_msgs::msg::MobilityOperation::UniquePtr msg) |
Callback to process a received MobilityOperation message. More... | |
void | updateCargoInformationAfterActionCompletion (const PortDrayageMobilityOperationMsg &previous_port_drayage_msg) |
Method to update worker's cargo-related data members depending on whether the previously completed action was for a pickup or dropoff. More... | |
void | mobilityOperationMessageParser (std::string mobility_operation_strategy_params) |
Function to help parse the text included in an inbound MobilityOperation message's strategy_params field according to the JSON schema intended for MobilityOperation messages with strategy type 'carma/port_drayage'. Stores the parsed information in _latest_mobility_operation_msg. More... | |
void | onGuidanceState (const carma_planning_msgs::msg::GuidanceState::UniquePtr msg) |
Callback to process the current status of the guidance state machine. More... | |
void | onRouteEvent (const carma_planning_msgs::msg::RouteEvent::UniquePtr msg) |
Callback to process each Route Event. More... | |
PortDrayageState | getPortDrayageState () |
Get the current state of the port drayage state machine. More... | |
Public Attributes | |
PortDrayageMobilityOperationMsg | latest_mobility_operation_msg_ |
LatLonCoordinate | current_gps_position_ |
Private Attributes | |
std::shared_ptr< carma_planning_msgs::msg::RouteEvent > | latest_route_event_ = nullptr |
PortDrayageStateMachine | pdsm_ |
std::string | previously_completed_operation_ |
std::string | cmv_id_ |
std::string | cargo_id_ |
std::function< void(carma_v2x_msgs::msg::MobilityOperation)> | publish_mobility_operation_ |
std::function< void(carma_msgs::msg::UIInstructions)> | publish_ui_instructions_ |
std::function< bool(std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request >)> | call_set_active_route_service_ |
std::shared_ptr< lanelet::projection::LocalFrameProjector > | map_projector_ = nullptr |
std::string | georeference_ {""} |
bool | starting_at_staging_area_ |
bool | enable_port_drayage_ |
std::string | previous_strategy_params_ |
const std::string | PORT_DRAYAGE_PLUGIN_ID = "port_drayage_plugin" |
const std::string | PORT_DRAYAGE_STRATEGY_ID = "carma/port_drayage" |
const std::string | SET_GUIDANCE_ACTIVE_SERVICE_ID = "/guidance/set_guidance_active" |
rclcpp::Clock::SharedPtr | clock_ |
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr | logger_ |
Implementation class for all the business logic of the PortDrayagePlugin
Definition at line 125 of file port_drayage_worker.hpp.
port_drayage_plugin::PortDrayageWorker::PortDrayageWorker | ( | rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr | logger, |
rclcpp::Clock::SharedPtr | clock, | ||
std::function< void(carma_v2x_msgs::msg::MobilityOperation)> | mobility_operations_publisher, | ||
std::function< void(carma_msgs::msg::UIInstructions)> | ui_instructions_publisher, | ||
std::function< bool(std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request >)> | call_set_active_route | ||
) |
Standard constructor for the PortDrayageWorker.
mobility_operations_publisher | A function containing the logic necessary to publish a Mobility Operations message. |
ui_instructions_publisher | A function containing the logic necessary to publish a UI Instructions message. |
call_set_active_route | A function containing the logic necessary to call the SetActiveRoute service client. |
Definition at line 43 of file port_drayage_worker.cpp.
References onArrivedAtDestination(), onReceivedNewDestination(), pdsm_, port_drayage_plugin::PortDrayageStateMachine::setOnArrivedAtDestinationCallback(), and port_drayage_plugin::PortDrayageStateMachine::setOnReceivedNewDestinationCallback().
carma_v2x_msgs::msg::MobilityOperation port_drayage_plugin::PortDrayageWorker::composeArrivalMessage | ( | ) | const |
Assemble the current dataset into a MobilityOperations message with a JSON formatted body containing CMV ID and cargo ID.
Definition at line 149 of file port_drayage_worker.cpp.
References port_drayage_plugin::PortDrayageMobilityOperationMsg::cargo_id, cargo_id_, clock_, cmv_id_, port_drayage_plugin::PortDrayageMobilityOperationMsg::current_action_id, current_gps_position_, port_drayage_plugin::OperationID::DROPOFF, port_drayage_plugin::EN_ROUTE_TO_INITIAL_DESTINATION, port_drayage_plugin::EN_ROUTE_TO_RECEIVED_DESTINATION, port_drayage_plugin::OperationID::ENTER_PORT, port_drayage_plugin::OperationID::ENTER_STAGING_AREA, port_drayage_plugin::PortDrayageStateMachine::getState(), latest_mobility_operation_msg_, port_drayage_plugin::LatLonCoordinate::latitude, logger_, port_drayage_plugin::LatLonCoordinate::longitude, port_drayage_plugin::PortDrayageMobilityOperationMsg::operation, pdsm_, port_drayage_plugin::OperationID::PICKUP, PORT_DRAYAGE_STRATEGY_ID, and starting_at_staging_area_.
Referenced by onArrivedAtDestination().
std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request > port_drayage_plugin::PortDrayageWorker::composeSetActiveRouteRequest | ( | boost::optional< double > | dest_latitude, |
boost::optional< double > | dest_longitude | ||
) | const |
Create a SetActiveRoute service request to set a new active route for the system based on the destination points contained in the most recently-received Port Drayage MobilityOperation message intended for this vehicle.
dest_latitude | The destination point's latitude |
dest_longitude | The destination point's longitude |
Definition at line 98 of file port_drayage_worker.cpp.
References port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_latitude, port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_longitude, latest_mobility_operation_msg_, logger_, and port_drayage_plugin::PortDrayageMobilityOperationMsg::operation.
Referenced by onReceivedNewDestination().
carma_msgs::msg::UIInstructions port_drayage_plugin::PortDrayageWorker::composeUIInstructions | ( | const std::string & | current_operation, |
const std::string & | previous_operation | ||
) |
Creates a UIInstructions message that can be used to create a pop-up on the Web UI to notify a user that a new route has been received for a specified destination type, and that the system can be engaged on that route.
current_operation | The 'operation' identifier associated with the latest received and processed Port Drayage MobilityOperation message. |
previous_operation | The previously completed 'operation' identifier. This is an empty string if no 'operation' was previously completed. |
Definition at line 119 of file port_drayage_worker.cpp.
References clock_, port_drayage_plugin::OperationID::DROPOFF, port_drayage_plugin::OperationID::HOLDING_AREA, port_drayage_plugin::OperationID::PICKUP, and SET_GUIDANCE_ACTIVE_SERVICE_ID.
Referenced by onReceivedNewDestination().
PortDrayageState port_drayage_plugin::PortDrayageWorker::getPortDrayageState | ( | ) |
Get the current state of the port drayage state machine.
Definition at line 393 of file port_drayage_worker.cpp.
References port_drayage_plugin::PortDrayageStateMachine::getState(), and pdsm_.
void port_drayage_plugin::PortDrayageWorker::mobilityOperationMessageParser | ( | std::string | mobility_operation_strategy_params | ) |
Function to help parse the text included in an inbound MobilityOperation message's strategy_params field according to the JSON schema intended for MobilityOperation messages with strategy type 'carma/port_drayage'. Stores the parsed information in _latest_mobility_operation_msg.
mobility_operation_strategy_params | the strategy_params field of a MobilityOperation message |
Definition at line 292 of file port_drayage_worker.cpp.
References port_drayage_plugin::PortDrayageMobilityOperationMsg::cargo_id, cargo_id_, port_drayage_plugin::PortDrayageMobilityOperationMsg::current_action_id, port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_latitude, port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_longitude, port_drayage_plugin::OperationID::DROPOFF, latest_mobility_operation_msg_, logger_, port_drayage_plugin::PortDrayageMobilityOperationMsg::operation, port_drayage_plugin::OperationID::PICKUP, port_drayage_plugin::PortDrayageMobilityOperationMsg::start_latitude, and port_drayage_plugin::PortDrayageMobilityOperationMsg::start_longitude.
Referenced by onInboundMobilityOperation().
void port_drayage_plugin::PortDrayageWorker::onArrivedAtDestination | ( | ) |
Callback for usage by the PortDrayageStateMachine when the vehicle has arrived at a destination.
Definition at line 74 of file port_drayage_worker.cpp.
References composeArrivalMessage(), and publish_mobility_operation_.
Referenced by PortDrayageWorker().
void port_drayage_plugin::PortDrayageWorker::onGuidanceState | ( | const carma_planning_msgs::msg::GuidanceState::UniquePtr | msg | ) |
Callback to process the current status of the guidance state machine.
msg | a received GuidanceState message |
Definition at line 369 of file port_drayage_worker.cpp.
References port_drayage_plugin::DRAYAGE_START, enable_port_drayage_, lightbar_manager::ENGAGED, port_drayage_plugin::PortDrayageStateMachine::getState(), port_drayage_plugin::INACTIVE, logger_, pdsm_, and port_drayage_plugin::PortDrayageStateMachine::processEvent().
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure().
void port_drayage_plugin::PortDrayageWorker::onInboundMobilityOperation | ( | carma_v2x_msgs::msg::MobilityOperation::UniquePtr | msg | ) |
Callback to process a received MobilityOperation message.
msg | a received MobilityOperation message |
Definition at line 242 of file port_drayage_worker.cpp.
References cmv_id_, latest_mobility_operation_msg_, logger_, mobilityOperationMessageParser(), port_drayage_plugin::PortDrayageMobilityOperationMsg::operation, pdsm_, PORT_DRAYAGE_STRATEGY_ID, previous_strategy_params_, previously_completed_operation_, port_drayage_plugin::PortDrayageStateMachine::processEvent(), port_drayage_plugin::RECEIVED_NEW_DESTINATION, and updateCargoInformationAfterActionCompletion().
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure().
void port_drayage_plugin::PortDrayageWorker::onNewGeoreference | ( | std_msgs::msg::String::UniquePtr | msg | ) |
Callback for map projection string to define lat/lon <--> map conversion.
msg | The proj string defining the projection. |
Definition at line 411 of file port_drayage_worker.cpp.
References georeference_, and map_projector_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure().
void port_drayage_plugin::PortDrayageWorker::onNewPose | ( | geometry_msgs::msg::PoseStamped::UniquePtr | msg | ) |
Callback for the pose subscriber. The pose will be converted into lat/lon and stored locally.
msg | Latest pose message |
Definition at line 397 of file port_drayage_worker.cpp.
References current_gps_position_, port_drayage_plugin::LatLonCoordinate::latitude, logger_, port_drayage_plugin::LatLonCoordinate::longitude, and map_projector_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure().
void port_drayage_plugin::PortDrayageWorker::onReceivedNewDestination | ( | ) |
Callback for usage by the PortDrayageStateMachine when the vehicle has received a new destination.
Definition at line 79 of file port_drayage_worker.cpp.
References call_set_active_route_service_, composeSetActiveRouteRequest(), composeUIInstructions(), port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_latitude, port_drayage_plugin::PortDrayageMobilityOperationMsg::dest_longitude, latest_mobility_operation_msg_, logger_, port_drayage_plugin::PortDrayageMobilityOperationMsg::operation, previously_completed_operation_, and publish_ui_instructions_.
Referenced by PortDrayageWorker().
void port_drayage_plugin::PortDrayageWorker::onRouteEvent | ( | const carma_planning_msgs::msg::RouteEvent::UniquePtr | msg | ) |
Callback to process each Route Event.
msg | a received RouteEvent message |
Definition at line 377 of file port_drayage_worker.cpp.
References port_drayage_plugin::ARRIVED_AT_DESTINATION, port_drayage_plugin::EN_ROUTE_TO_INITIAL_DESTINATION, port_drayage_plugin::EN_ROUTE_TO_RECEIVED_DESTINATION, port_drayage_plugin::PortDrayageStateMachine::getState(), latest_route_event_, logger_, pdsm_, and port_drayage_plugin::PortDrayageStateMachine::processEvent().
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure().
void port_drayage_plugin::PortDrayageWorker::setCargoID | ( | const std::string & | cargo_id | ) |
Setter function to set this object's cargo_id_ string.
cargo_id | The provided Cargo ID for this object |
Definition at line 62 of file port_drayage_worker.cpp.
References cargo_id_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure(), and port_drayage_plugin::PortDrayagePlugin::parameter_update_callback().
void port_drayage_plugin::PortDrayageWorker::setEnablePortDrayageFlag | ( | bool | enable_port_drayage | ) |
Setter function to set this object's enable_port_drayage flag.
enable_port_drayage | The provided boolean flag |
Definition at line 66 of file port_drayage_worker.cpp.
References enable_port_drayage_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure(), and port_drayage_plugin::PortDrayagePlugin::parameter_update_callback().
void port_drayage_plugin::PortDrayageWorker::setStartingAtStagingAreaFlag | ( | bool | starting_at_staging_area | ) |
Setter function to set this object's starting_at_staging_area flag.
starting_at_staging_area | The provided boolean flag |
Definition at line 70 of file port_drayage_worker.cpp.
References starting_at_staging_area_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure(), and port_drayage_plugin::PortDrayagePlugin::parameter_update_callback().
void port_drayage_plugin::PortDrayageWorker::setVehicleID | ( | const std::string & | cmv_id | ) |
Setter function to set this object's cmv_id_ string.
cmv_id | The provided CMV ID for this object |
Definition at line 58 of file port_drayage_worker.cpp.
References cmv_id_.
Referenced by port_drayage_plugin::PortDrayagePlugin::handle_on_configure(), and port_drayage_plugin::PortDrayagePlugin::parameter_update_callback().
void port_drayage_plugin::PortDrayageWorker::updateCargoInformationAfterActionCompletion | ( | const PortDrayageMobilityOperationMsg & | previous_port_drayage_msg | ) |
Method to update worker's cargo-related data members depending on whether the previously completed action was for a pickup or dropoff.
previous_port_drayage_msg | The contents of the previously received MobilityOperation port drayage message for this CMV stored in a PortDrayageMobilityOperationMsg object. |
Definition at line 273 of file port_drayage_worker.cpp.
References port_drayage_plugin::PortDrayageMobilityOperationMsg::cargo_id, cargo_id_, port_drayage_plugin::OperationID::DROPOFF, logger_, port_drayage_plugin::PortDrayageMobilityOperationMsg::operation, and port_drayage_plugin::OperationID::PICKUP.
Referenced by onInboundMobilityOperation().
|
private |
Definition at line 135 of file port_drayage_worker.hpp.
Referenced by onReceivedNewDestination().
|
private |
Definition at line 132 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), mobilityOperationMessageParser(), setCargoID(), and updateCargoInformationAfterActionCompletion().
|
private |
Definition at line 150 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), and composeUIInstructions().
|
private |
Definition at line 131 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), onInboundMobilityOperation(), and setVehicleID().
LatLonCoordinate port_drayage_plugin::PortDrayageWorker::current_gps_position_ |
Definition at line 288 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), and onNewPose().
|
private |
Definition at line 139 of file port_drayage_worker.hpp.
Referenced by onGuidanceState(), and setEnablePortDrayageFlag().
|
private |
Definition at line 137 of file port_drayage_worker.hpp.
Referenced by onNewGeoreference().
PortDrayageMobilityOperationMsg port_drayage_plugin::PortDrayageWorker::latest_mobility_operation_msg_ |
Definition at line 285 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), composeSetActiveRouteRequest(), mobilityOperationMessageParser(), onInboundMobilityOperation(), and onReceivedNewDestination().
|
private |
Definition at line 128 of file port_drayage_worker.hpp.
Referenced by onRouteEvent().
|
private |
Definition at line 153 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), composeSetActiveRouteRequest(), mobilityOperationMessageParser(), onGuidanceState(), onInboundMobilityOperation(), onNewPose(), onReceivedNewDestination(), onRouteEvent(), and updateCargoInformationAfterActionCompletion().
|
private |
Definition at line 136 of file port_drayage_worker.hpp.
Referenced by onNewGeoreference(), and onNewPose().
|
private |
Definition at line 129 of file port_drayage_worker.hpp.
Referenced by PortDrayageWorker(), composeArrivalMessage(), getPortDrayageState(), onGuidanceState(), onInboundMobilityOperation(), and onRouteEvent().
|
private |
Definition at line 145 of file port_drayage_worker.hpp.
|
private |
Definition at line 146 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), and onInboundMobilityOperation().
|
private |
Definition at line 142 of file port_drayage_worker.hpp.
Referenced by onInboundMobilityOperation().
|
private |
Definition at line 130 of file port_drayage_worker.hpp.
Referenced by onInboundMobilityOperation(), and onReceivedNewDestination().
|
private |
Definition at line 133 of file port_drayage_worker.hpp.
Referenced by onArrivedAtDestination().
|
private |
Definition at line 134 of file port_drayage_worker.hpp.
Referenced by onReceivedNewDestination().
|
private |
Definition at line 147 of file port_drayage_worker.hpp.
Referenced by composeUIInstructions().
|
private |
Definition at line 138 of file port_drayage_worker.hpp.
Referenced by composeArrivalMessage(), and setStartingAtStagingAreaFlag().