-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve startup race condition for sim time #608
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
29de414
Separate the Node Time Source from the Node Clock
tfoote d4a222f
Implement initial value checking of use_sim_time parameter parameter
tfoote c00a06d
Be sure to update all newly attached clocks
tfoote 649b51a
linter cleanup
tfoote 8d3d0e2
add unit tests to cover either attachment order
tfoote 5348132
resolve comment and stricter clang string management
tfoote 78e5e4f
Update rclcpp/include/rclcpp/node_interfaces/node_time_source.hpp
wjwwood 893dbd7
Update rclcpp/include/rclcpp/node_interfaces/node_time_source_interfa…
wjwwood a7de819
Add virtual destructors to interface classes
tfoote b47812a
Merge branch 'separate_time_source' of github.com:ros2/rclcpp into se…
tfoote 14ebc70
move destructors to top of class (#611)
wjwwood bd22955
2018 copyright
tfoote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
72 changes: 72 additions & 0 deletions
72
rclcpp/include/rclcpp/node_interfaces/node_time_source.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2018 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__NODE_INTERFACES__NODE_TIME_SOURCE_HPP_ | ||
#define RCLCPP__NODE_INTERFACES__NODE_TIME_SOURCE_HPP_ | ||
|
||
#include "rclcpp/callback_group.hpp" | ||
#include "rclcpp/clock.hpp" | ||
#include "rclcpp/macros.hpp" | ||
#include "rclcpp/node_interfaces/node_base_interface.hpp" | ||
#include "rclcpp/node_interfaces/node_clock_interface.hpp" | ||
#include "rclcpp/node_interfaces/node_parameters_interface.hpp" | ||
#include "rclcpp/node_interfaces/node_time_source_interface.hpp" | ||
#include "rclcpp/node_interfaces/node_topics_interface.hpp" | ||
#include "rclcpp/time_source.hpp" | ||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace node_interfaces | ||
{ | ||
|
||
/// Implementation of the NodeTimeSource part of the Node API. | ||
class NodeTimeSource : public NodeTimeSourceInterface | ||
{ | ||
public: | ||
RCLCPP_SMART_PTR_ALIASES_ONLY(NodeTimeSource) | ||
|
||
RCLCPP_PUBLIC | ||
explicit NodeTimeSource( | ||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base, | ||
rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics, | ||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph, | ||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services, | ||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging, | ||
rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock, | ||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters | ||
); | ||
|
||
RCLCPP_PUBLIC | ||
virtual | ||
~NodeTimeSource(); | ||
|
||
private: | ||
RCLCPP_DISABLE_COPY(NodeTimeSource) | ||
|
||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_; | ||
rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_; | ||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_; | ||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_; | ||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_; | ||
rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_; | ||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters_; | ||
|
||
rclcpp::TimeSource time_source_; | ||
}; | ||
|
||
} // namespace node_interfaces | ||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__NODE_INTERFACES__NODE_TIME_SOURCE_HPP_ |
42 changes: 42 additions & 0 deletions
42
rclcpp/include/rclcpp/node_interfaces/node_time_source_interface.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2018 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__NODE_INTERFACES__NODE_TIME_SOURCE_INTERFACE_HPP_ | ||
#define RCLCPP__NODE_INTERFACES__NODE_TIME_SOURCE_INTERFACE_HPP_ | ||
|
||
#include "rclcpp/callback_group.hpp" | ||
#include "rclcpp/clock.hpp" | ||
#include "rclcpp/macros.hpp" | ||
#include "rclcpp/visibility_control.hpp" | ||
|
||
namespace rclcpp | ||
{ | ||
namespace node_interfaces | ||
{ | ||
|
||
/// Pure virtual interface class for the NodeTimeSource part of the Node API. | ||
class NodeTimeSourceInterface | ||
{ | ||
public: | ||
RCLCPP_SMART_PTR_ALIASES_ONLY(NodeTimeSourceInterface) | ||
|
||
RCLCPP_PUBLIC | ||
virtual | ||
~NodeTimeSourceInterface() = default; | ||
}; | ||
|
||
} // namespace node_interfaces | ||
} // namespace rclcpp | ||
|
||
#endif // RCLCPP__NODE_INTERFACES__NODE_TIME_SOURCE_INTERFACE_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
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,50 @@ | ||
// Copyright 2018 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 "rclcpp/node_interfaces/node_time_source.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
using rclcpp::node_interfaces::NodeTimeSource; | ||
|
||
NodeTimeSource::NodeTimeSource( | ||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base, | ||
rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics, | ||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph, | ||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services, | ||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging, | ||
rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock, | ||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters) | ||
: node_base_(node_base), | ||
node_topics_(node_topics), | ||
node_graph_(node_graph), | ||
node_services_(node_services), | ||
node_logging_(node_logging), | ||
node_clock_(node_clock), | ||
node_parameters_(node_parameters) | ||
{ | ||
time_source_.attachNode( | ||
node_base_, | ||
node_topics_, | ||
node_graph_, | ||
node_services_, | ||
node_logging_, | ||
node_clock_, | ||
node_parameters_); | ||
time_source_.attachClock(node_clock_->get_clock()); | ||
} | ||
|
||
NodeTimeSource::~NodeTimeSource() | ||
{} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might need a virtual destructor to make sure
~NodeTimeSource()
gets called when thestd::shared_ptr<NodeTimeSourceInterface>
on the node is destructed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is probably true as well for all the other interface classes too. I went over it with @wjwwood and it looks like virtual default constructors are the best approch. We're clearly not using it right now but in the future not having them will cause warnings or errors.