Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ec7c290
minor meta data changes to add capability runtime info tracking for e…
KalanaRatnayake Aug 11, 2026
08e46c2
added relations and definitions to provider.yaml, pushing the spec_ve…
KalanaRatnayake Aug 12, 2026
f59a10e
minor doc fix
KalanaRatnayake Aug 12, 2026
ed4b20f
removed get_capability_spec_runner due to merging the process into fa…
KalanaRatnayake Aug 12, 2026
a0ae1f2
removed get_capability_spec_runner due to merging the process into fa…
KalanaRatnayake Aug 12, 2026
cbddf9b
removed get_capability_spec_runner due to merging the process into fa…
KalanaRatnayake Aug 13, 2026
7797ddf
added ownership to capability connections
KalanaRatnayake Aug 13, 2026
3990f16
updated the null check on interace parameter and updated the InputMul…
KalanaRatnayake Aug 14, 2026
ce269c2
updated the null check on definable base model
KalanaRatnayake Aug 14, 2026
09aa178
updated runnable and interface
KalanaRatnayake Aug 16, 2026
5a5cdc4
added process_result() function to action_runner
KalanaRatnayake Aug 18, 2026
f45b6e5
extended resource model to have more information on parameters
KalanaRatnayake Aug 19, 2026
7d2c468
updated runner base class to use interfaces yaml parameter from inter…
KalanaRatnayake Aug 21, 2026
2a29a20
minor doc update
KalanaRatnayake Aug 21, 2026
d31088e
added more explantions
KalanaRatnayake Aug 22, 2026
52e4a78
Added minor logging
KalanaRatnayake Sep 12, 2026
77c6e8f
minor fix
KalanaRatnayake Sep 13, 2026
f711d0e
stability improvement
KalanaRatnayake Sep 14, 2026
4bfa587
minor modifications
KalanaRatnayake Sep 16, 2026
e46fa9d
replaced event system history topic with snapshot service
KalanaRatnayake Sep 27, 2026
cf4ca2a
resolved semantic_interface resolving
KalanaRatnayake Oct 7, 2026
315fcad
proposing semantic_providers
KalanaRatnayake Oct 11, 2026
d33e25f
improved runnable spec discovery now updates interface names with sem…
KalanaRatnayake Oct 11, 2026
4c358c7
added info in semantic provider. not implemented yet
KalanaRatnayake Oct 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The main usage of `capabilities2` will typically involve creating or customizing
| [Interfaces](./docs/interfaces.md) | The main capability specification file |
| [Providers](./docs/providers.md) | The capability provider specification file provides a mechanism to operate the capability |
| [Semantic Interfaces](./docs/semantic_interfaces.md) | The semantic interface specification file provides a mechanism to redefine a capability with semantic information |
| [Semantic Providers](./docs/semantic_provider.md) | The semantic provider specification file provides a mechanism to redefine a capability provider with semantic information |

Runners can be created using the runner API parent classes [here](./capabilities2_runner/readme.md). The capabilities service can be started using the [capabilities2_server](./capabilities2_server/readme.md) package.

Expand All @@ -50,6 +51,7 @@ ros2 launch capabilities2_server capabilities2_server.launch.py
- [Registering a capability](./capabilities2_server/docs/register.md)
- [Terminal based capability usage](./capabilities2_server/docs/terminal_usage.md)
- [Running test scripts](./docs/run_test_scripts.md)
- [Runnable Information](./docs/runnable.md)

### Docs

Expand Down
15 changes: 15 additions & 0 deletions capabilities2_events/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
find_package(rclcpp REQUIRED)
find_package(capabilities2_msgs REQUIRED)

Expand Down Expand Up @@ -47,6 +48,20 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)

if(BUILD_TESTING)
ament_add_gtest(published_event_test
test/published_event_test.cpp
)
if(TARGET published_event_test)
target_include_directories(published_event_test PUBLIC include)
target_link_libraries(published_event_test ${PROJECT_NAME})
ament_target_dependencies(published_event_test
rclcpp
capabilities2_msgs
)
endif()
endif()

ament_export_include_directories(include)
ament_export_dependencies(rclcpp capabilities2_msgs)
ament_export_libraries(${PROJECT_NAME})
Expand Down
24 changes: 21 additions & 3 deletions capabilities2_events/include/capabilities2_events/event_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class EventBase
typedef capabilities2_events::EventParameters parameter_t;
typedef std::string access_id_t;
typedef std::string target_instance_id_t;
typedef std::function<void(const access_id_t&, const capability_str_t&, const target_instance_id_t&, parameter_t)> event_callback_t;
typedef std::function<void(const access_id_t&, const capability_str_t&, const target_instance_id_t&, parameter_t)>
event_callback_t;

public:
EventBase()
Expand All @@ -62,13 +63,14 @@ class EventBase
* which lets loosely-coupled capabilities propogate state changes
* when a source capability emits an event to a target capability
*
* @param connection_id connection identifier (format: "bond_id/trigger_id")
* @param connection_id connection identifier (format: "bond_id/instance_id/target_instance_id")
* @param ownership_id ownership identifier for the connection (used for access control)
* @param event_code type of event being emitted
* @param source source capability emitting the event
* @param target target capability receiving the event
* @param callback function to trigger target capability with (capability, parameters, bond_id, target_instance_id)
*/
virtual void emit(const std::string& connection_id, const uint8_t& event_code,
virtual void emit(const std::string& connection_id, const std::string& ownership_id, const uint8_t& event_code,
const capabilities2_msgs::msg::Capability& source,
const capabilities2_msgs::msg::Capability& target, event_callback_t callback)
{
Expand All @@ -84,6 +86,22 @@ class EventBase
}
}

/**
* @brief Publish an observed event for monitoring/telemetry even when no callback is triggered.
*
* This is used so external observers can see lifecycle events such as STARTED and STOPPED
* even when the plan does not define a matching event connection.
*/
virtual void publish_observed_event(const std::string& ownership_id, const uint8_t& event_code,
const capabilities2_msgs::msg::Capability& source,
const std::string& instance_id)
{
(void)ownership_id;
(void)event_code;
(void)source;
(void)instance_id;
}

/**
* @brief on server ready event
*
Expand Down
32 changes: 30 additions & 2 deletions capabilities2_events/include/capabilities2_events/event_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class EventNode
// connection target
capabilities2_msgs::msg::Capability target;

// connection ownership id
std::string ownership_id;

// event callback with signature: (capability, parameters, bond_id)
EventBase::event_callback_t callback;
};
Expand Down Expand Up @@ -72,6 +75,26 @@ class EventNode
return;
}

std::string ownership_id_for_observation;

for (const auto& [conn_id, connection] : connections_)
{
size_t first_pos = conn_id.find('/');
size_t second_pos = conn_id.find('/', first_pos + 1);

std::string conn_bond_id = (first_pos != std::string::npos) ? conn_id.substr(0, first_pos) : conn_id;
std::string conn_instance_id =
(second_pos != std::string::npos) ? conn_id.substr(first_pos + 1, second_pos - first_pos - 1) : "";

if (bond_id == conn_bond_id && instance_id == conn_instance_id)
{
ownership_id_for_observation = connection.ownership_id;
break;
}
}

event_emitter_->publish_observed_event(ownership_id_for_observation, event_type, source_, instance_id);

// check each connection
for (const auto& [conn_id, connection] : connections_)
{
Expand Down Expand Up @@ -109,7 +132,8 @@ class EventNode
// modifying execution of other nodes is not owned by this class
// this lets the execution flow be made thread-safe
// in the scope where the thread is owned
event_emitter_->emit(conn_id, event_type, source_, target_with_params, connection.callback);
event_emitter_->emit(conn_id, connection.ownership_id, event_type, source_, target_with_params,
connection.callback);
}
}
}
Expand Down Expand Up @@ -147,11 +171,13 @@ class EventNode
* @param connection_id unique identifier for the connection (format: "bond_id/trigger_id")
* @param type type of event to connect to
* @param target target capability to connect to
* @param ownership_id ownership id of the connection (used for access control)
* @param event_cb callback to trigger target capability with (capability, parameters, bond_id, target_instance_id)
*
* @throws event_exception if connection with given id already exists
*/
void add_connection(const std::string& connection_id, const capabilities2_msgs::msg::CapabilityEventCode& type,
void add_connection(const std::string& connection_id, const std::string& ownership_id,
const capabilities2_msgs::msg::CapabilityEventCode& type,
const capabilities2_msgs::msg::Capability& target, EventBase::event_callback_t event_cb)
{
// validate connection id
Expand All @@ -164,6 +190,7 @@ class EventNode
EventPipe conn;
conn.type = type;
conn.target = target;
conn.ownership_id = ownership_id;
conn.callback = event_cb;

// add connection
Expand Down Expand Up @@ -224,6 +251,7 @@ class EventNode
c.type = connection.type;
c.source = source_;
c.target = connection.target;
c.ownership_id = connection.ownership_id;
conns.push_back(c);
}

Expand Down
Loading
Loading