The Server Module

This module implements the Capability server.

The Capability server provides access to queries and services related to capabilities.

class capabilities.server.CapabilityInstance(provider, provider_path, started_by='unknown')[source]

Encapsulates the state of an instance of a Capability Provider

This class encapsulates the state of the capability instance and provides methods for changing the states of the instance.

cancel()[source]

Cancels the instance, which can only be done while it is still ‘waiting’

Fails to cancel if the current state is not ‘waiting’. “Canceling” is achieved by setting the canceled member variable to True.

Returns:True if canceling is successful, False otherwise
Return type:bool
launch()[source]

Change to the ‘launching’ state

Fails to transition if the current state is not ‘waiting’.

Returns:True if transition is successful, False otherwise
Return type:bool
launched(pid)[source]

Called once the instance is “launched”, changes state to ‘running’

Fails to transition if the current state is not ‘launching’. If successful, the state changes to ‘running’.

Parameters:pid (int) – process ID of the instance being tracked
Returns:True if transition is successful, False otherwise
Return type:bool
state

Get the current state of the CapabilityInstance

stopped()[source]

Change to the ‘stopping’ state

Fails to transition if the current state is not either ‘running’ or ‘launching’.

Returns:True if transition is successful, False otherwise
Return type:bool
terminated()[source]

Called when the instance has terminated, transitions to the ‘terminated’ state

Fails to transition if the current state is not ‘stopping’.

Returns:True if transition is successful, False otherwise
Return type:bool
class capabilities.server.CapabilityServer(package_paths, screen=None)[source]

A class to expose the discovery.SpecIndex over a ROS API

handle_capability_events(event)[source]

Callback for handling messages (events) from the /events topic

This callback only process events generated by this node.

Parameters:event (capabilities.msgs.CapabilityEvent) – ROS message encapsulating an event
shutdown()[source]

Stops the capability server and cleans up any running processes

spin()[source]

Starts the capability server by setting up ROS comms, then spins

capabilities.server.get_reverse_depends(name, capability_instances)[source]

Gets the reverse dependencies of a given Capability

Parameters:
  • name (str) – Name of the Capability which the instances might depend on
  • capability_instances (list of CapabilityInstance) – list of instances to search for having a dependency on the given Capability
Returns:

A list of CapabilityInstance‘s which depend on the given Capability name

Return type:

list of CapabilityInstance