Warn unused (#327)
* comply with unused warnings * fix flakiness and add test for transitions * mark flaky test * duplicate const char * in State constructor * linters * correct year in license * mark flaky test
This commit is contained in:
parent
5777bbee79
commit
708903e5df
5 changed files with 118 additions and 16 deletions
|
@ -63,9 +63,15 @@ public:
|
|||
if (rcl_lifecycle_state_machine_is_initialized(&state_machine_) != RCL_RET_OK) {
|
||||
fprintf(stderr, "%s:%u, FATAL: rcl_state_machine got destroyed externally.\n",
|
||||
__FILE__, __LINE__);
|
||||
// TODO(karsten1987): Remove else. It should always be possible to call
|
||||
// fini on state machine, also when not initialized
|
||||
} else {
|
||||
rcl_lifecycle_state_machine_fini(&state_machine_,
|
||||
node_base_interface_->get_rcl_node_handle());
|
||||
if (rcl_lifecycle_state_machine_fini(&state_machine_,
|
||||
node_base_interface_->get_rcl_node_handle()) != RCL_RET_OK)
|
||||
{
|
||||
fprintf(stderr, "%s:%u, FATAL: failed to destroy rcl_state_machine.\n",
|
||||
__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,16 +310,20 @@ public:
|
|||
rcl_lifecycle_ret_t error_resolved = execute_callback(state_machine_.current_state->id,
|
||||
initial_state);
|
||||
if (error_resolved == RCL_RET_OK) {
|
||||
fprintf(stderr, "Exception handling was successful\n");
|
||||
// fprintf(stderr, "Exception handling was successful\n");
|
||||
// We call cleanup on the error state
|
||||
rcl_lifecycle_trigger_transition(
|
||||
&state_machine_, error_resolved, true);
|
||||
fprintf(stderr, "current state after error callback%s\n",
|
||||
state_machine_.current_state->label);
|
||||
if (rcl_lifecycle_trigger_transition(&state_machine_, error_resolved, true) != RCL_RET_OK) {
|
||||
fprintf(stderr, "Failed to call cleanup on error state\n");
|
||||
return false;
|
||||
}
|
||||
// fprintf(stderr, "current state after error callback%s\n",
|
||||
// state_machine_.current_state->label);
|
||||
} else {
|
||||
// We call shutdown on the error state
|
||||
rcl_lifecycle_trigger_transition(
|
||||
&state_machine_, error_resolved, true);
|
||||
if (rcl_lifecycle_trigger_transition(&state_machine_, error_resolved, true) != RCL_RET_OK) {
|
||||
fprintf(stderr, "Failed to call cleanup on error state\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// This true holds in both cases where the actual callback
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "rclcpp_lifecycle/state.hpp"
|
||||
|
||||
#include <lifecycle_msgs/msg/state.hpp>
|
||||
|
||||
#include <rcutils/allocator.h>
|
||||
#include <rcutils/strdup.h>
|
||||
#include <rcl_lifecycle/data_types.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -35,7 +38,8 @@ State::State(uint8_t id, const std::string & label)
|
|||
|
||||
auto state_handle = new rcl_lifecycle_state_t;
|
||||
state_handle->id = id;
|
||||
state_handle->label = label.c_str();
|
||||
state_handle->label =
|
||||
rcutils_strndup(label.c_str(), label.size(), rcutils_get_default_allocator());
|
||||
|
||||
state_handle_ = state_handle;
|
||||
}
|
||||
|
@ -56,12 +60,18 @@ State::~State()
|
|||
uint8_t
|
||||
State::id() const
|
||||
{
|
||||
if (!state_handle_) {
|
||||
throw std::runtime_error("Error in state! Internal state_handle is NULL.");
|
||||
}
|
||||
return state_handle_->id;
|
||||
}
|
||||
|
||||
std::string
|
||||
State::label() const
|
||||
{
|
||||
if (!state_handle_) {
|
||||
throw std::runtime_error("Error in state! Internal state_handle is NULL.");
|
||||
}
|
||||
return state_handle_->label;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,17 +90,13 @@ Transition::label() const
|
|||
State
|
||||
Transition::start_state() const
|
||||
{
|
||||
return State(
|
||||
transition_handle_->start->id,
|
||||
transition_handle_->start->label);
|
||||
return State(transition_handle_->start);
|
||||
}
|
||||
|
||||
State
|
||||
Transition::goal_state() const
|
||||
{
|
||||
return State(
|
||||
transition_handle_->goal->id,
|
||||
transition_handle_->goal->label);
|
||||
return State(transition_handle_->goal);
|
||||
}
|
||||
|
||||
} // namespace rclcpp_lifecycle
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue