-
Notifications
You must be signed in to change notification settings - Fork 412
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
Changes from 7 commits
29de414
d4a222f
c00a06d
649b51a
8d3d0e2
5348132
78e5e4f
893dbd7
a7de819
b47812a
14ebc70
bd22955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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_ |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might need a virtual destructor to make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
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_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2017 Open Source Robotics Foundation, Inc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2018? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could probably still be fixed |
||
// | ||
// 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() | ||
{} |
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.
The destructor is conventionally at the top of the class just after any constructors.