ApplePickerComponent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #pragma once
  9. #include "ApplePickingNotifications.h"
  10. #include "ApplePickingRequests.h"
  11. #include <AzCore/Component/Component.h>
  12. // #include <vision_msgs/msgs/detection_3d_array.h>
  13. namespace AppleKraken
  14. {
  15. //! Demo component handling orchestration of apple picking
  16. class ApplePickerComponent
  17. : public AZ::Component
  18. , private ApplePickingNotificationBus::Handler // Probably could use TickBus as well for timeouts
  19. {
  20. public:
  21. AZ_COMPONENT(ApplePickerComponent, "{E9E83A4A-31A4-4E7A-AF88-7565AC8B9F27}", AZ::Component);
  22. ApplePickerComponent() = default;
  23. void Activate() override;
  24. void Deactivate() override;
  25. static void Reflect(AZ::ReflectContext* context);
  26. //! Detect and pick all apples in manipulator range.
  27. void StartAutomatedOperation();
  28. //! Report overall progress of gathering task.
  29. //! @returns how much of the task is complete (0: nothing, 1: all of it). The task is completed when all reachable apples are
  30. //! gathered (or had a failure) and the effector is in IDLE state.
  31. float ReportProgress();
  32. private:
  33. void ApplePicked() override;
  34. void AppleRetrieved() override;
  35. void PickingFailed(const AZStd::string& reason) override;
  36. AZ::Obb m_gatheringArea;
  37. AZStd::queue<PickAppleTask> m_currentAppleTasks; //! Populated in StartAutomatedOperation. Tasks are popped when completed or failed.
  38. };
  39. } // namespace AppleKraken