-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConditionWaitReturnCode for spin_until_complete
Signed-off-by: Christophe Bedard <[email protected]>
- Loading branch information
1 parent
36d56c5
commit 0fb8046
Showing
8 changed files
with
121 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2014 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCLCPP__CONDITION_WAIT_RETURN_CODE_HPP_ | ||
#define RCLCPP__CONDITION_WAIT_RETURN_CODE_HPP_ | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
|
||
/// Return codes to be used with spin_until_complete. | ||
/** | ||
* SUCCESS: The condition wait is complete. This does not indicate that the operation succeeded. | ||
* INTERRUPTED: The condition wait is not complete, spinning was interrupted by Ctrl-C or another | ||
* error. | ||
* TIMEOUT: Spinning timed out. | ||
*/ | ||
enum class ConditionWaitReturnCode {SUCCESS, INTERRUPTED, TIMEOUT}; | ||
|
||
/// Stream operator for ConditionWaitReturnCode. | ||
RCLCPP_PUBLIC | ||
std::ostream & | ||
operator<<(std::ostream & os, const ConditionWaitReturnCode & condition_wait_return_code); | ||
|
||
/// String conversion function for ConditionWaitReturnCode. | ||
RCLCPP_PUBLIC | ||
std::string | ||
to_string(const ConditionWaitReturnCode & condition_wait_return_code); | ||
|
||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__CONDITION_WAIT_RETURN_CODE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <sstream> | ||
#include <string> | ||
|
||
#include "rclcpp/condition_wait_return_code.hpp" | ||
|
||
TEST(TestConditionWaitReturnCode, to_string) { | ||
EXPECT_EQ( | ||
"Unknown enum value (-1)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode(-1))); | ||
EXPECT_EQ( | ||
"SUCCESS (0)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode::SUCCESS)); | ||
EXPECT_EQ( | ||
"INTERRUPTED (1)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode::INTERRUPTED)); | ||
EXPECT_EQ( | ||
"TIMEOUT (2)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode::TIMEOUT)); | ||
EXPECT_EQ( | ||
"Unknown enum value (3)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode(3))); | ||
EXPECT_EQ( | ||
"Unknown enum value (100)", rclcpp::to_string(rclcpp::ConditionWaitReturnCode(100))); | ||
} | ||
|
||
TEST(TestConditionWaitReturnCode, ostream) { | ||
std::ostringstream ostream; | ||
|
||
ostream << rclcpp::ConditionWaitReturnCode::SUCCESS; | ||
ASSERT_EQ("SUCCESS (0)", ostream.str()); | ||
} |