Add debug logging (#187)

* use ROS_PACKAGE_NAME in debug msgs

* rcl_lifecycle too

* Swap unnamed macros to named

* Remove semicolon

* Add debug logging

* Timer debug logging

* Wait debug

* A bit less wait debug...

* Clearer time output

* Remove the wait sublogger

* Use conditional logging instead of the else{}

* Add 'X finalized' msg

* Add send_response logging

* Remove extra semicolons

* Add publish/take messages

* [style nitpick] formatted variables on the next line
This commit is contained in:
dhood 2017-11-21 17:23:50 -08:00 committed by GitHub
parent 9f92f8fa37
commit 7d0045adb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 186 additions and 73 deletions

View file

@ -228,19 +228,20 @@ rcl_lifecycle_com_interface_init(
fail:
if (RCL_RET_OK != rcl_publisher_fini(&com_interface->pub_transition_event, node_handle)) {
RCUTILS_LOG_ERROR("Failed to destroy transition_event publisher")
RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME, "Failed to destroy transition_event publisher")
}
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_change_state, node_handle)) {
RCUTILS_LOG_ERROR("Failed to destroy change_state service")
RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME, "Failed to destroy change_state service")
}
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_state, node_handle)) {
RCUTILS_LOG_ERROR("Failed to destroy get_state service")
RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME, "Failed to destroy get_state service")
}
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_available_states, node_handle)) {
RCUTILS_LOG_ERROR("Failed to destroy get_available_states service")
RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME, "Failed to destroy get_available_states service")
}
if (RCL_RET_OK != rcl_service_fini(&com_interface->srv_get_available_transitions, node_handle)) {
RCUTILS_LOG_ERROR("Failed to destroy get_available_transitions service")
RCUTILS_LOG_ERROR_NAMED(
ROS_PACKAGE_NAME, "Failed to destroy get_available_transitions service")
}
if (topic_name) {

View file

@ -152,7 +152,7 @@ rcl_lifecycle_is_valid_transition(
}
}
RCUTILS_LOG_WARN_NAMED(
"rcl_lifecycle",
ROS_PACKAGE_NAME,
"No callback transition matching %d found for current state %s",
key, state_machine->current_state->label)
return NULL;
@ -169,7 +169,7 @@ rcl_lifecycle_trigger_transition(
// If we have a faulty transition pointer
if (!transition) {
RCUTILS_LOG_ERROR_NAMED(
"rcl_lifecycle",
ROS_PACKAGE_NAME,
"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());
@ -178,7 +178,7 @@ rcl_lifecycle_trigger_transition(
if (!transition->goal) {
RCUTILS_LOG_ERROR_NAMED(
"rcl_lifecycle", "No valid goal is set")
ROS_PACKAGE_NAME, "No valid goal is set")
}
state_machine->current_state = transition->goal;
if (publish_notification) {
@ -200,13 +200,15 @@ rcl_print_state_machine(const rcl_lifecycle_state_machine_t * state_machine)
const rcl_lifecycle_transition_map_t * map = &state_machine->transition_map;
for (size_t i = 0; i < map->states_size; ++i) {
RCUTILS_LOG_INFO_NAMED(
"rcl_lifecycle",
ROS_PACKAGE_NAME,
"Primary State: %s(%u)\n# of valid transitions: %u",
map->states[i].label, map->states[i].id,
map->states[i].valid_transition_size
)
for (size_t j = 0; j < map->states[i].valid_transition_size; ++j) {
RCUTILS_LOG_INFO("\tNode %s: Key %d: Transition: %s",
RCUTILS_LOG_INFO_NAMED(
ROS_PACKAGE_NAME,
"\tNode %s: Key %d: Transition: %s",
map->states[i].label,
map->states[i].valid_transition_keys[j],
map->states[i].valid_transitions[j].label)

View file

@ -229,7 +229,7 @@ TEST_F(TestDefaultStateMachine, wrong_default_sequence) {
*it == lifecycle_msgs__msg__Transition__TRANSITION_ACTIVATE ||
*it == lifecycle_msgs__msg__Transition__TRANSITION_SHUTDOWN) {continue;}
RCUTILS_LOG_INFO("applying key %u", *it)
RCUTILS_LOG_INFO_NAMED(ROS_PACKAGE_NAME, "applying key %u", *it)
EXPECT_EQ(
RCL_RET_ERROR, rcl_lifecycle_trigger_transition(&state_machine, *it, false));
rcl_reset_error();