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

Disable rosout logging for the bridge #197

Merged
merged 2 commits into from
May 18, 2019
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
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ if(TEST_ROS1_BRIDGE)
set(TEST_BRIDGE_DYNAMIC_BRIDGE "$<TARGET_FILE:dynamic_bridge>")
set(TEST_BRIDGE_ROS2_CLIENT "$<TARGET_FILE:test_ros2_client_cpp>")
set(TEST_BRIDGE_ROS2_SERVER "$<TARGET_FILE:test_ros2_server_cpp>")
set(TEST_BRIDGE_RMW ${rmw_implementation})
endif()

macro(targets)
set(TEST_BRIDGE_RMW ${rmw_implementation})

configure_file(
test/test_topics_across_dynamic_bridge.py.in
test_topics_across_dynamic_bridge${target_suffix}.py.genexp
Expand All @@ -231,7 +232,7 @@ macro(targets)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
TARGET test_topics_across_dynamic_bridge${target_suffix}
ENV RMW_IMPLEMENTAION=${rmw_implementaion}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)

configure_file(
Expand All @@ -246,7 +247,7 @@ macro(targets)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
TARGET test_services_across_dynamic_bridge${target_suffix}
ENV RMW_IMPLEMENTAION=${rmw_implementaion}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)
endmacro()

Expand Down
21 changes: 20 additions & 1 deletion src/dynamic_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cstring>
#include <map>
#include <memory>
#include <set>
Expand All @@ -36,6 +37,8 @@
#include "rclcpp/rclcpp.hpp"
#include "rclcpp/scope_exit.hpp"

#include "rcutils/get_env.h"

#include "ros1_bridge/bridge.hpp"


Expand Down Expand Up @@ -456,7 +459,23 @@ int main(int argc, char * argv[])
}

// ROS 2 node
rclcpp::init(argc, argv);

// TODO(hidmic): remove when Fast-RTPS supports registering multiple
// typesupports for the same topic in the same process.
// See https://github.com/ros2/rmw_fastrtps/issues/265.
std::vector<char *> args(argv, argv + argc);
char log_disable_rosout[] = "__log_disable_rosout:=true";

const char * rmw_implementation = "";
const char * error = rcutils_get_env("RMW_IMPLEMENTATION", &rmw_implementation);
if (NULL != error) {
throw std::runtime_error(error);
}
if (0 == strcmp(rmw_implementation, "") || NULL != strstr(rmw_implementation, "fastrtps")) {
args.push_back(log_disable_rosout);
}
rclcpp::init(args.size(), args.data());

auto ros2_node = rclcpp::Node::make_shared("ros_bridge");

// ROS 1 node
Expand Down