Skip to content

Commit

Permalink
add foxglove packages
Browse files Browse the repository at this point in the history
Signed-off-by: wep21 <[email protected]>
  • Loading branch information
wep21 committed Feb 20, 2025
1 parent b9605b8 commit c00920c
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 0 deletions.
96 changes: 96 additions & 0 deletions patch/ros-jazzy-ffmpeg-encoder-decoder.unix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/include/ffmpeg_encoder_decoder/decoder.hpp b/include/ffmpeg_encoder_decoder/decoder.hpp
index 0e2521c..94625e5 100644
--- a/include/ffmpeg_encoder_decoder/decoder.hpp
+++ b/include/ffmpeg_encoder_decoder/decoder.hpp
@@ -81,7 +81,7 @@ private:
AVFrame * colorFrame_{NULL};
SwsContext * swsContext_{NULL};
enum AVPixelFormat hwPixFormat_;
- AVPacket packet_;
+ // AVPacket packet_;
AVBufferRef * hwDeviceContext_{NULL};
};
} // namespace ffmpeg_encoder_decoder
diff --git a/src/decoder.cpp b/src/decoder.cpp
index 0a12d25..9737ffe 100644
--- a/src/decoder.cpp
+++ b/src/decoder.cpp
@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); }
void Decoder::reset()
{
if (codecContext_) {
+#if LIBAVFORMAT_VERSION_MAJOR < 59
avcodec_close(codecContext_);
+#else
+ avcodec_free_context(&codecContext_);
+#endif
av_free(codecContext_);
codecContext_ = NULL;
}
@@ -255,7 +259,7 @@ bool Decoder::decodePacket(
image->header.stamp = it->second;
ptsToStamp_.erase(it);
#ifdef USE_AV_FLAGS
- callback_(image, decodedFrame_->flags || AV_FRAME_FLAG_KEY); // deliver callback
+ callback_(image, decodedFrame_->flags | AV_FRAME_FLAG_KEY); // deliver callback
#else
callback_(image, decodedFrame_->key_frame); // deliver callback
#endif
diff --git a/src/encoder.cpp b/src/encoder.cpp
index a4b6de6..8a3f40a 100644
--- a/src/encoder.cpp
+++ b/src/encoder.cpp
@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame)
void Encoder::closeCodec()
{
if (codecContext_) {
+#if LIBAVFORMAT_VERSION_MAJOR < 59
avcodec_close(codecContext_);
+#else
+ avcodec_free_context(&codecContext_);
+#endif
codecContext_ = nullptr;
}
free_frame(&frame_);
@@ -207,11 +211,19 @@ void Encoder::doOpenCodec(int width, int height)
setAVOption("preset", preset_);
setAVOption("tune", tune_);
setAVOption("delay", delay_);
+#ifdef __APPLE__
+ RCLCPP_DEBUG(
+ logger_,
+ "codec: %10s, profile: %10s, preset: %10s,"
+ " bit_rate: %10lld qmax: %2d",
+ encoder_.c_str(), profile_.c_str(), preset_.c_str(), bitRate_, qmax_);
+#else
RCLCPP_DEBUG(
logger_,
"codec: %10s, profile: %10s, preset: %10s,"
" bit_rate: %10ld qmax: %2d",
encoder_.c_str(), profile_.c_str(), preset_.c_str(), bitRate_, qmax_);
+#endif

err = avcodec_open2(codecContext_, codec, NULL);
utils::check_for_err("cannot open codec", err);
diff --git a/src/utils.cpp b/src/utils.cpp
index da089e4..01e8eea 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format(
std::vector<enum AVPixelFormat> get_encoder_formats(const AVCodec * c)
{
std::vector<enum AVPixelFormat> formats;
- if (c && c->pix_fmts) {
- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
+#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39)
+ const enum AVPixelFormat *pix_fmts = NULL;
+ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL);
+ if (c && pix_fmts) {
+#else
+ const enum AVPixelFormat *pix_fmts = c->pix_fmts;
+ if (c && pix_fmts) {
+#endif
+ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
formats.push_back(*p);
}
}
35 changes: 35 additions & 0 deletions patch/ros-jazzy-foxglove-bridge.win.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 715ce29..18d4865 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,11 @@ project(foxglove_bridge LANGUAGES CXX VERSION 0.8.3)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

+if(MSVC)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+ set(BUILD_SHARED_LIBS TRUE)
+endif()
+
macro(enable_strict_compiler_warnings target)
if (MSVC)
target_compile_options(${target} PRIVATE /WX /W4)
@@ -77,7 +82,7 @@ add_library(foxglove_bridge_base SHARED
${CMAKE_CURRENT_BINARY_DIR}/foxglove_bridge_base/src/version.cpp
)
target_include_directories(foxglove_bridge_base
- PUBLIC
+ SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/foxglove_bridge_base/include>
$<INSTALL_INTERFACE:include>
)
@@ -92,7 +97,8 @@ if(nlohmann_json_FOUND)
else()
message(STATUS "nlohmann_json not found, will search at compile time")
endif()
-enable_strict_compiler_warnings(foxglove_bridge_base)
+# enable_strict_compiler_warnings(foxglove_bridge_base)
+target_compile_definitions(foxglove_bridge_base PUBLIC _WEBSOCKETPP_CPP11_STL_)

message(STATUS "ROS_VERSION: " $ENV{ROS_VERSION})
message(STATUS "ROS_DISTRO: " $ENV{ROS_DISTRO})
23 changes: 23 additions & 0 deletions patch/ros-jazzy-rosx-introspection.unix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/src/ros_parser.cpp b/src/ros_parser.cpp
index 40c161b..8a1523c 100644
--- a/src/ros_parser.cpp
+++ b/src/ros_parser.cpp
@@ -581,8 +581,7 @@ bool Parser::serializeFromJson(const std::string_view json_string,
}
else
{
- rapidjson::Value next_value = value_field->GetObject();
- serializeImpl(msg_node_child.get(), &next_value);
+ serializeImpl(msg_node_child.get(), value_field);
}
}
break;
@@ -600,7 +599,7 @@ bool Parser::serializeFromJson(const std::string_view json_string,
auto root_msg =
_schema->field_tree.croot()->value()->getMessagePtr(_schema->msg_library);

- rapidjson::Value json_root = json_document.GetObject();
+ rapidjson::Value& json_root = json_document;
serializeImpl(root_msg.get(), &json_root);

return true;
42 changes: 42 additions & 0 deletions patch/ros-jazzy-rosx-introspection.win.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/src/ros_parser.cpp b/src/ros_parser.cpp
index 40c161b..8a1523c 100644
--- a/src/ros_parser.cpp
+++ b/src/ros_parser.cpp
@@ -581,8 +581,7 @@ bool Parser::serializeFromJson(const std::string_view json_string,
}
else
{
- rapidjson::Value next_value = value_field->GetObject();
- serializeImpl(msg_node_child.get(), &next_value);
+ serializeImpl(msg_node_child.get(), value_field);
}
}
break;
@@ -600,7 +599,7 @@ bool Parser::serializeFromJson(const std::string_view json_string,
auto root_msg =
_schema->field_tree.croot()->value()->getMessagePtr(_schema->msg_library);

- rapidjson::Value json_root = json_document.GetObject();
+ rapidjson::Value& json_root = json_document;
serializeImpl(root_msg.get(), &json_root);

return true;

diff --git a/src/ros_utils/message_definition_cache.cpp b/src/ros_utils/message_definition_cache.cpp
index 7c4da1f..41b8f5e 100644
--- a/src/ros_utils/message_definition_cache.cpp
+++ b/src/ros_utils/message_definition_cache.cpp
@@ -22,3 +22,4 @@
+#include <functional>
#include <regex>
#include <set>
#include <string>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 005588b..16a8b50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,2 +7,3 @@ project(rosx_introspection LANGUAGES CXX VERSION 1.0.2)
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)


4 changes: 4 additions & 0 deletions vinca_linux_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,9 @@ packages_select_by_deps:

- grid_map

- foxglove_bridge
- foxglove_compressed_video_transport
- foxglove_msgs

patch_dir: patch
rosdistro_snapshot: rosdistro_snapshot.yaml
4 changes: 4 additions & 0 deletions vinca_linux_aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,9 @@ packages_select_by_deps:

- grid_map

- foxglove_bridge
- foxglove_compressed_video_transport
- foxglove_msgs

patch_dir: patch
rosdistro_snapshot: rosdistro_snapshot.yaml
4 changes: 4 additions & 0 deletions vinca_osx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,9 @@ packages_select_by_deps:

- grid_map

- foxglove_bridge
- foxglove_compressed_video_transport
- foxglove_msgs

patch_dir: patch
rosdistro_snapshot: rosdistro_snapshot.yaml
4 changes: 4 additions & 0 deletions vinca_osx_arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,9 @@ packages_select_by_deps:

- grid_map

- foxglove_bridge
- foxglove_compressed_video_transport
- foxglove_msgs

patch_dir: patch
rosdistro_snapshot: rosdistro_snapshot.yaml
3 changes: 3 additions & 0 deletions vinca_win.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ packages_select_by_deps:
- ament_cmake_mypy
- rosbridge_suite

- foxglove_bridge
# - foxglove_compressed_video_transport
- foxglove_msgs

patch_dir: patch
rosdistro_snapshot: rosdistro_snapshot.yaml
Expand Down

0 comments on commit c00920c

Please sign in to comment.