ROS2TimeSource.cpp 833 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "ROS2TimeSource.h"
  9. #include <ROS2/ROS2Bus.h>
  10. namespace ROS2
  11. {
  12. builtin_interfaces::msg::Time ROS2TimeSource::GetROSTimestamp() const
  13. {
  14. auto ros2Node = ROS2Interface::Get()->GetNode();
  15. AZ_Assert(ros2Node, "No ROS 2 node");
  16. builtin_interfaces::msg::Time timeStamp = ros2Node->get_clock()->now();
  17. return timeStamp;
  18. }
  19. AZ::Outcome<void, AZStd::string> ROS2TimeSource::AdjustTime(const builtin_interfaces::msg::Time& time)
  20. {
  21. return AZ::Failure(AZStd::string("ROS2TimeSource does not support setting a specific time."));
  22. }
  23. } // namespace ROS2