Skip to content

Commit

Permalink
Removed topic statistics as they were not generic in iron yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanFabian committed Oct 10, 2024
1 parent 53fdaaa commit 7bd8f08
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Lint & Test
on:
push:
branches: [ jazzy ]
branches: [ iron ]
pull_request:
branches: [ jazzy ]
branches: [ iron ]
defaults:
run:
shell: bash
Expand Down Expand Up @@ -37,8 +37,8 @@ jobs:
strategy:
matrix:
setup:
- rosdistro: jazzy
os: ubuntu-24.04
- rosdistro: iron
os: ubuntu-22.04
steps:
- name: install build tools
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class BabelFish;

class BabelFishSubscription : public rclcpp::SubscriptionBase
{
private:
using SubscriptionTopicStatisticsSharedPtr =
std::shared_ptr<rclcpp::topic_statistics::SubscriptionTopicStatistics>;

public:
RCLCPP_SMART_PTR_DEFINITIONS( BabelFishSubscription )

Expand All @@ -29,8 +25,7 @@ class BabelFishSubscription : public rclcpp::SubscriptionBase
MessageTypeSupport::ConstSharedPtr type_support, const std::string &topic_name,
const rclcpp::QoS &qos,
rclcpp::AnySubscriptionCallback<CompoundMessage, std::allocator<void>> callback,
const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> &options,
SubscriptionTopicStatisticsSharedPtr subscription_topic_statistics = nullptr );
const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> &options );

~BabelFishSubscription() override;

Expand Down Expand Up @@ -76,8 +71,6 @@ class BabelFishSubscription : public rclcpp::SubscriptionBase

MessageTypeSupport::ConstSharedPtr type_support_;
rclcpp::AnySubscriptionCallback<CompoundMessage, std::allocator<void>> callback_;
/// Component which computes and publishes topic statistics for this subscriber
SubscriptionTopicStatisticsSharedPtr subscription_topic_statistics_{ nullptr };
};
} // namespace ros_babel_fish

Expand Down
33 changes: 1 addition & 32 deletions ros_babel_fish/src/detail/babel_fish_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ BabelFishSubscription::BabelFishSubscription(
MessageTypeSupport::ConstSharedPtr type_support, const std::string &topic_name,
const rclcpp::QoS &qos,
rclcpp::AnySubscriptionCallback<CompoundMessage, std::allocator<void>> callback,
const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> &options,
SubscriptionTopicStatisticsSharedPtr subscription_topic_statistics )
const rclcpp::SubscriptionOptionsWithAllocator<std::allocator<void>> &options )
: rclcpp::SubscriptionBase( node_base, type_support->type_support_handle, topic_name,
options.to_rcl_subscription_options( qos ), options.event_callbacks,
options.use_default_callbacks,
Expand All @@ -29,10 +28,6 @@ BabelFishSubscription::BabelFishSubscription(
{
// TODO: Adding intra process support [very low priority]

if ( subscription_topic_statistics != nullptr ) {
this->subscription_topic_statistics_ = std::move( subscription_topic_statistics );
}

TRACEPOINT( rclcpp_subscription_init, static_cast<const void *>( get_subscription_handle().get() ),
static_cast<const void *>( this ) );
TRACEPOINT( rclcpp_subscription_callback_added, static_cast<const void *>( this ),
Expand Down Expand Up @@ -64,40 +59,14 @@ std::shared_ptr<rclcpp::SerializedMessage> BabelFishSubscription::create_seriali
void BabelFishSubscription::handle_message( std::shared_ptr<void> &message,
const rclcpp::MessageInfo &message_info )
{
std::chrono::time_point<std::chrono::system_clock> now;
if ( subscription_topic_statistics_ ) {
// get current time before executing callback to
// exclude callback duration from topic statistics result.
now = std::chrono::system_clock::now();
}

callback_.dispatch( CompoundMessage::make_shared( *type_support_, message ), message_info );

if ( subscription_topic_statistics_ ) {
const auto nanos = std::chrono::time_point_cast<std::chrono::nanoseconds>( now );
const auto time = rclcpp::Time( nanos.time_since_epoch().count() );
subscription_topic_statistics_->handle_message( message_info.get_rmw_message_info(), time );
}
}

void BabelFishSubscription::handle_serialized_message(
const std::shared_ptr<rclcpp::SerializedMessage> &serialized_message,
const rclcpp::MessageInfo &message_info )
{
std::chrono::time_point<std::chrono::system_clock> now;
if ( subscription_topic_statistics_ ) {
// get current time before executing callback to
// exclude callback duration from topic statistics result.
now = std::chrono::system_clock::now();
}

callback_.dispatch( serialized_message, message_info );

if ( subscription_topic_statistics_ ) {
const auto nanos = std::chrono::time_point_cast<std::chrono::nanoseconds>( now );
const auto time = rclcpp::Time( nanos.time_since_epoch().count() );
subscription_topic_statistics_->handle_message( message_info.get_rmw_message_info(), time );
}
}

void BabelFishSubscription::handle_loaned_message( void *loaned_message,
Expand Down

0 comments on commit 7bd8f08

Please sign in to comment.