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

Code style update #107

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
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
a693461
CmakeList: add some compile options
khancyr Jul 31, 2024
b76b5d8
ArduPilotPlugin.hh: remove unexisting forward declaration
khancyr Jul 31, 2024
ab89928
ArduPilotPlugin.hh: make class final to make clang-tidy happy
khancyr Jul 31, 2024
4acd2eb
ArduPilotPlugin.hh: make destructor default and final to make clang-t…
khancyr Jul 31, 2024
097e629
ArduPilotPlugin.hh: sdf::ElementPtr can be access as const reference
khancyr Jul 31, 2024
00aa219
ArduPilotPlugin.cc: make Control destructor default
khancyr Jul 31, 2024
1e1e837
ArduPilotPlugin.cc: fix static member access from instance
khancyr Jul 31, 2024
8293db4
ArduPilotPlugin.cc: fix ranges variable shadowing
khancyr Jul 31, 2024
46c5d46
ArduPilotPlugin.cc: fix fcu_frame_count implict cast
khancyr Jul 31, 2024
e53c3e2
ArduPilotPlugin.cc: fix unused parameter
khancyr Jul 31, 2024
b2c5158
ArduPilotPlugin.cc: fix implicit fallthrough
khancyr Jul 31, 2024
60b979b
ArduPilotPlugin.cc: fix implicast
khancyr Jul 31, 2024
2c61274
ArduPilotPlugin.cc: fix pkt_frame_count implicit cast
khancyr Jul 31, 2024
b5537b7
ArduPilotPlugin.cc: comment unused variables
khancyr Jul 31, 2024
145bde5
ArduPilotPlugin.cc: zero init variable (clang-tidy check)
khancyr Jul 31, 2024
2e2c252
GstCameraPlugin: fix unused parameter
khancyr Jul 31, 2024
66bd3ee
GstCameraPlugin: correct cast and nullptr usage
khancyr Jul 31, 2024
68362da
CMakeList: Correct compile flags for clang
khancyr Aug 5, 2024
9f09242
ArduPilotPlugin: fix implicit conversion changes signedness: 'int' to…
khancyr Aug 5, 2024
60bc962
ArduPilotPlugin: use ranged base loop
khancyr Aug 5, 2024
4af5cea
ArduPilotPlugin: used lambda instead of bind
khancyr Aug 5, 2024
c5f1916
ArduPilotPlugin: use make_shared to create object
khancyr Aug 5, 2024
8d6727e
ArduPilotPlugin: use std::move to get OnMessageWrapper callback
khancyr Aug 5, 2024
551c0aa
ArduPilotPlugin: fix initial value and import
khancyr Aug 5, 2024
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
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ find_package(OpenCV REQUIRED)

pkg_check_modules(GST REQUIRED gstreamer-1.0 gstreamer-app-1.0)

# Make external include directories system includes to suppress warnings.
include_directories(SYSTEM ${RapidJSON_INCLUDE_DIRS})
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
include_directories(SYSTEM ${GST_INCLUDE_DIRS})

# --------------------------------------------------------------------------- #
# Build plugin.
Expand Down Expand Up @@ -113,6 +117,34 @@ target_link_libraries(GstCameraPlugin PRIVATE
${GST_LINK_LIBRARIES}
)

# Retrieve the list of current targets
get_property(current_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
# Filter out targets that end with _uninstall
list(FILTER current_targets EXCLUDE REGEX "uninstall$")

# Apply compile options to each target, cannot use global compile options as gazebo don't comply with them
foreach(target ${current_targets})
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(${target} PRIVATE -Wshadow -Wformat)
target_compile_options(${target} PRIVATE -Wcast-align -Woverloaded-virtual)
target_compile_options(${target} PRIVATE -Wnull-dereference)
target_compile_options(${target} PRIVATE -Wconversion)
target_compile_options(${target} PRIVATE -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls)
target_compile_options(${target} PRIVATE -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Wsign-promo -Wswitch -Wundef)
target_compile_options(${target} PRIVATE -Wold-style-cast)
target_compile_options(${target} PRIVATE -Werror)
target_compile_options(${target} PRIVATE -Werror=return-type)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target} PRIVATE -Wuseless-cast )
target_compile_options(${target} PRIVATE -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wstrict-null-sentinel)
endif()

target_compile_options(${target} PRIVATE -ffunction-sections -fdata-sections)
target_link_options(${target} PRIVATE -Wl,--gc-sections)
endif()
endforeach()

# --------------------------------------------------------------------------- #
# Install.

Expand Down
17 changes: 8 additions & 9 deletions include/ArduPilotPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct servo_packet_32 {
};

// Forward declare private data class
class ArduPilotSocketPrivate;
class ArduPilotPluginPrivate;

/// \brief Interface ArduPilot from ardupilot stack
Expand Down Expand Up @@ -86,7 +85,7 @@ class ArduPilotPluginPrivate;
/// controller synchronization
/// <have_32_channels> set true if 32 channels are enabled
///
class GZ_SIM_VISIBLE ArduPilotPlugin:
class GZ_SIM_VISIBLE ArduPilotPlugin final:
public gz::sim::System,
public gz::sim::ISystemConfigure,
public gz::sim::ISystemPostUpdate,
Expand All @@ -97,7 +96,7 @@ class GZ_SIM_VISIBLE ArduPilotPlugin:
public: ArduPilotPlugin();

/// \brief Destructor.
public: ~ArduPilotPlugin();
public: ~ArduPilotPlugin() final = default;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not a problem here, but there can be some nasty side effects in shared libraries when defining virtual methods inline in headers. What happens is that each DLL using the header creates a copy of the destructor, so it is undefined which particular one gets called. Worse, a DLL unloading can destroy objects that are still supposed to be in scope. Biggest issue is with templates and base classes, but I now avoid this after being burned. Was a problem in the core Gazebo libraries for some time - now corrected.


public: void Reset(const UpdateInfo &_info,
EntityComponentManager &_ecm) final;
Expand All @@ -120,27 +119,27 @@ class GZ_SIM_VISIBLE ArduPilotPlugin:

/// \brief Load control channels
private: void LoadControlChannels(
sdf::ElementPtr _sdf,
const sdf::ElementPtr& _sdf,
gz::sim::EntityComponentManager &_ecm);

/// \brief Load IMU sensors
private: void LoadImuSensors(
sdf::ElementPtr _sdf,
const sdf::ElementPtr &_sdf,
gz::sim::EntityComponentManager &_ecm);

/// \brief Load GPS sensors
private: void LoadGpsSensors(
sdf::ElementPtr _sdf,
const sdf::ElementPtr &_sdf,
gz::sim::EntityComponentManager &_ecm);

/// \brief Load range sensors
private: void LoadRangeSensors(
sdf::ElementPtr _sdf,
const sdf::ElementPtr &_sdf,
gz::sim::EntityComponentManager &_ecm);

/// \brief Load wind sensors
private: void LoadWindSensors(
sdf::ElementPtr _sdf,
const sdf::ElementPtr &_sdf,
gz::sim::EntityComponentManager &_ecm);

/// \brief Update the control surfaces controllers.
Expand Down Expand Up @@ -173,7 +172,7 @@ class GZ_SIM_VISIBLE ArduPilotPlugin:
private: void SendState() const;

/// \brief Initialise flight dynamics model socket
private: bool InitSockets(sdf::ElementPtr _sdf) const;
private: bool InitSockets(const sdf::ElementPtr& _sdf) const;

/// \brief Private data pointer.
private: std::unique_ptr<ArduPilotPluginPrivate> dataPtr;
Expand Down
Loading
Loading