kompass.components.planner#
Module Contents#
Classes#
Planner component config parameters |
|
Planner Component used for path planning during navigation. |
API#
- class kompass.components.planner.PlannerConfig#
Bases:
kompass.config.ComponentConfigPlanner component config parameters
- class kompass.components.planner.Planner(component_name: str, config_file: Optional[str] = None, config: Optional[kompass.components.planner.PlannerConfig] = None, inputs: Optional[Dict[str, kompass.components.ros.Topic]] = None, outputs: Optional[Dict[str, kompass.components.ros.Topic]] = None, **kwargs)#
Bases:
kompass.components.component.ComponentPlanner Component used for path planning during navigation.
Input Topics:
map: Global map used for planning, set on the planner when received. Subscribed with a reliable and transient local QoS by default, to receive a map published once (latched) even when joining later, and with whatever the map topic asks for instead.
Default:Topic(name="/map", msg_type="OccupancyGrid" qos_profile=QoSConfig(durability=qos.DurabilityPolicy.TRANSIENT_LOCAL))location: the robot current location.
DefaultTopic(name="/odom", msg_type="Odometry")goal_point: 2D navigation goal point on the map.
DefaultTopic(name="/goal", msg_type="PointStamped")depth_camera_info: Intrinsics of the camera behind vision goals (
PointsOfInterestorDetections), required for those goal types.
DefaultNonevision_depth: Optional depth source for lifting vision goals to 3D instead of the depth embedded in their message: a depth
Imagealigned with the detection camera or aPointCloud2(e.g. 3D LiDAR).
DefaultNone
Outputs:
plan: Path to reach the goal point from start location.
DefaultTopic(name="/plan", msg_type="Path")reached_end: Flag indicating that the current planning target is reached
DefaultTopic(name="/reached_end", msg_type="Bool")
Available Run Types:
Set directly from Planner ‘run_type’ property.
TIMED: Compute a new plan periodically from current location (last message received on location input Topic) to the goal location (last message received on goal_point input Topic)
EVENT: Compute a new plan from current location on every new message received on goal_point input Topic
SERVER: Offers a PlanPath ROS service and computes a new plan on every service request
ACTIONSERVER: Offers a PlanPath ROS action and continuously computes a plan once an action request is received until goal point is reached. One goal at a time: while one is being driven, a new goal is rejected, and a caller that wants to go somewhere else cancels the first (the
cancel_main_actionservice, or thecancel_main_goalaction) and then sends it
Usage Example:
from kompass.components import Planner, PlannerConfig from kompass.config import ComponentRunType from kompass.robot import ( RobotConfig, RobotType, RobotGeometryType, LinearCtrlLimits, AngularCtrlLimits, ) import numpy as np # Configure your robot my_robot = RobotConfig( model_type=RobotType.DIFFERENTIAL_DRIVE, geometry_type=RobotGeometryType.CYLINDER, geometry_params=np.array([0.1, 0.3]), ctrl_vx_limits=LinearCtrlLimits(max_vel=1.0, max_acc=1.5, max_decel=2.5), ctrl_omega_limits=AngularCtrlLimits( max_omega=1.0, max_acc=2.0, max_decel=2.0, max_ang=np.pi / 3 ), ) # Setup the planner config config = PlannerConfig( robot=my_robot, loop_rate=1.0 ) planner = Planner(component_name="planner", config=config) # Add rviz clicked_point as input topic planner.run_type = ComponentRunType.EVENT # Can also pass a string "Event" goal_topic = Topic(name="/clicked_point", msg_type="PoseStamped") planner.inputs(goal_point=goal_topic)
- inputs(**kwargs)#
Set component input streams (topics). The map input defaults to a latched QoS, as the map is published once, and keeps whatever the given topic asks for instead
- inspect_component() str#
Method to return a string representation of the component configuration, used for inspection and LLM-based reasoning about the component
- Returns:
String representation of the component configuration
- Return type:
str
- get_ros_entrypoints() Dict[str, Dict[str, Any]]#
Get the component ROS entry points (additional services and actions) as a dictionary.
- config_from_file(config_file: str)#
Configure the planner node and the algorithm from file
- Parameters:
config_file (str) – Path to config file (yaml, json, toml)
- init_variables()#
Overwrites the init variables method called at Node init
- create_all_services()#
Creates all node services
- destroy_all_services()#
Destroys all node services
- trigger_main_action_server(goal_x: float = 0.0, goal_y: float = 0.0, goal_orientation: float = 0.0, tolerance_dist: float = 0.1, tolerance_ori: float = 0.1, algorithm_name: Optional[str] = None, **_) kompass.components.ros.ActionReturnType#
A component action to trigger the main planner action (Plan path to point until reached)
- Parameters:
goal_x (float, optional) – Goal x coordinate on the map (m), defaults to 0.0
goal_y (float, optional) – Goal y coordinate on the map (m), defaults to 0.0
goal_orientation (float, optional) – Goal orientation on the map (rad), defaults to 0.0
tolerance_dist (float, optional) – Distance to the goal within which it is reached (m), defaults to 0.1
tolerance_ori (float, optional) – Orientation error within which the goal is reached (rad), defaults to 0.1
algorithm_name (Optional[str], optional) – Planning algorithm, defaults to None (configured algorithm)
A goal already being driven is not replaced. The action server takes one goal at a time, and a second one is rejected rather than preempting the first: what the robot is doing is changed by saying so, not as a side effect of a new request. Cancel it first, with the
cancel_main_goalaction or the<component>/cancel_main_actionservice, and send the new point after.- Returns:
If the goal was accepted by the action server, with a reason when it was not, including a goal already being driven
- Return type:
ActionReturnType
- main_service_callback(request: kompass_interfaces.srv.PlanPath.Request, response: kompass_interfaces.srv.PlanPath.Response)#
Path planning service callback
- Parameters:
request (PlanPath.Request) – Path planning request containing goal location
response (PlanPath.Response) – Path planning response (success and plan)
- Returns:
Path planning response
- Return type:
PlanPath.Response
- reached_point(goal_point: kompass_core.models.RobotState, tolerance: kompass_interfaces.msg.PathTrackingError) bool#
Checks if the current robot state is close to a given goal point
- Parameters:
goal_point (RobotState) – Goal point
tolerance (PathTrackingError) – Tolerance to goal
- Returns:
If the distance to the goal is less than the given tolerance, and False while the robot location is unknown
- Return type:
bool
- main_action_callback(goal_handle: kompass_interfaces.action.PlanPath.Goal)#
Callback for the planner main action server
- Parameters:
goal_handle (PlanPathAction.Goal) – Incoming action goal
- Returns:
Action result
- Return type:
PlanPathAction.Result