Controller#

Motion control and dynamic obstacle avoidance.

The Controller is the real-time “pilot” of your robot. While the Planner looks ahead to find a global route, the Controller deals with the immediate reality — calculating velocity commands to follow the global path (path following) or a global target point (object following) while reacting to dynamic obstacles and adhering to kinematic constraints.

It supports several control algorithms, switched by configuration or at run time: Pure Pursuit, Stanley, DWA, DVZ and the vision followers.

Available Run Types#

The Controller typically runs at a high frequency (10Hz-50Hz) to ensure smooth motion.

Timed

Periodic Control Loop. Computes a new velocity command periodically if all necessary inputs are available.

Action Server

Goal Tracking. Offers a ControlPath ROS2 Action. Continuously computes control commands until the goal is reached or the action is preempted.

Inputs#

Key Name

Allowed Types

Number

Default

plan

nav_msgs.msg.Path

1

Topic(name="/plan", msg_type="Path")

location

nav_msgs.msg.Odometry, geometry_msgs.msg.PoseStamped, geometry_msgs.msg.Pose

1

Topic(name="/odom", msg_type="Odometry")

sensor_data

sensor_msgs.msg.LaserScan, sensor_msgs.msg.PointCloud2

1

Topic(name="/scan", msg_type="LaserScan")

local_map

nav_msgs.msg.OccupancyGrid

1

Topic(name="/local_map/occupancy_layer", msg_type="OccupancyGrid")

vision_detections

automatika_embodied_agents.msg.Detections, automatika_embodied_agents.msg.Trackings

1

None. Provide it to use vision target tracking.

depth_camera_info

sensor_msgs.msg.CameraInfo

1

None. Required for the RGB-D follower.

vision_depth

sensor_msgs.msg.Image, sensor_msgs.msg.PointCloud2

1

None. A separate depth source, an aligned depth image or a point cloud, paired with detections by time stamp within vision_depth_max_age.

Tip

Provide a vision_detections input topic to the controller to activate the creation of a vision-based target following action server, track_vision_target. See the Vision Tracking tutorial for more details.

Outputs#

Key Name

Allowed Types

Number

Default

command

geometry_msgs.msg.Twist, geometry_msgs.msg.TwistStamped

1

Topic(name="/control", msg_type="Twist")

multi_command

kompass_interfaces.msg.TwistArray

1

Topic(name="/control_list", msg_type="TwistArray")

interpolation

nav_msgs.msg.Path

1

Topic(name="/interpolated_path", msg_type="Path")

local_plan

nav_msgs.msg.Path

1

Topic(name="/local_path", msg_type="Path")

tracked_point

nav_msgs.msg.Odometry, geometry_msgs.msg.PoseStamped, geometry_msgs.msg.Pose

1

Topic(name="/tracked_point", msg_type="PoseStamped")

path_samples

nav_msgs.msg.Path

1

Topic(name="/debug_samples", msg_type="Path"). Published with debug=True.

Algorithms#

EMOS includes several production-ready control plugins suited for different environments:

  • Pure Pursuit — Geometric path tracking towards a look-ahead point on the path. Simple, smooth and predictable.

  • Stanley — Geometric path tracking using the front axle as reference. Best for Ackermann steering.

  • DVZ — Deformable Virtual Zone. Reactive collision avoidance based on risk zones. Extremely fast for crowded dynamic environments.

  • DWA — Dynamic Window Approach. Sample-based collision avoidance with GPU support. Considers kinematics to find optimal velocity.

  • Vision followers — VisionRGBFollower and VisionRGBDFollower. Steer the robot to keep a visual target centered, from RGB alone or with depth.

See the Algorithms Reference for detailed descriptions of each algorithm.

Configuration#

Field

Default

Effect

algorithm

DWA

The control algorithm, a ControllersID or its name.

control_time_step

0.1 s

Time step of the computed control sequence.

use_direct_sensor

false

Read obstacles from the sensor directly rather than from the local map.

ctrl_publish_type

Array

How commands go out: Sequence, Parallel or Array.

vision_depth_max_age

0.2 s

How far apart a detection and its separate depth may be in time.

debug

false

Publishes the sampled trajectories on path_samples.

Built-in Actions#

set_algorithm(algorithm_value) switches the algorithm while the recipe runs, which is what an event uses to move from Pure Pursuit outdoors to DWA indoors. stop_path_tracking() ends the current tracking as if the path had been reached, clears the plan and stops the robot; a new plan resumes tracking. Both return (success, message). With vision tracking enabled, the StopVisionTracking service stops a running target follow.

Usage Example#

from kompass.components import Controller, ControllerConfig
from kompass.control import ControllersID
from kompass.ros import Topic

# Setup custom configuration
my_config = ControllerConfig(loop_rate=10.0)

# Init a controller object
my_controller = Controller(component_name="controller", config=my_config)

# Change an input
my_controller.inputs(plan=Topic(name='/global_path', msg_type='Path'))

# Change run type (default "Timed")
my_controller.run_type = "ActionServer"

# Choose the algorithm
my_controller.algorithm = ControllersID.DWA