Skip to main content

MotionApprovalPromptSlot Class

The one place an operator's motion-approval answer is delivered, and the claim that keeps two motions from waiting on it at once. More...

Declaration​

class moveit_pro::behaviors::MotionApprovalPromptSlot { ... }

Included Headers​

#include <motion_approval_prompt_slot.hpp>

Public Member Typedefs Index​

usingAnswerCell = std::shared_ptr< std::atomic< Answer > >

Enumerations Index​

enum classAnswer { ... }

What the operator said, or that they have not said anything yet. More...

enum classDelivery { ... }

What became of an answer. Each refusal needs different words to the operator, so they stay distinct. More...

Public Member Functions Index​

AnswerCelltryClaim (std::string preview_id)

Claim the slot for a new prompt. More...

Deliveryanswer (std::string_view preview_id, bool approved)

Deliver the operator's answer to the prompt it names. More...

Private Member Attributes Index​

std::mutexmutex_
std::weak_ptr< std::atomic< Answer > >waiting_
std::stringwaiting_preview_id_

Description​

The one place an operator's motion-approval answer is delivered, and the claim that keeps two motions from waiting on it at once.

The answer arrives on a service advertised for the life of the Runtime, while the prompt that wants it is created and destroyed per motion. Rather than let the service callback reach into the prompt — where it would race the prompt's destruction — the prompt takes a shared answer cell from here and the callback only ever writes to that cell. The cell outlives whichever of the two lets go first, so a late answer lands somewhere harmless instead of on freed memory.

Holding the cell is the claim: it is released when the prompt drops it, including by a throw partway through construction, so there is no path that wedges the gate for the rest of the process.

Every answer names the prompt it is for, so an answer that outlives its own prompt is refused rather than applied to whichever motion happens to be waiting when it arrives.

Definition at line 33 of file motion_approval_prompt_slot.hpp.

Public Member Typedefs​

AnswerCell​

using moveit_pro::behaviors::MotionApprovalPromptSlot::AnswerCell = std::shared_ptr<std::atomic<Answer> >

Definition at line 53 of file motion_approval_prompt_slot.hpp.

Enumerations​

Answer​

enum class moveit_pro::behaviors::MotionApprovalPromptSlot::Answer
strong

What the operator said, or that they have not said anything yet.

Enumeration values
kWaiting
kApproved
kDeclined

Definition at line 37 of file motion_approval_prompt_slot.hpp.

Delivery​

enum class moveit_pro::behaviors::MotionApprovalPromptSlot::Delivery
strong

What became of an answer. Each refusal needs different words to the operator, so they stay distinct.

Enumeration values
kDelivered
kNothingWaiting
kAnotherPrompt
kAlreadyAnswered

Definition at line 45 of file motion_approval_prompt_slot.hpp.

Public Member Functions​

answer()​

MotionApprovalPromptSlot::Delivery moveit_pro::behaviors::MotionApprovalPromptSlot::answer (std::string_view preview_id, bool approved)

Deliver the operator's answer to the prompt it names.

Parameters
preview_id

The prompt being answered, as carried by the preview the operator was shown.

approved

What the operator decided.

Declaration at line 69 of file motion_approval_prompt_slot.hpp, definition at line 27 of file motion_approval_prompt_slot.cpp.

tryClaim()​

MotionApprovalPromptSlot::AnswerCell moveit_pro::behaviors::MotionApprovalPromptSlot::tryClaim (std::string preview_id)

Claim the slot for a new prompt.

Parameters
preview_id

Identity the answer must name to be accepted. The gate stamps it on the previewed Solution, so the operator's app can echo it back.

Returns

The cell to poll, or nullptr when another prompt already holds the slot. Keep the cell alive for as long as the prompt waits; dropping it releases the claim.

Declaration at line 62 of file motion_approval_prompt_slot.hpp, definition at line 14 of file motion_approval_prompt_slot.cpp.

Private Member Attributes​

mutex_​

std::mutex moveit_pro::behaviors::MotionApprovalPromptSlot::mutex_

Definition at line 72 of file motion_approval_prompt_slot.hpp.

waiting_​

std::weak_ptr<std::atomic<Answer> > moveit_pro::behaviors::MotionApprovalPromptSlot::waiting_

Definition at line 74 of file motion_approval_prompt_slot.hpp.

waiting_preview_id_​

std::string moveit_pro::behaviors::MotionApprovalPromptSlot::waiting_preview_id_

Definition at line 76 of file motion_approval_prompt_slot.hpp.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.