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

Setup profiler #52

Merged
merged 3 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@ This repository contains packages used for Gazebo simulation of marine buoys.

Start from [Buoy entrypoint](https://github.com/osrf/buoy_entrypoint).

## Development

### Profiler

By default, the profiler isn't enabled. To enable it at compilation time,
pass the `-DENABLE_PROFILER=1` CMake argument. For example, to compile tests
and enable the profiler with `colcon`:

```
colcon build --cmake-args ' -DBUILD_TESTING=false' ' -DENABLE_PROFILER=1'
```

See more on [this tutorial](https://ignitionrobotics.org/api/common/4.4/profiler.html).
16 changes: 14 additions & 2 deletions buoy_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
cmake_minimum_required(VERSION 3.5)
project(buoy_gazebo)

# Option to enable profiler
option(ENABLE_PROFILER "Enable Ignition Profiler" FALSE)

if(ENABLE_PROFILER)
add_definitions("-DIGN_PROFILER_ENABLE=1")
else()
add_definitions("-DIGN_PROFILER_ENABLE=0")
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(buoy_msgs REQUIRED)

find_package(ignition-cmake2 REQUIRED)
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
find_package(ignition-common4 REQUIRED COMPONENTS profiler)
set(GZ_COMMON_VER ${ignition-common4_VERSION_MAJOR})
find_package(ignition-gazebo6 REQUIRED)
set(GZ_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR})
set(GZ_SIM_VER ${ignition-gazebo6_VERSION_MAJOR})


# Plugins
Expand Down Expand Up @@ -50,8 +61,9 @@ function(gz_add_plugin plugin_name)
)
target_link_libraries(${plugin_name}
PUBLIC
ignition-gazebo${GZ_GAZEBO_VER}::ignition-gazebo${GZ_GAZEBO_VER}
ignition-gazebo${GZ_SIM_VER}::ignition-gazebo${GZ_SIM_VER}
ignition-plugin${GZ_PLUGIN_VER}::ignition-plugin${GZ_PLUGIN_VER}
ignition-common${GZ_COMMON_VER}::profiler
${gz_add_plugin_PUBLIC_LINK_LIBS}
PRIVATE
${gz_add_plugin_PRIVATE_LINK_LIBS}
Expand Down
4 changes: 1 addition & 3 deletions buoy_gazebo/src/ElectroHydraulicPTO/ElectroHydraulicPTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,14 @@ void ElectroHydraulicPTO::PreUpdate(
const int n = 2;
int info;

IGN_PROFILE("ElectroHydraulicPTO::Update");
IGN_PROFILE("#ElectroHydraulicPTO::PreUpdate");
// Nothing left to do if paused.
if (_info.paused) {
return;
}

auto SimTime = std::chrono::duration<double>(_info.simTime).count();

IGN_PROFILE("#ElectroHydraulicPTO::PreUpdate");

// If the joints haven't been identified yet, the plugin is disabled
if (this->dataPtr->PrismaticJointEntity == ignition::gazebo::kNullEntity) {
return;
Expand Down