19#include <rclcpp/rclcpp.hpp>
21#include <carma_v2x_msgs/msg/mobility_operation.hpp>
22#include <carma_planning_msgs/msg/guidance_state.hpp>
23#include <carma_planning_msgs/msg/route_event.hpp>
24#include <carma_planning_msgs/srv/set_active_route.hpp>
25#include <carma_msgs/msg/ui_instructions.hpp>
26#include <geometry_msgs/msg/twist_stamped.hpp>
27#include <geometry_msgs/msg/pose_stamped.hpp>
28#include "std_msgs/msg/string.hpp"
31#include <lanelet2_extension/projection/local_frame_projector.h>
32#include <boost/optional.hpp>
33#include <boost/property_tree/ptree.hpp>
34#include <boost/property_tree/json_parser.hpp>
136 std::shared_ptr<lanelet::projection::LocalFrameProjector>
map_projector_ =
nullptr;
153 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr
logger_;
169 PortDrayageWorker(rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger,
170 rclcpp::Clock::SharedPtr clock,
171 std::function<
void(carma_v2x_msgs::msg::MobilityOperation)> mobility_operations_publisher,
172 std::function<
void(carma_msgs::msg::UIInstructions)> ui_instructions_publisher,
173 std::function<
bool(std::shared_ptr<carma_planning_msgs::srv::SetActiveRoute::Request>)> call_set_active_route);
216 std::shared_ptr<carma_planning_msgs::srv::SetActiveRoute::Request>
composeSetActiveRouteRequest(boost::optional<double> dest_latitude, boost::optional<double> dest_longitude)
const;
224 carma_msgs::msg::UIInstructions
composeUIInstructions(
const std::string& current_operation,
const std::string& previous_operation);
242 void onNewPose(geometry_msgs::msg::PoseStamped::UniquePtr msg);
270 void onGuidanceState(
const carma_planning_msgs::msg::GuidanceState::UniquePtr msg);
276 void onRouteEvent(
const carma_planning_msgs::msg::RouteEvent::UniquePtr msg);
Helper class containing an enum for valid port drayage MobilityOperation message operation IDs and a ...
OperationID::Operation getOperationID() const
Getter function to obtain the Operation enum associated with this object.
const Operation operation_enum_
friend bool operator==(const std::string &lhs, const OperationID &rhs)
Overloaded == operator for comparision with String objects.
friend std::ostream & operator<<(std::ostream &output, const OperationID &oid)
Stream operator for this object.
Operation
Enum containing possible operation IDs used to define destinations for port drayage.
OperationID(enum Operation op)
Standard constructor for OperationID.
std::string operationToString() const
Function to convert this object's 'operation_enum_' to a human-readable string.
const std::string SET_GUIDANCE_ACTIVE_SERVICE_ID
void setVehicleID(const std::string &cmv_id)
Setter function to set this object's cmv_id_ string.
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 t...
const std::string PORT_DRAYAGE_STRATEGY_ID
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.
LatLonCoordinate current_gps_position_
std::string previous_strategy_params_
void setStartingAtStagingAreaFlag(bool starting_at_staging_area)
Setter function to set this object's starting_at_staging_area flag.
PortDrayageStateMachine pdsm_
PortDrayageState getPortDrayageState()
Get the current state of the port drayage state machine.
void onRouteEvent(const carma_planning_msgs::msg::RouteEvent::UniquePtr msg)
Callback to process each Route Event.
PortDrayageMobilityOperationMsg latest_mobility_operation_msg_
void updateCargoInformationAfterActionCompletion(const PortDrayageMobilityOperationMsg &previous_port_drayage_msg)
Method to update worker's cargo-related data members depending on whether the previously completed ac...
std::string georeference_
void onArrivedAtDestination()
Callback for usage by the PortDrayageStateMachine when the vehicle has arrived at a destination.
void setEnablePortDrayageFlag(bool enable_port_drayage)
Setter function to set this object's enable_port_drayage flag.
bool enable_port_drayage_
std::function< void(carma_v2x_msgs::msg::MobilityOperation)> publish_mobility_operation_
void mobilityOperationMessageParser(std::string mobility_operation_strategy_params)
Function to help parse the text included in an inbound MobilityOperation message's strategy_params fi...
const std::string PORT_DRAYAGE_PLUGIN_ID
void onNewPose(geometry_msgs::msg::PoseStamped::UniquePtr msg)
Callback for the pose subscriber. The pose will be converted into lat/lon and stored locally.
void onReceivedNewDestination()
Callback for usage by the PortDrayageStateMachine when the vehicle has received a new destination.
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 destina...
std::shared_ptr< lanelet::projection::LocalFrameProjector > map_projector_
std::function< void(carma_msgs::msg::UIInstructions)> publish_ui_instructions_
bool starting_at_staging_area_
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_
void onGuidanceState(const carma_planning_msgs::msg::GuidanceState::UniquePtr msg)
Callback to process the current status of the guidance state machine.
void onInboundMobilityOperation(carma_v2x_msgs::msg::MobilityOperation::UniquePtr msg)
Callback to process a received MobilityOperation message.
void setCargoID(const std::string &cargo_id)
Setter function to set this object's cargo_id_ string.
std::shared_ptr< carma_planning_msgs::msg::RouteEvent > latest_route_event_
void onNewGeoreference(std_msgs::msg::String::UniquePtr msg)
Callback for map projection string to define lat/lon <--> map conversion.
std::function< bool(std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request >)> call_set_active_route_service_
rclcpp::Clock::SharedPtr clock_
carma_v2x_msgs::msg::MobilityOperation composeArrivalMessage() const
Assemble the current dataset into a MobilityOperations message with a JSON formatted body containing ...
std::string previously_completed_operation_
PortDrayageState
Enum containing the possible state values for the PortDrayagePlugin.
Convenience struct for storing the vehicle's current latitude/longitude coordinates.
Convenience struct for storing all data contained in a received MobilityOperation message's strategy_...
boost::optional< double > dest_longitude
boost::optional< std::string > current_action_id
boost::optional< double > start_longitude
boost::optional< double > dest_latitude
boost::optional< std::string > cargo_id
boost::optional< double > start_latitude