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

Fix warnings with GCC on Ubuntu 20.04 #88

Merged
merged 1 commit into from
Jan 13, 2025
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
11 changes: 6 additions & 5 deletions face_cropping/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
Expand Down Expand Up @@ -187,6 +182,12 @@ install(TARGETS face_cropping_webrtc_node DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY models DESTINATION share/${PROJECT_NAME})

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(torchvision PRIVATE -w)
target_compile_options(face_cropping_node PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(face_cropping_webrtc_node PRIVATE -Wall -Wextra -Wpedantic)
endif()

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
Expand Down
6 changes: 0 additions & 6 deletions map_image_generator/src/drawers/LabelImageDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <opencv2/imgproc.hpp>

#include <tf2/utils.h>

using namespace map_image_generator;

LabelImageDrawer::LabelImageDrawer(const Parameters& parameters, rclcpp::Node& node, tf2_ros::Buffer& tfBuffer)
Expand Down Expand Up @@ -52,14 +50,10 @@ void LabelImageDrawer::drawLabel(
tf2::fromMsg(label.pose.pose, labelPose);
labelPose = transform * labelPose;
adjustTransformForRobotRef(labelPose);
double yaw = tf2::getYaw(labelPose.getRotation());

int startX, startY;
convertTransformToMapCoordinates(labelPose, startX, startY);

int endX = static_cast<int>(startX + size * cos(yaw));
int endY = static_cast<int>(startY + size * sin(yaw));

cv::drawMarker(
image,
cv::Point(startX, startY),
Expand Down
20 changes: 12 additions & 8 deletions map_image_generator/src/drawers/OccupancyGridImageDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,17 @@ void OccupancyGridImageDrawer::rotateImageAboutCenter(cv::Mat& image, double ang
OccupancyGridImageDrawer::DirectionalValues
OccupancyGridImageDrawer::computePadding(const DirectionalValues& position, int height, int width)
{
// TODO: remove pragma when using C++20
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
return {
.top = restrictToPositive((height - 1) / 2 - position.top),
.bottom = restrictToPositive(height / 2 - position.bottom),

.left = restrictToPositive((width - 1) / 2 - position.left),
.right = restrictToPositive(width / 2 - position.right),
};
#pragma GCC diagnostic pop
}

OccupancyGridImageDrawer::MapCoordinates
Expand All @@ -217,12 +221,16 @@ OccupancyGridImageDrawer::MapCoordinates
OccupancyGridImageDrawer::DirectionalValues
OccupancyGridImageDrawer::getDirectionsFromMapCoordinates(const MapCoordinates& mapCoordinates, const cv::Mat& map)
{
// TODO: remove pragma when using C++20
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
return {
.top = 0 + mapCoordinates.y,
.bottom = (map.rows - 1) - mapCoordinates.y,
.left = 0 + mapCoordinates.x,
.right = (map.cols - 1) - mapCoordinates.x,
};
#pragma GCC diagnostic pop
}

void OccupancyGridImageDrawer::drawOccupancyGridImage(cv::Mat& image)
Expand All @@ -239,18 +247,10 @@ void OccupancyGridImageDrawer::drawOccupancyGridImage(cv::Mat& image)
MapCoordinates robotCoordinates = getMapCoordinatesFromTf(*robotTransform);
DirectionalValues robotPosition = getDirectionsFromMapCoordinates(robotCoordinates, m_scaledOccupancyGridImage);

double heightBorder = 0.1 * outHeight;
double widthBorder = 0.1 * outWidth;

// Map center
double occupancyXOrigin = m_lastOccupancyGrid->info.origin.position.x;
double occupancyYOrigin = m_lastOccupancyGrid->info.origin.position.y;

tf2::Transform mapOriginPose;
mapOriginPose.setOrigin({0.0, 0.0, 0.0});

MapCoordinates mapOriginCoordinates = getMapCoordinatesFromTf(mapOriginPose);
DirectionalValues mapPosition = getDirectionsFromMapCoordinates(mapOriginCoordinates, m_scaledOccupancyGridImage);

double hScaleFactor = (0.4 * outWidth) / std::abs(robotPosition.left - mapOriginCoordinates.x);
double vScaleFactor = (0.4 * outHeight) / std::abs(robotPosition.top - mapOriginCoordinates.y);
Expand All @@ -259,10 +259,14 @@ void OccupancyGridImageDrawer::drawOccupancyGridImage(cv::Mat& image)

const auto& zoomedMap = getZoomedOccupancyImage();

// TODO: remove pragma when using C++20
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
MapCoordinates zoomedMapOriginCoordinates{
.x = static_cast<int>(mapOriginCoordinates.x * m_parameters.scaleFactor()),
.y = static_cast<int>(mapOriginCoordinates.y * m_parameters.scaleFactor()),
};
#pragma GCC diagnostic pop
DirectionalValues zoomedMapPosition = getDirectionsFromMapCoordinates(zoomedMapOriginCoordinates, zoomedMap);

DirectionalValues padding = computePadding(zoomedMapPosition, outHeight, outWidth);
Expand Down
4 changes: 2 additions & 2 deletions opentera_webrtc_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ find_package(ament_cmake REQUIRED)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/node_modules.stamp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/opentera-webrtc-teleop-frontend/teleop-vue/package.json
COMMAND npm install
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/output_only_if_failed.sh npm install
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/node_modules.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/opentera-webrtc-teleop-frontend/teleop-vue
VERBATIM
Expand All @@ -45,7 +45,7 @@ file(
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dist.stamp
DEPENDS ${FRONTEND_FILES} ${CMAKE_CURRENT_BINARY_DIR}/node_modules.stamp opentera_werbrtc_teleop_frontend-install
COMMAND npm run build
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/output_only_if_failed.sh npm run build
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/dist.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/opentera-webrtc-teleop-frontend/teleop-vue
VERBATIM
Expand Down
10 changes: 10 additions & 0 deletions opentera_webrtc_demos/cmake/output_only_if_failed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

output=$("$@" 2>&1)
return_code=$?

if [ $return_code -ne 0 ]; then
echo -e "$output" >&2
fi

exit $return_code
2 changes: 1 addition & 1 deletion opentera_webrtc_robot_gui/src/LocalCameraWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void LocalCameraWindow::mousePressEvent(QMouseEvent* event)
}
}

void LocalCameraWindow::focusOutEvent(QFocusEvent* event)
void LocalCameraWindow::focusOutEvent([[maybe_unused]] QFocusEvent* event)
{
if (isSizeGripEnabled())
{
Expand Down
2 changes: 1 addition & 1 deletion opentera_webrtc_robot_gui/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void MainWindow::onPeerStatusClientDisconnected(const QString& id)
}
}

void MainWindow::_onPeerStatus(const QString& id, const QString& name, int status)
void MainWindow::_onPeerStatus(const QString& id, [[maybe_unused]] const QString& name, int status)
{
switch (status)
{
Expand Down
12 changes: 6 additions & 6 deletions opentera_webrtc_robot_gui/src/ROSCameraView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void CameraWidget::setImage(const QImage& image, bool repaintNow)
}
}

void CameraWidget::paintEvent(QPaintEvent* event)
void CameraWidget::paintEvent([[maybe_unused]] QPaintEvent* event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
Expand All @@ -27,9 +27,9 @@ void CameraWidget::paintEvent(QPaintEvent* event)
return;
}

float scale =
std::min(static_cast<float>(width()) / static_cast<float>(m_image.width()),
static_cast<float>(height()) / static_cast<float>(m_image.height()));
float scale = std::min(
static_cast<float>(width()) / static_cast<float>(m_image.width()),
static_cast<float>(height()) / static_cast<float>(m_image.height()));
int scaledWidth = static_cast<int>(scale * m_image.width());
int scaledHeight = static_cast<int>(scale * m_image.height());
int offsetX = std::max(0, (width() - scaledWidth) / 2);
Expand All @@ -41,8 +41,8 @@ void CameraWidget::paintEvent(QPaintEvent* event)
ROSCameraView::ROSCameraView(QWidget* parent)
: QWidget{parent},
m_layout{nullptr},
m_label{nullptr},
m_cameraWidget{nullptr}
m_cameraWidget{nullptr},
m_label{nullptr}
{
m_layout = new QVBoxLayout(this);

Expand Down
16 changes: 12 additions & 4 deletions opentera_webrtc_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

if(NOT CMAKE_BUILD_TYPE )
MESSAGE(STATUS "not define build type, set to release" )
set(CMAKE_BUILD_TYPE Release )
Expand Down Expand Up @@ -55,6 +51,8 @@ set(OPENTERA_WEBRTC_ENABLE_EXAMPLES OFF)
set(OPENTERA_WEBRTC_ENABLE_GSTREAMER ON)
# Use system opencv that is shared with ROS
set(OPENTERA_WEBRTC_USE_SYSTEM_OPENCV ON)
# Disable building the documentation, the pip install for the documentation is annoying.
set(OPENTERA_WEBRTC_ENABLE_PYTHON_HTML_DOC OFF)
# Enable install on build for python package, which is required for using it in ROS if using devel space
set(OPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_INSTALL_ON_BUILD OFF)
# Install in ROS worksapce
Expand Down Expand Up @@ -193,6 +191,16 @@ ament_target_dependencies(${PROJECT_NAME}_json_data_handler
set_target_properties(${PROJECT_NAME}_json_data_handler PROPERTIES OUTPUT_NAME json_data_handler PREFIX "")
install(TARGETS ${PROJECT_NAME}_json_data_handler DESTINATION lib/${PROJECT_NAME})

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${PROJECT_NAME}_topic_streamer PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(${PROJECT_NAME}_data_channel_bridge PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(${PROJECT_NAME}_json_data_handler PRIVATE -Wall -Wextra -Wpedantic)

foreach(target ${opentera_webrtc_native_client_targets})
target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic)
endforeach()
endif()

install(
DIRECTORY
lib/lib
Expand Down
2 changes: 1 addition & 1 deletion opentera_webrtc_ros/opentera-webrtc
Submodule opentera-webrtc updated 24 files
+2 −4 .github/workflows/cpp-python-tests.yml
+1 −1 .github/workflows/github-stats.yml
+1 −1 VERSION
+1 −0 opentera-webrtc-native-client/3rdParty/CMakeLists.txt
+11 −2 opentera-webrtc-native-client/3rdParty/webrtc_native/CMakeLists.txt
+3 −0 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/python/src/Json.cpp
+12 −5 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Handlers/PeerConnectionHandler.cpp
+1 −1 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Handlers/StreamPeerConnectionHandler.cpp
+26 −26 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/OpenteraAudioDeviceModule.cpp
+2 −2 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Sources/AudioSource.cpp
+3 −1 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/StreamClient.cpp
+1 −1 opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/WebrtcClient.cpp
+15 −15 ...t/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Encoders/H264GStreamerVideoEncoders.h
+6 −6 ...nt/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Encoders/Vp8GStreamerVideoEncoders.h
+7 −7 ...nt/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Encoders/Vp9GStreamerVideoEncoders.h
+4 −3 ...aWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoDecoderFactory.h
+2 −2 ...aWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoEncoderFactory.h
+1 −1 ...client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Utils/GStreamerMessageHandling.h
+7 −2 opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Decoders/GStreamerVideoDecoder.cpp
+3 −1 opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Encoders/GStreamerVideoEncoder.cpp
+16 −18 opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Encoders/H264GStreamerVideoEncoders.cpp
+10 −6 opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Encoders/Vp8GStreamerVideoEncoders.cpp
+8 −8 opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Encoders/Vp9GStreamerVideoEncoders.cpp
+3 −2 ...era-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoEncoderFactory.cpp