/** * \brief Store a GoalStatus in a ClientGoalStatus * Note that the only GoalStatuses that can be converted into a * ClientGoalStatus are {PREEMPTED, SUCCEEDED, ABORTED, REJECTED} * \param goal_status The GoalStatus msg that we want to convert */ public void fromGoalStatus(GoalStatus goal_status) { switch (goal_status.status) { case GoalStatus.PREEMPTED: state_ = StateEnum.PREEMPTED; break; case GoalStatus.SUCCEEDED: state_ = StateEnum.SUCCEEDED; break; case GoalStatus.ABORTED: state_ = StateEnum.ABORTED; break; case GoalStatus.REJECTED: state_ = StateEnum.REJECTED; break; default: state_ = StateEnum.LOST; ROS.Error("actionlib", "Cannot convert GoalStatus %u to ClientGoalState", goal_status.status); break; } }
public void Activate() { GoalStatus = GoalStatus.Active; // Give entity the behaviour needed to traverse through nodes ME.SB = new ArriveBehaviour(ME, Target, SteeringBehaviour.Deceleration.Fast); }
/// <summary> /// Processes subgoals /// </summary> /// <returns></returns> public GoalStatus ProcessSubGoals() { //remove all completed and failed goals from the front of the subgoal list while (SubGoals.Count != 0 && (SubGoals[0].IsComplete || SubGoals[0].HasFailed)) { SubGoals[0].Terminate(); // SubGoals[0] = null; SubGoals.RemoveAt(0); } //if any subgoals remain, process the one at the front of the list if (SubGoals.Count != 0) { //grab the status of the frontmost subgoal SubGoals[0].Process(); GoalStatus goalStatus = SubGoals[0].GoalStatusP; //we have to test for the special case where the frontmost subgoal //reports "completed" and the subgoal list contains additional goals. //When this is the case, to ensure the parent keeps processing its //subgoal list,the "active" status is returned if (goalStatus == GoalStatus.Completed && SubGoals.Count > 1) { return(GoalStatus.Active); } return(goalStatus); } //no more subgoals to process return "completed" else { return(GoalStatus.Completed); } }
private void CancelCallback(GoalID goalId) { if (!started) { return; } ROS.Debug()($"[{ThisNode.Name}] [actionlib] The action server has received a new cancel request"); if (goalId.id == null) { var timeZero = DateTime.UtcNow; foreach (var valuePair in goalHandles) { var goalHandle = valuePair.Value; if ((ROS.GetTime(goalId.stamp) == timeZero) || (ROS.GetTime(goalHandle.GoalId.stamp) < ROS.GetTime(goalId.stamp))) { if (goalHandle.SetCancelRequested() && (cancelCallback != null)) { cancelCallback(goalHandle); } } } } else { ServerGoalHandle <TGoal, TResult, TFeedback> goalHandle; var foundGoalHandle = goalHandles.TryGetValue(goalId.id, out goalHandle); if (foundGoalHandle) { if (goalHandle.SetCancelRequested() && (cancelCallback != null)) { cancelCallback(goalHandle); } } else { // We have not received the goal yet, prepare to cancel goal when it is received var goalStatus = new GoalStatus { status = GoalStatus.RECALLING }; goalHandle = new ServerGoalHandle <TGoal, TResult, TFeedback>(this, goalId, goalStatus, null) { DestructionTime = ROS.GetTime(goalId.stamp) }; //lock( lockGoalHandles ) //{ goalHandles[goalId.id] = goalHandle; //} } } // Make sure to set lastCancel based on the stamp associated with this cancel request if (ROS.GetTime(goalId.stamp) > lastCancel) { lastCancel = ROS.GetTime(goalId.stamp); } }
/// <summary> /// Sets the goal status to inactive if it is failed /// </summary> public void ReactivateIfFailed() { if (HasFailed) { Status = GoalStatus.Inactive; } }
public void ShouldInsertGoalIntoDatabaseUsingValuesProvided() { //Arrange int expectedId = 151; GoalStatus defaultCreateStatus = GoalStatus.Open; Goal knownGoal = new Goal(0, "Testing Goal A", null, 100, GoalStatus.Open, false); //Setup the repository mockGoalRepository.Setup (gr => gr.CreateGoalForUser(It.IsAny <int>(), It.Is <Goal>(goal => goal.Equals(knownGoal)))) .Returns <int, Goal>((userId, goal) => { Goal testGoal = new Goal(expectedId, goal.Name, goal.Description, goal.Target, defaultCreateStatus, goal.IsDefault); return(testGoal); }); IGoalService goalService = new GoalService(mockGoalRepository.Object); //Act Goal savedGoal = goalService.CreateGoal(1, knownGoal); //Assert savedGoal.Should().NotBeNull(); savedGoal.Id.Should().Be(expectedId); savedGoal.Name.Should().Be(knownGoal.Name); savedGoal.Description.Should().Be(knownGoal.Description); savedGoal.Target.Should().Be(knownGoal.Target); savedGoal.Status.Should().Be(defaultCreateStatus); savedGoal.IsDefault.Should().Be(knownGoal.IsDefault); }
public override byte[] Serialize(bool partofsomethingelse) { List <byte[]> pieces = new List <byte[]>(); if (Header == null) { Header = new std_msgs.Header(); } pieces.Add(Header.Serialize(true)); if (GoalStatus == null) { GoalStatus = new actionlib_msgs.GoalStatus(); } pieces.Add(GoalStatus.Serialize(true)); if (Content == null) { Content = new T(); } pieces.Add(Content.Serialize(true)); // combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
protected virtual GoalStatus ProcessSubgoals() { while (SubGoals.Count > 0) { Goal <T> firstgoal = SubGoals[0]; if (firstgoal.IsComplete || firstgoal.HasFailed) { firstgoal.Terminate(); SubGoals.Remove(firstgoal); } else { break; } } if (SubGoals.Count > 0) { GoalStatus status = SubGoals[0].Process(); if (status == GoalStatus.Complete && SubGoals.Count > 1) { return(GoalStatus.Active); } return(status); } else { return(GoalStatus.Complete); } }
private GoalStatus ComputeGoalStatus() { GoalStatus subGoalStatus; if (SubGoals.Count != 0 && _mostDesirableSubGoalIndexOnClient != -1) { Goal mostDesirableSubGoal = SubGoals[_mostDesirableSubGoalIndexOnClient]; subGoalStatus = mostDesirableSubGoal.ComputeGoalStatus(); if (subGoalStatus == GoalStatus.Completed && SubGoals.Count > 1) { subGoalStatus = GoalStatus.Active; } } else { subGoalStatus = GoalStatus.Completed; } if (_clientStatus != GoalStatus.Inactive) { _serverStatus = ShouldStatusChange(subGoalStatus); } else { _serverStatus = GoalStatus.Active; } return(_serverStatus); }
protected void ReactivateIfFailed() { if (HasFailed) { Status = GoalStatus.Inactive; } }
public ActionFeedback(Header header, GoalStatus goalStatus, PartialMessageDeserializer goalMessageDeserializer) { _goalMessageDeserializer = goalMessageDeserializer; Header = header; GoalStatus = goalStatus; }
// Process all the gubgoals public GoalStatus ProcessSubgoals() { // while there is still some tasks left, we remove any goals that has been completed or failed while (my_Subgoals.Count > 0 && (my_Subgoals.Peek().isCompleted() || my_Subgoals.Peek().hasFailed())) { my_Subgoals.Pop().Terminate(); } // process the next goal if (my_Subgoals.Count > 0) { //get the status of the current goal GoalStatus status = my_Subgoals.Peek().Process(); //to make sure that we keep processing goals after completed message is received if (status == GoalStatus.completed && my_Subgoals.Count > 1) { return(GoalStatus.active); } return(status); } //all the goal is competed else { return(GoalStatus.completed); } }
public void UpdateGoalStatus(GoalStatus status) { if (status != CurrentGoalStatus) { PreviousGoalStatus = CurrentGoalStatus; CurrentGoalStatus = status; } }
private void StatusCallback(GoalStatusArray actionGoalStatusArray) { if (actionGoalStatusArray.status_list.Length > 0) { goalStatus = actionGoalStatusArray.status_list[actionGoalStatusArray.status_list.Length - 1]; } OnStatusUpdated(); }
private void FixedUpdate() { // if the goal is not satisfied we keep trying if (my_Status != GoalStatus.completed) { my_Status = goal.Process(); } }
public ActionResult SaveAjax(GoalStatus goalstatus) { //id=0 means add operation, update operation otherwise bool isNew = goalstatus.ID == 0; //validate data if (ModelState.IsValid) { try { //call repository function to save the data in database goalstatusRepository.InsertOrUpdate(goalstatus); goalstatusRepository.Save(); //set status message if (isNew) { goalstatus.SuccessMessage = "Goal Status has been added successfully"; } else { goalstatus.SuccessMessage = "Goal Status has been updated successfully"; } } catch (CustomException ex) { goalstatus.ErrorMessage = ex.UserDefinedMessage; } catch (Exception ex) { ExceptionManager.Manage(ex); goalstatus.ErrorMessage = Constants.Messages.UnhandelledError; } } else { foreach (var modelStateValue in ViewData.ModelState.Values) { foreach (var error in modelStateValue.Errors) { goalstatus.ErrorMessage = error.ErrorMessage; break; } if (goalstatus.ErrorMessage.IsNotNullOrEmpty()) { break; } } } //return the status message in json if (goalstatus.ErrorMessage.IsNotNullOrEmpty()) { return(Json(new { success = false, data = goalstatus.ErrorMessage })); } else { return(Json(new { success = true, data = goalstatus.SuccessMessage })); } }
public virtual void Activate() { if (owner.Debug) { Debug.Log("AI-Thinking : " + owner.gameObject.name + " Activate the goal " + GetType().Name); } status = GoalStatus.Active; }
/// <summary> /// Creates a new Goal /// </summary> /// <param name="id">The ID of the Goal</param> /// <param name="name">The name of the Goal</param> /// <param name="description">The description of the goal</param> /// <param name="target">The target of the goal</param> /// <param name="status">The status of the goal</param> /// <param name="isDefault">Whether the goal is the default for the user</param> public Goal(int id, string name, string description, double target, GoalStatus status, bool isDefault) { Id = id; Name = name; Description = description; Target = target <= 0 ? throw new ArgumentOutOfRangeException(nameof(target), "Please ensure the goal has a target") : target; Status = status; IsDefault = isDefault; }
private void StatusCallback(GoalStatusArray actionGoalStatusArray) { if (actionGoalStatusArray.status_list.Length > 0) { goalStatus = actionGoalStatusArray.status_list[0]; } lastStatusUpdateTime = DateTime.Now; OnStatusUpdated(); }
public void PublishFeedback(GoalStatus goalStatus, TFeedback feedback) { var newFeedback = new FeedbackActionMessage <TFeedback>(); newFeedback.Header = new Messages.std_msgs.Header(); newFeedback.Header.stamp = ROS.GetTime(); newFeedback.GoalStatus = goalStatus; newFeedback.Feedback = feedback; ROS.Debug()($"[{ThisNode.Name}] [actionlib] Publishing feedback for goal with id: {goalStatus.goal_id.id} and stamp: {new DateTimeOffset( ROS.GetTime( goalStatus.goal_id.stamp ) ).ToUnixTimeSeconds()}"); feedbackPublisher.publish(newFeedback); }
public ActionResult <GoalStatus> Post([FromBody] GoalStatus model) { var serviceResult = _goalStatusService.Create(model); if (serviceResult.Status == BrashActionStatus.ERROR) { return(BadRequest(serviceResult.Message)); } return(serviceResult.Model); }
public void Activate() { GoalStatus = GoalStatus.Active; oldMaxSpeed = entity.MaxSpeed; entity.MaxSpeed = 0; timer = new Timer(); timer.Interval = 2000; timer.AutoReset = true; timer.Elapsed += Sleep; timer.Enabled = true; }
public Goal(int goalId, int userId, string title, string info, DateTime?startDT, DateTime endDT, int progress, GoalStatus status, int strikes, DateTime postDT) { GoalId = goalId; UserId = userId; Title = title; Info = info; StartDT = startDT; EndDT = endDT; Progress = progress; Status = status; Strikes = strikes; PostDT = postDT; }
public ActionResult Index([DataSourceRequest(Prefix = "Grid")] DataSourceRequest dsRequest) { if (!ViewBag.HasAccessToAdminModule) { WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action"; return(RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty })); } //create a new instance of goalstatus GoalStatus goalstatus = new GoalStatus(); //return view result return(View(goalstatus)); }
public static string GetGoalStatusString(GoalStatus goalStatus) { if (goalStatus == null) { return("INVALID GOAL STATUS 'null'"); } if (goalStatus.status >= 0 && goalStatus.status < GoalStates.Count) { return(GoalStates[goalStatus.status]); } return($"INVALID GOAL STATUS {goalStatus.status}"); }
public override GoalStatus Process() { ActiveIfInactive(); GoalStatus subStatus = ProcessSubgoals(); if (subStatus == GoalStatus.Complete || subStatus == GoalStatus.Failed) { Status = GoalStatus.Complete; } return(Status); }
public bool Equals(WrappedFeedbackMessage <T> message) { if (message == null) { return(false); } bool result = true; result &= Header.Equals(message.Header); result &= GoalStatus.Equals(message.GoalStatus); result &= Content.Equals(message.Content); return(result); }
/// <summary> /// Get the goal status /// </summary> /// <param name="goalStatus">The goal status as an instance of <c>actionlib_msgs.GoalStatus</c></param> /// <returns>Returns the goal status as <c>string</c>.</returns> public static string GetGoalStatusString(actionlib_msgs.GoalStatus goalStatus) { if (goalStatus == null) { return("null"); } if (Enum.IsDefined(typeof(GoalStatus), goalStatus.status)) { GoalStatus status = (GoalStatus)goalStatus.status; return(status.ToString("g")); } return($"INVALID GOAL STATUS {goalStatus.status}"); }
public void Activate() { GoalStatus = GoalStatus.Active; previousMaxSpeed = ME.MaxSpeed; ME.MaxSpeed = 0; // Set a timer to increase the fatique timer = new Timer(); timer.Interval = 1000; timer.AutoReset = true; timer.Elapsed += Sleep; timer.Enabled = true; }
public void PublishResult(GoalStatus goalStatus, TResult result) { var newResult = new ResultActionMessage <TResult>(); newResult.Header = new Messages.std_msgs.Header(); newResult.Header.stamp = ROS.GetTime(); newResult.GoalStatus = goalStatus; if (result != null) { newResult.Result = result; } ROS.Debug()($"[{ThisNode.Name}] [actionlib] Publishing result for goal with id: {goalStatus.goal_id.id} and stamp: {new DateTimeOffset( ROS.GetTime( goalStatus.goal_id.stamp ) ).ToUnixTimeSeconds()}"); resultPublisher.publish(newResult); PublishStatus(); }
private void ApplyGoalStatusOnClients(Command command, object networkvalue) { var serverStatus = (GoalStatus) networkvalue; switch (serverStatus) { case GoalStatus.Active: { if (_clientStatus == GoalStatus.Inactive) { _clientStatus = GoalStatus.Active; Activate(); } break; } case GoalStatus.Completed: { OnCompleted(); break; } case GoalStatus.Failed: { OnFailed(); break; } default: case GoalStatus.Inactive: { if (_clientStatus == GoalStatus.Active) { _clientStatus = GoalStatus.Inactive; Terminate(); } break; } } _clientStatus = serverStatus; }
private GoalStatus ComputeGoalStatus() { GoalStatus subGoalStatus; if (SubGoals.Count != 0 && _mostDesirableSubGoalIndexOnClient != -1) { Goal mostDesirableSubGoal = SubGoals[_mostDesirableSubGoalIndexOnClient]; subGoalStatus = mostDesirableSubGoal.ComputeGoalStatus(); if (subGoalStatus == GoalStatus.Completed && SubGoals.Count > 1) subGoalStatus = GoalStatus.Active; } else subGoalStatus = GoalStatus.Completed; if (_clientStatus != GoalStatus.Inactive) _serverStatus = ShouldStatusChange(subGoalStatus); else _serverStatus = GoalStatus.Active; return _serverStatus; }
protected override GoalStatus ShouldStatusChange(GoalStatus subGoalStatus) { return GoalStatus.Active; }
protected abstract GoalStatus ShouldStatusChange(GoalStatus subGoalStatus);