예제 #1
0
        /**
         * \brief Resends this goal [with the same GoalID] to the ActionServer
         *
         * Useful if the user thinks that the goal may have gotten lost in transit
         */
        public void resend()
        {
            if (!isActive)
            {
                ROS.Error("actionlib", "Trying to resend() on an inactive ClientGoalHandle. You are incorrectly using a ClientGoalHandle");
            }

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this resend() call");
                return;
            }

            UnityEngine.Debug.Assert(goalManager != null);
            AActionGoal actionGoal = null;

            lock ( lockObject )
            {
                actionGoal = listHandle.GetElement().getActionGoal();
//				actionGoal = listHandle.getElem()->getActionGoal();
            }

            if (actionGoal == null)
            {
                ROS.Error("actionlib", "BUG: Got a NULL actionGoal");
            }

            if (goalManager.sendGoalDelegate != null)
            {
                goalManager.sendGoalDelegate(actionGoal);
            }
        }
예제 #2
0
        /**
         * \brief Sends a cancel message for this specific goal to the ActionServer
         *
         * Also transitions the Communication State Machine to WAITING_FOR_CANCEL_ACK
         */
        public void cancel()
        {
            if (!isActive)
            {
                ROS.Error("actionlib", "Trying to cancel() on an inactive ClientGoalHandle. You are incorrectly using a ClientGoalHandle");
                return;
            }

            UnityEngine.Debug.Assert(goalManager != null);

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this call");
                return;
            }

            lock ( lockObject )
            {
                switch (listHandle.GetElement().getCommState().state)
                {
                case CommState.StateEnum.WAITING_FOR_GOAL_ACK:
                case CommState.StateEnum.PENDING:
                case CommState.StateEnum.ACTIVE:
                case CommState.StateEnum.WAITING_FOR_CANCEL_ACK:
                    break;                     // Continue standard processing

                case CommState.StateEnum.WAITING_FOR_RESULT:
                case CommState.StateEnum.RECALLING:
                case CommState.StateEnum.PREEMPTING:
                case CommState.StateEnum.DONE:
                    ROS.Debug("actionlib", "Got a cancel() request while in state [%s], so ignoring it", listHandle.GetElement().getCommState().toString());
                    return;

                default:
                    ROS.Error("actionlib", "BUG: Unhandled CommState: %u", listHandle.GetElement().getCommState().state);
                    return;
                }
            }

            AActionGoal actionGoal = listHandle.GetElement().getActionGoal();

            Messages.actionlib_msgs.GoalID cancelMsg = new Messages.actionlib_msgs.GoalID();
            cancelMsg.stamp = ROS.GetTime();
            cancelMsg.id    = listHandle.GetElement().getActionGoal().GoalID.id;
//			cancelMsg.id = listHandle.GetElement ().getActionGoal ()->goal_id.id;

            if (goalManager.cancelDelegate != null)
            {
                goalManager.cancelDelegate(cancelMsg);
            }

            listHandle.GetElement().transitionToState(this, CommState.StateEnum.WAITING_FOR_CANCEL_ACK);
        }
예제 #3
0
        public void listElemDeleter(List <CommStateMachine <ActionSpec> > .Enumerator it)
        {
            UnityEngine.Debug.Assert(guard != null);
            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Not going to try delete the CommStateMachine associated with this goal");
                return;
            }

            ROS.Debug("actionlib", "About to erase CommStateMachine");
            lock ( lockObject )
            {
                list.Remove(it.Current);
            }
            ROS.Debug("actionlib", "Done erasing CommStateMachine");
        }
예제 #4
0
        /**
         * \brief Stops goal handle from tracking a goal
         *
         * Useful if you want to stop tracking the progress of a goal, but it is inconvenient to force
         * the goal handle to go out of scope. Has pretty much the same semantics as boost::shared_ptr::reset()
         */
        public void reset()
        {
            if (isActive)
            {
                DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
                if (!protector.isProtected())
                {
                    ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this reset() call");
                    return;
                }

                lock ( lockObject )
                {
//					listHandle.reset(); // not sure what to replace this stuff with
                    isActive    = false;
                    goalManager = null;
                }
            }
        }
예제 #5
0
        /**
         * \brief Check if two goal handles point to the same goal
         * \return TRUE if both point to the same goal. Also returns TRUE if both handles are inactive.
         */
        public static bool operator ==(ClientGoalHandle <ActionSpec> lhs, ClientGoalHandle <ActionSpec> rhs)
        {
            if (object.ReferenceEquals(lhs, rhs))
            {
                return(true);
            }
            if (!(lhs.isActive && rhs.isActive))
            {
                return(false);
            }

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(lhs.guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this operator==() call");
                return(false);
            }

            return(lhs.listHandle == rhs.listHandle);
        }
예제 #6
0
        /**
         * \brief Get result associated with this goal
         *
         * \return NULL if no reseult received.  Otherwise returns shared_ptr to result.
         */
        public AResult getResult()
//		public AActionResult getResult ()
        {
            if (!isActive)
            {
                ROS.Error("actionlib", "Trying to getResult on an inactive ClientGoalHandle. You are incorrectly using a ClientGoalHandle");
            }
            UnityEngine.Debug.Assert(goalManager != null);

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this getResult() call");
                return(null);
//				return typename ClientGoalHandle<ActionSpec>::ResultConstPtr() ;
            }

            lock ( lockObject )
            {
                return(listHandle.GetElement().getResult());
//				return listHandle.GetElement ().getResult<TResult> ();
            }
        }
예제 #7
0
        /**
         * \brief Get the state of this goal's communication state machine from interaction with the server
         *
         * Possible States are: WAITING_FOR_GOAL_ACK, PENDING, ACTIVE, WAITING_FOR_RESULT,
         *                      WAITING_FOR_CANCEL_ACK, RECALLING, PREEMPTING, DONE
         * \return The current goal's communication state with the server
         */
        public CommState getCommState()
        {
            if (!isActive)
            {
                ROS.Error("actionlib", "Trying to getCommState on an inactive ClientGoalHandle. You are incorrectly using a ClientGoalHandle");
                return(new CommState(CommState.StateEnum.DONE));
            }

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this getCommState() call");
                return(new CommState(CommState.StateEnum.DONE));
            }

            UnityEngine.Debug.Assert(goalManager != null);

            lock ( lockObject )
            {
                return(listHandle.GetElement().getCommState());
//				return listHandle.getElem()->getCommState(); // ??
            }
        }
예제 #8
0
        /**
         * \brief Get the terminal state information for this goal
         *
         * Possible States Are: RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST
         * This call only makes sense if CommState==DONE. This will send ROS_WARNs if we're not in DONE
         * \return The terminal state
         */
        public TerminalState getTerminalState()
        {
            if (!isActive)
            {
                ROS.Error("actionlib", "Trying to getTerminalState on an inactive ClientGoalHandle. You are incorrectly using a ClientGoalHandle");
                return(new TerminalState(TerminalState.StateEnum.LOST));
            }

            DestructionGuard.ScopedProtector protector = new DestructionGuard.ScopedProtector(guard);
            if (!protector.isProtected())
            {
                ROS.Error("actionlib", "This action client associated with the goal handle has already been destructed. Ignoring this getTerminalState() call");
                return(new TerminalState(TerminalState.StateEnum.LOST));
            }

            UnityEngine.Debug.Assert(goalManager != null);
            lock ( lockObject )
            {
                CommState comm_state = listHandle.GetElement().getCommState();
//				CommState comm_state = listHandle.getElem()->getCommState();
                if (comm_state != CommState.StateEnum.DONE)
                {
                    ROS.Warn("actionlib", "Asking for the terminal state when we're in [%s]", comm_state.toString());
                }

                Messages.actionlib_msgs.GoalStatus goal_status = listHandle.GetElement().getGoalStatus();
//				Messages.actionlib_msgs.GoalStatus goal_status = listHandle.getElem()->getGoalStatus();

                switch (goal_status.status)
                {
                case gstat.PENDING:
                case gstat.ACTIVE:
                case gstat.PREEMPTING:
                case gstat.RECALLING:
                    ROS.Error("actionlib", "Asking for terminal state, but latest goal status is %u", goal_status.status);
                    return(new TerminalState(TerminalState.StateEnum.LOST, goal_status.text));

                case gstat.PREEMPTED:
                    return(new TerminalState(TerminalState.StateEnum.PREEMPTED, goal_status.text));

                case gstat.SUCCEEDED:
                    return(new TerminalState(TerminalState.StateEnum.SUCCEEDED, goal_status.text));

                case gstat.ABORTED:
                    return(new TerminalState(TerminalState.StateEnum.ABORTED, goal_status.text));

                case gstat.REJECTED:
                    return(new TerminalState(TerminalState.StateEnum.REJECTED, goal_status.text));

                case gstat.RECALLED:
                    return(new TerminalState(TerminalState.StateEnum.RECALLED, goal_status.text));

                case gstat.LOST:
                    return(new TerminalState(TerminalState.StateEnum.LOST, goal_status.text));

                default:
                    ROS.Error("actionlib", "Unknown goal status: %u", goal_status.status);
                    break;
                }

                ROS.Error("actionlib", "Bug in determining terminal state");
                return(new TerminalState(TerminalState.StateEnum.LOST, goal_status.text));
            }
        }