Class BTBuilder

Inheritance Relationships

Derived Types

Class Documentation

class BTBuilder

Interface for behavior tree builder implementations.

This abstract class defines the interface for components that transform a plan into a behavior tree representation for execution.

Subclassed by plansys2::STNBTBuilder, plansys2::SequentialBTBuilder, plansys2::SimpleBTBuilder

Public Types

using Ptr = std::shared_ptr<plansys2::BTBuilder>

Public Functions

virtual void initialize(const std::string &bt_action_1 = "", const std::string &bt_action_2 = "", int precision = 3) = 0

Initialize the builder with behavior tree templates.

Parameters:
  • bt_action_1[in] XML template for regular actions, default empty.

  • bt_action_2[in] XML template for durative actions, default empty.

  • precision[in] Precision for time calculations, default 3.

virtual std::string get_tree(const plansys2_msgs::msg::Plan &current_plan) = 0

Generate a behavior tree XML from a plan.

Parameters:

current_plan[in] The plan to transform into a behavior tree.

Returns:

std::string containing the behavior tree XML.

virtual Graph::Ptr get_graph() = 0

Get the internal graph representation.

Returns:

Shared pointer to the graph.

virtual bool propagate(Graph::Ptr graph) = 0

Propagate temporal constraints through the graph.

Parameters:

graph[inout] The graph to propagate constraints through.

Returns:

True if propagation was successful, false if inconsistencies were found.

virtual std::string get_dotgraph(std::shared_ptr<std::map<std::string, ActionExecutionInfo>> action_map, bool enable_legend = false, bool enable_print_graph = false) = 0

Generate a DOT graph representation for visualization.

Parameters:
  • action_map[in] Map of action IDs to execution information.

  • enable_legend[in] Whether to include a legend in the graph, default false.

  • enable_print_graph[in] Whether to print the graph to console, default false.

Returns:

std::string containing the DOT graph representation.

Public Static Functions

static inline int to_int_time(float time, int power)

Convert a floating point time to an integer with specified precision.

Parameters:
  • time[in] The time value to convert.

  • power[in] The power of 10 to multiply by (precision).

Returns:

The time as an integer with the specified precision.

static inline std::string to_string(const ActionType &action_type)

Convert an action type to its string representation.

Parameters:

action_type[in] The action type to convert.

Returns:

std::string representation of the action type.

static inline std::string to_action_id(const plansys2_msgs::msg::PlanItem &item, int precision)

Generate a unique action identifier from a plan item.

Parameters:
  • item[in] The plan item to generate an ID for.

  • precision[in] The precision for the time component.

Returns:

std::string The unique identifier for the action.

static inline std::string to_action_id(const ActionStamped &action, int precision)

Generate a unique action identifier from an ActionStamped.

Parameters:
  • action[in] The action to generate an ID for.

  • precision[in] The precision for the time component.

Returns:

std::string The unique identifier for the action.