kompass.components.map_server

Module Contents

Classes

MapServerConfig

MapServer component configuration parameters

MapServer

MapServer component used for reading and converting map data from file to serve a global map. Supports both 2D maps with a YAML file and 3D maps with PCD files.

API

class kompass.components.map_server.MapServerConfig

Bases: kompass.config.ComponentConfig

MapServer component configuration parameters

Name

Type, Default

Description

map_file_read_rate

float, 0.0

Rate to read and convert the map data from file. If zero, converts once.

pc_publish_row

bool, True

Publish the row point cloud data read from the file. Only applicable if input is .pcd file.

pc_frame

Optional[str], None

Frame ID to use when publishing the point cloud data. If None, uses the world frame.

map_file_path

Optional[str], None

Path to the map file.

custom_map_frame

Optional[str], None

Custom frame ID for the map.

grid_resolution

float, 0.05

Resolution of the occupancy grid if generating from point cloud.

z_ground_limit

float, 0.01

Points below this height value are considered ground. Used only for point cloud input.

class kompass.components.map_server.MapServer(component_name: str, config_file: Optional[str] = None, config: Optional[kompass.components.map_server.MapServerConfig] = None, outputs: Optional[Dict[str, kompass.components.ros.Topic]] = None, **kwargs)

Bases: kompass.components.component.Component

MapServer component used for reading and converting map data from file to serve a global map. Supports both 2D maps with a YAML file and 3D maps with PCD files.

Outputs:

Key Name

Allowed Types

Number

Default

global_map

nav_msgs.msg.OccupancyGrid

1

Topic(name="/map", msg_type="OccupancyGrid") - Global map generated from input data.

spatial_sensor

sensor_msgs.msg.PointCloud2

1, optional

Topic(name="/row_point_cloud", msg_type="PointCloud2") - Row point cloud data for visualization or further processing.

Available Services:

  • Save2dMapToFile: Saves the 2D map to a file (YAML format).

  • Save3dMapToFile: Saves the 3D map to a file (PCD format).

Usage Example:

from kompass.components import MapServerConfig, MapServer
from kompass.ros import Topic

# Setup custom configuration
my_config = MapServerConfig(
        map_file_read_rate=5.0,
        map_file_path="/path/to/your/map.pcd",
        grid_resolution=0.1,
        pc_publish_row=False,
    )

# Init a MapServer object
my_map_server = MapServer(component_name="map_server", config=my_config)
init_variables()

Overwrites the init variables method called at Node init

create_all_timers()

Create all node timers

create_all_services()

Creates all node services

destroy_all_timers()

Destroys all node timers

destroy_all_services()

Destroys all node services

convert_map_from_file() bool

Convert the map from file to OccupancyGrid message