Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pub/sub init, publish and take instrumentation using tracetools #329

Merged
merged 2 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 rmw_cyclonedds_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ find_package(ament_cmake_ros REQUIRED)

find_package(rcutils REQUIRED)
find_package(rcpputils REQUIRED)
find_package(tracetools REQUIRED)

#find_package(cyclonedds_cmake_module REQUIRED)
find_package(CycloneDDS QUIET CONFIG)
Expand Down Expand Up @@ -77,6 +78,7 @@ ament_target_dependencies(rmw_cyclonedds_cpp
"rmw"
"rmw_dds_common"
"rosidl_runtime_c"
"tracetools"
)

configure_rmw_library(rmw_cyclonedds_cpp)
Expand Down
1 change: 1 addition & 0 deletions rmw_cyclonedds_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<depend>rosidl_runtime_c</depend>
<depend>rosidl_typesupport_introspection_c</depend>
<depend>rosidl_typesupport_introspection_cpp</depend>
<depend>tracetools</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
14 changes: 13 additions & 1 deletion rmw_cyclonedds_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@

#include "rosidl_typesupport_cpp/message_type_support.hpp"

#include "tracetools/tracetools.h"

#include "namespace_prefix.hpp"

#include "dds/dds.h"
Expand Down Expand Up @@ -1547,6 +1549,7 @@ extern "C" rmw_ret_t rmw_publish(
return RMW_RET_INVALID_ARGUMENT);
auto pub = static_cast<CddsPublisher *>(publisher->data);
assert(pub);
TRACEPOINT(rmw_publish, ros_message);
if (dds_write(pub->enth, ros_message) >= 0) {
return RMW_RET_OK;
} else {
Expand Down Expand Up @@ -2190,6 +2193,7 @@ extern "C" rmw_publisher_t * rmw_create_publisher(
}

cleanup_publisher.cancel();
TRACEPOINT(rmw_publisher_init, static_cast<const void *>(pub), cddspub->gid.data);
return pub;
}

Expand Down Expand Up @@ -2695,6 +2699,7 @@ extern "C" rmw_subscription_t * rmw_create_subscription(
}

cleanup_subscription.cancel();
TRACEPOINT(rmw_subscription_init, static_cast<const void *>(sub), cddssub->gid.data);
return sub;
}

Expand Down Expand Up @@ -2850,10 +2855,17 @@ static rmw_ret_t rmw_take_int(
fprintf(stderr, "** sample in history for %.fms\n", static_cast<double>(dt) / 1e6);
}
#endif
return RMW_RET_OK;
goto take_done;
}
}
*taken = false;
take_done:
TRACEPOINT(
rmw_take,
static_cast<const void *>(subscription),
static_cast<const void *>(ros_message),
(message_info ? message_info->source_timestamp : 0LL),
*taken);
return RMW_RET_OK;
}

Expand Down