ROS2TimeSource.cpp 798 B

1234567891011121314151617181920212223242526
  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 <ROS2/Clock/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. builtin_interfaces::msg::Time timeStamp = ros2Node->get_clock()->now();
  16. return timeStamp;
  17. }
  18. AZ::Outcome<void, AZStd::string> ROS2TimeSource::AdjustTime(const builtin_interfaces::msg::Time& time)
  19. {
  20. return AZ::Failure(AZStd::string("ROS2TimeSource does not support setting a specific time."));
  21. }
  22. } // namespace ROS2