12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <AzCore/Serialization/SerializeContext.h>
- #include <AzCore/std/numeric.h>
- #include <ROS2/ROS2Bus.h>
- #include <ROS2/Sensor/Events/TickBasedSource.h>
- #include <ROS2/Utilities/ROS2Conversions.h>
- namespace ROS2
- {
- void TickBasedSource::Reflect(AZ::ReflectContext* context)
- {
- if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<TickBasedSource>()->Version(1);
- }
- }
- void TickBasedSource::Start()
- {
- AZ::TickBus::Handler::BusConnect();
- }
- void TickBasedSource::Stop()
- {
- AZ::TickBus::Handler::BusDisconnect();
- }
- float TickBasedSource::GetDeltaTime(float deltaTime) const
- {
- return deltaTime;
- }
- void TickBasedSource::OnTick(float deltaTime, AZ::ScriptTimePoint time)
- {
- AZ_UNUSED(time);
- AZ_UNUSED(deltaTime);
- const auto expectedSimulationLoopTime = ROS2Interface::Get()->GetExpectedSimulationLoopTime();
- m_sourceEvent.Signal(expectedSimulationLoopTime);
- }
- } // namespace ROS2
|