Class Adapter
Defined in File Adapter.hpp
Inheritance Relationships
Base Type
public std::enable_shared_from_this< Adapter >
Class Documentation
-
class Adapter : public std::enable_shared_from_this<Adapter>
Public Types
-
using Blockers = std::vector<EasyTrafficLight::Blocker>
Public Functions
-
std::shared_ptr<EasyFullControl> add_easy_fleet(const EasyFullControl::FleetConfiguration &config)
Add an Easy Full Control fleet to be adapted.
- Parameters:
config – [in] Configuration for the new Easy Full Control fleet.
- Returns:
The handle for adding new robots to the fleet.
-
std::shared_ptr<FleetUpdateHandle> add_fleet(const std::string &fleet_name, rmf_traffic::agv::VehicleTraits traits, rmf_traffic::agv::Graph navigation_graph, std::optional<std::string> server_uri = std::nullopt)
Add a fleet to be adapted.
If a single real-life fleet needs to integrate robots with varying traits or with different navigation graphs, it is okay to call this function multiple times with the same fleet_name and add a robot using whichever handle has the traits and navigation graph that match the robot.
- Parameters:
fleet_name – [in] The name of the fleet that is being added.
traits – [in] Specify the approximate traits of the vehicles in this fleet.
navigation_graph – [in] Specify the navigation graph used by the vehicles in this fleet.
server_uri – [in] Specify the URI for the websocket server that receives updates on tasks and states. If nullopt, data will not be published.
-
void add_easy_traffic_light(std::function<void(EasyTrafficLightPtr handle)> handle_callback, const std::string &fleet_name, const std::string &robot_name, rmf_traffic::agv::VehicleTraits traits, std::function<void()> pause_callback, std::function<void()> resume_callback, std::function<void(Blockers)> deadlock_callback = nullptr)
Create an easy-to-use version of a traffic light to help manage robots that can only support pause and resume commands.
This API is much simpler to use than the standard traffic light API, but it provides less information about the exact timing needed for the starts and stops.
This API should only be used for demo purposes, or if system integrators can ensure very low-latency and reliable connections to the robots to ensure that the commands arrive on time.
- Parameters:
handle_callback – [in] The callback that will be triggered when the EasyTrafficLight handle is ready to be used. This callback will only be triggered once.
fleet_name – [in] The name of the fleet
robot_name – [in] The name of the robot
traits – [in] The traits of the robot
pause_callback – [in] The callback that should be triggered by the traffic light when an immediate pause is needed.
resume_callback – [in] The callback that will be triggered by the traffic light when the robot may resume moving forward.
deadlock_callback – [in] The callback that will be triggered by the traffic light if there is a permanent blocker disrupting the ability of this vehicle to proceed. Manual intervention may be required in this circumstance. A callback does not need to be provided for this. Either way, an error message will be printed to the log.
-
std::shared_ptr<rclcpp::Node> node()
Get the rclcpp::Node that this adapter will be using for communication.
-
Adapter &start()
Begin running the event loop for this adapter. The event loop will operate in another thread, so this function is non-blocking.
Public Static Functions
-
static std::shared_ptr<Adapter> init_and_make(const std::string &node_name, std::optional<rmf_traffic::Duration> discovery_timeout = std::nullopt)
Initialize an rclcpp context and make an adapter instance. This will instantiate an rclcpp::Node and allow you to add fleets to be adapted.
This is an easier-to-use but less customizable alternative to make().
See also
- Parameters:
node_name – [in] The name for the rclcpp::Node that will be produced for this Adapter.
discovery_timeout – [in] How long we will wait to discover the Schedule Node before giving up. If rmf_utils::nullopt is given, then this will try to use the discovery_timeout node paramter, or it will wait 1 minute if the discovery_timeout node parameter was not defined.
-
static std::shared_ptr<Adapter> make(const std::string &node_name, const rclcpp::NodeOptions &node_options = rclcpp::NodeOptions(), std::optional<rmf_traffic::Duration> discovery_timeout = std::nullopt)
Make an adapter instance. This will instantiate an rclcpp::Node and allow you to add fleets to be adapted.
See also
Note
You must initialize rclcpp before calling this, either by using rclcpp::init(~) or rclcpp::Context::init(~). This requirement can be avoided by using init_and_make() instead of this function.
- Parameters:
node_name – [in] The name for the rclcpp::Node that will be produced for this Adapter.
node_options – [in] The options that the rclcpp::Node will be constructed with.
discovery_timeout – [in] How long we will wait to discover the Schedule Node before giving up. If rmf_utils::nullopt is given, then this will try to use the discovery_timeout node paramter, or it will wait 1 minute if the discovery_timeout node parameter was not defined.
-
using Blockers = std::vector<EasyTrafficLight::Blocker>