remove fprintf, use logging macros (#152)
* remove fprintf, use logging macros * consistent includes
This commit is contained in:
parent
2d961fb501
commit
5cdef527de
13 changed files with 53 additions and 46 deletions
|
@ -15,7 +15,8 @@
|
|||
#ifndef RCL_LIFECYCLE__DATA_TYPES_H_
|
||||
#define RCL_LIFECYCLE__DATA_TYPES_H_
|
||||
|
||||
#include <rcl/rcl.h>
|
||||
#include "rcl/rcl.h"
|
||||
|
||||
#include "rcl_lifecycle/visibility_control.h"
|
||||
|
||||
#if __cplusplus
|
||||
|
|
|
@ -22,8 +22,8 @@ extern "C"
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <rcl_lifecycle/visibility_control.h>
|
||||
#include <rcl_lifecycle/data_types.h>
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
#include "rcl_lifecycle/visibility_control.h"
|
||||
|
||||
RCL_LIFECYCLE_PUBLIC
|
||||
rcl_lifecycle_state_machine_t
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
#ifndef RCL_LIFECYCLE__TRANSITION_MAP_H_
|
||||
#define RCL_LIFECYCLE__TRANSITION_MAP_H_
|
||||
|
||||
#include <rcl/macros.h>
|
||||
#include <rcl_lifecycle/data_types.h>
|
||||
#include "rcl/macros.h"
|
||||
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
|
||||
#if __cplusplus
|
||||
extern "C"
|
||||
|
|
|
@ -22,17 +22,20 @@ extern "C"
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rcl/error_handling.h>
|
||||
#include <rcutils/format_string.h>
|
||||
#include <rmw/validate_full_topic_name.h>
|
||||
#include <rosidl_generator_c/message_type_support_struct.h>
|
||||
#include <rosidl_generator_c/string_functions.h>
|
||||
#include "lifecycle_msgs/msg/transition_event.h"
|
||||
|
||||
#include <lifecycle_msgs/msg/transition_event.h>
|
||||
#include "rcl/error_handling.h"
|
||||
|
||||
#include "rcutils/format_string.h"
|
||||
#include "rcutils/logging_macros.h"
|
||||
|
||||
#include "rmw/validate_full_topic_name.h"
|
||||
|
||||
#include "rosidl_generator_c/message_type_support_struct.h"
|
||||
#include "rosidl_generator_c/string_functions.h"
|
||||
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
|
||||
|
||||
static lifecycle_msgs__msg__TransitionEvent msg;
|
||||
static const char * pub_transition_event_suffix = "transition_event";
|
||||
static const char * srv_change_state_suffix = "change_state";
|
||||
|
@ -224,24 +227,19 @@ rcl_lifecycle_com_interface_init(
|
|||
|
||||
fail:
|
||||
if (RCL_RET_OK != rcl_publisher_fini(&com_interface->pub_transition_event, node_handle)) {
|
||||
fprintf(stderr, "%s:%u, Failed to destroy transition_event publisher\n",
|
||||
__FILE__, __LINE__);
|
||||
RCUTILS_LOG_ERROR("Failed to destroy transition_event publisher")
|
||||
}
|
||||
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_change_state, node_handle)) {
|
||||
fprintf(stderr, "%s:%u, Failed to destroy change_state service\n",
|
||||
__FILE__, __LINE__);
|
||||
RCUTILS_LOG_ERROR("Failed to destroy change_state service")
|
||||
}
|
||||
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_state, node_handle)) {
|
||||
fprintf(stderr, "%s:%u, Failed to destroy get_state service\n",
|
||||
__FILE__, __LINE__);
|
||||
RCUTILS_LOG_ERROR("Failed to destroy get_state service")
|
||||
}
|
||||
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_available_states, node_handle)) {
|
||||
fprintf(stderr, "%s:%u, Failed to destroy get_available_states service\n",
|
||||
__FILE__, __LINE__);
|
||||
RCUTILS_LOG_ERROR("Failed to destroy get_available_states service")
|
||||
}
|
||||
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_available_transitions, node_handle)) {
|
||||
fprintf(stderr, "%s:%u, Failed to destroy get_available_transitions service\n",
|
||||
__FILE__, __LINE__);
|
||||
RCUTILS_LOG_ERROR("Failed to destroy get_available_transitions service")
|
||||
}
|
||||
|
||||
if (topic_name) {
|
||||
|
|
|
@ -20,7 +20,7 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
#include <rcl/macros.h>
|
||||
#include "rcl/macros.h"
|
||||
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <lifecycle_msgs/msg/state.h>
|
||||
#include <lifecycle_msgs/msg/transition.h>
|
||||
#include "lifecycle_msgs/msg/state.h"
|
||||
#include "lifecycle_msgs/msg/transition.h"
|
||||
|
||||
#include "rcl/error_handling.h"
|
||||
#include "rcl/rcl.h"
|
||||
|
||||
#include "rcl_lifecycle/transition_map.h"
|
||||
#include "rcl/rcl.h"
|
||||
#include "rcl/error_handling.h"
|
||||
|
||||
#include "default_state_machine.h" // NOLINT
|
||||
#include "states.h" // NOLINT
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#ifndef DEFAULT_STATE_MACHINE_H_
|
||||
#define DEFAULT_STATE_MACHINE_H_
|
||||
|
||||
#include <rcl/macros.h>
|
||||
#include <rcl/types.h>
|
||||
#include "rcl/macros.h"
|
||||
#include "rcl/types.h"
|
||||
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
#include "rcl_lifecycle/visibility_control.h"
|
||||
|
|
|
@ -24,6 +24,8 @@ extern "C"
|
|||
#include "rcl/rcl.h"
|
||||
#include "rcl/error_handling.h"
|
||||
|
||||
#include "rcutils/logging_macros.h"
|
||||
|
||||
#include "rcl_lifecycle/rcl_lifecycle.h"
|
||||
#include "rcl_lifecycle/transition_map.h"
|
||||
|
||||
|
@ -148,8 +150,8 @@ rcl_lifecycle_is_valid_transition(
|
|||
return ¤t_state->valid_transitions[i];
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "%s:%u, No callback transition matching %d found for current state %s\n",
|
||||
__FILE__, __LINE__, key, state_machine->current_state->label);
|
||||
RCUTILS_LOG_WARN("No callback transition matching %d found for current state %s",
|
||||
key, state_machine->current_state->label)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -163,14 +165,14 @@ rcl_lifecycle_trigger_transition(
|
|||
|
||||
// If we have a faulty transition pointer
|
||||
if (!transition) {
|
||||
fprintf(stderr, "No transition found for node %s with key %d\n",
|
||||
state_machine->current_state->label, key);
|
||||
RCUTILS_LOG_ERROR("No transition found for node %s with key %d",
|
||||
state_machine->current_state->label, key)
|
||||
RCL_SET_ERROR_MSG("Transition is not registered.", rcl_get_default_allocator());
|
||||
return RCL_RET_ERROR;
|
||||
}
|
||||
|
||||
if (!transition->goal) {
|
||||
fprintf(stderr, "No valid goal is set\n");
|
||||
RCUTILS_LOG_ERROR("No valid goal is set")
|
||||
}
|
||||
state_machine->current_state = transition->goal;
|
||||
if (publish_notification) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#ifndef STATES_H_
|
||||
#define STATES_H_
|
||||
|
||||
#include <rcl_lifecycle/visibility_control.h>
|
||||
#include <rcl_lifecycle/data_types.h>
|
||||
#include "rcl_lifecycle/data_types.h"
|
||||
#include "rcl_lifecycle/visibility_control.h"
|
||||
|
||||
#if __cplusplus
|
||||
extern "C"
|
||||
|
|
|
@ -21,10 +21,11 @@ extern "C"
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rcl_lifecycle/transition_map.h"
|
||||
#include "rcl/error_handling.h"
|
||||
#include "rcutils/format_string.h"
|
||||
|
||||
#include "rcl_lifecycle/transition_map.h"
|
||||
|
||||
rcl_lifecycle_transition_map_t
|
||||
rcl_lifecycle_get_zero_initialized_transition_map()
|
||||
{
|
||||
|
|
|
@ -17,16 +17,18 @@
|
|||
// as depicted in design.ros2.org
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <lifecycle_msgs/msg/state.h>
|
||||
#include <lifecycle_msgs/msg/transition.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "lifecycle_msgs/msg/state.h"
|
||||
#include "lifecycle_msgs/msg/transition.h"
|
||||
|
||||
#include "rcl/error_handling.h"
|
||||
#include "rcl/rcl.h"
|
||||
|
||||
#include "rcutils/logging_macros.h"
|
||||
|
||||
#include "rcl_lifecycle/rcl_lifecycle.h"
|
||||
|
||||
#include "../src/default_state_machine.h"
|
||||
|
||||
class TestDefaultStateMachine : public ::testing::Test
|
||||
|
@ -226,7 +228,7 @@ TEST_F(TestDefaultStateMachine, wrong_default_sequence) {
|
|||
*it == lifecycle_msgs__msg__Transition__TRANSITION_ACTIVATE ||
|
||||
*it == lifecycle_msgs__msg__Transition__TRANSITION_SHUTDOWN) {continue;}
|
||||
|
||||
fprintf(stderr, "applying key %u\n", *it);
|
||||
RCUTILS_LOG_INFO("applying key %u", *it)
|
||||
EXPECT_EQ(
|
||||
RCL_RET_ERROR, rcl_lifecycle_trigger_transition(&state_machine, *it, false));
|
||||
rcl_reset_error();
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
// as depicted in design.ros2.org
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <lifecycle_msgs/msg/state.h>
|
||||
#include <lifecycle_msgs/msg/transition.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "lifecycle_msgs/msg/state.h"
|
||||
#include "lifecycle_msgs/msg/transition.h"
|
||||
|
||||
#include "rcl/error_handling.h"
|
||||
#include "rcl/rcl.h"
|
||||
|
||||
#include "rcl_lifecycle/rcl_lifecycle.h"
|
||||
|
||||
#include "../src/default_state_machine.h"
|
||||
|
||||
class TestMultipleInstances : public ::testing::Test
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rcl/error_handling.h"
|
||||
|
||||
#include "rcl_lifecycle/transition_map.h"
|
||||
|
||||
class TestTransitionMap : public ::testing::Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue