Class GraphIgnition

Inheritance Relationships

Base Type

  • public fuse_core::AsyncSensorModel

Class Documentation

class GraphIgnition : public fuse_core::AsyncSensorModel

A ignition sensor designed to be used to reset the optimizer graph to an input graph. This is useful for debugging purposes because it allows to play back the recorded transactions from a previous run starting from the same graph, so we obtain the same intermediate graphs and publishers’ outputs. This is specially useful when we cannot record all the graph messages because that would take too much bandwidth or disk, so the recorded graph must be throttled.

This class publishes a transaction equivalent to the supplied graph. When the sensor is first loaded, it does not send any transactions. It waits for a graph to do so. Whenever a graph is received, either on the set_graph service or the topic, this ignition sensor resets the optimizer then publishes a new transaction equivalent to the specified graph.

Parameters:

  • ~queue_size (int, default: 10) The subscriber queue size for the graph messages

  • ~reset_service (string, default: “~/reset”) The name of the reset service to call before sending a transaction

  • ~set_graph_service (string, default: “set_graph”) The name of the set_graph service to advertise

  • ~topic (string, default: “graph”) The topic name for received Graph messages

Public Types

using ParameterType = parameters::GraphIgnitionParams

Public Functions

GraphIgnition()

Default constructor.

All plugins are required to have a constructor that accepts no arguments

~GraphIgnition() = default

Destructor.

void initialize(fuse_core::node_interfaces::NodeInterfaces<ALL_FUSE_CORE_NODE_INTERFACES> interfaces, const std::string &name, fuse_core::TransactionCallback transaction_callback) override

Shadowing extension to the AsyncSensorModel::initialize call.

void start() override

Subscribe to the input topic to start sending transactions to the optimizer.

As a very special case, we are overriding the start() method instead of providing an onStart() implementation. This is because the GraphIgnition sensor calls reset() on the optimizer, which in turn calls stop() and start(). If we used the AsyncSensorModel implementations of start() and stop(), the system would hang inside of one callback function while waiting for another callback to complete.

void stop() override

Unsubscribe from the input topic to stop sending transactions to the optimizer.

As a very special case, we are overriding the stop() method instead of providing an onStop() implementation. This is because the GraphIgnition sensor calls reset() on the optimizer, which in turn calls stop() and start(). If we used the AsyncSensorModel implementations of start() and stop(), the system would hang inside of one callback function while waiting for another callback to complete.

Protected Functions

void subscriberCallback(const fuse_msgs::msg::SerializedGraph &msg)

Triggers the publication of a new transaction equivalent to the supplied graph.

bool setGraphServiceCallback(rclcpp::Service<fuse_msgs::srv::SetGraph>::SharedPtr service, std::shared_ptr<rmw_request_id_t> request_id, const fuse_msgs::srv::SetGraph::Request::SharedPtr req)

Triggers the publication of a new transaction equivalent to the supplied graph.

void onInit() override

Perform any required initialization for the kinematic ignition sensor.

void process(const fuse_msgs::msg::SerializedGraph &msg, std::function<void()> post_process = nullptr)

Process a received graph from one of the ROS comm channels.

This method validates the input graph, resets the optimizer, then constructs and sends the initial state constraints (by calling sendGraph()).

Parameters:

msg[in] - The graph message

void sendGraph(const fuse_core::Graph &graph, const rclcpp::Time &stamp)

Create and send a transaction equivalent to the supplied graph.

Parameters:
  • graph[in] - The graph

  • stamp[in] - The graph stamp

Protected Attributes

fuse_core::node_interfaces::NodeInterfaces<fuse_core::node_interfaces::Base, fuse_core::node_interfaces::Graph, fuse_core::node_interfaces::Logging, fuse_core::node_interfaces::Parameters, fuse_core::node_interfaces::Services, fuse_core::node_interfaces::Topics, fuse_core::node_interfaces::Waitables> interfaces_

Shadows AsyncSensorModel interfaces_.

std::atomic_bool started_

Flag indicating the sensor has been started.

rclcpp::Logger logger_

The sensor model’s logger.

ParameterType params_

Object containing all of the configuration parameters.

Service client used to call the “reset” service on the optimizer

rclcpp::Client<std_srvs::srv::Empty>::SharedPtr reset_client_
rclcpp::Service<fuse_msgs::srv::SetGraph>::SharedPtr set_graph_service_
rclcpp::Subscription<fuse_msgs::msg::SerializedGraph>::SharedPtr sub_
fuse_core::GraphDeserializer graph_deserializer_

Deserializer for SerializedGraph messages.