Skip to content

Commit

Permalink
Disable rosout logging for the bridge (ros2#197)
Browse files Browse the repository at this point in the history
* Disable rosout logging for the dynamic_bridge.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Fix CMake code that registers launch tests.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Dhananjay Sathe <dhananjay.sathe@rapyuta-robotics.com>
  • Loading branch information
hidmic authored and dhananjaysathe committed Aug 22, 2019
1 parent c102806 commit 82a3beb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,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 @@ -238,7 +239,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 @@ -253,7 +254,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

0 comments on commit 82a3beb

Please sign in to comment.