GetSimulationStateServiceHandler.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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 "GetSimulationStateServiceHandler.h"
  9. #include <SimulationInterfaces/SimulationMangerRequestBus.h>
  10. #include <simulation_interfaces/msg/result.hpp>
  11. #include <simulation_interfaces/msg/simulation_state.hpp>
  12. namespace ROS2SimulationInterfaces
  13. {
  14. AZStd::unordered_set<SimulationFeatureType> GetSimulationStateServiceHandler::GetProvidedFeatures()
  15. {
  16. return AZStd::unordered_set<SimulationFeatureType>{ SimulationFeatures::SIMULATION_STATE_GETTING };
  17. }
  18. AZStd::optional<GetSimulationStateServiceHandler::Response> GetSimulationStateServiceHandler::HandleServiceRequest(
  19. const std::shared_ptr<rmw_request_id_t> header, const Request& request)
  20. {
  21. Response response;
  22. SimulationInterfaces::SimulationState currentState;
  23. SimulationInterfaces::SimulationManagerRequestBus::BroadcastResult(
  24. currentState, &SimulationInterfaces::SimulationManagerRequests::GetSimulationState);
  25. response.result.result = simulation_interfaces::msg::Result::RESULT_OK;
  26. response.state.state = currentState;
  27. return response;
  28. }
  29. } // namespace ROS2SimulationInterfaces