Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 package org.srs.srs_knowledge.task;
00052
00053 import java.io.*;
00054 import java.util.StringTokenizer;
00055 import java.util.ArrayList;
00056
00057 import ros.pkg.srs_knowledge.msg.*;
00058 import ros.pkg.geometry_msgs.msg.Pose2D;
00059
00060 import org.srs.srs_knowledge.task.*;
00061 import org.srs.srs_knowledge.knowledge_engine.*;
00062 import ros.pkg.srs_symbolic_grounding.srv.*;
00063
00064 import org.json.simple.JSONArray;
00065 import org.json.simple.JSONObject;
00066 import org.json.simple.JSONValue;
00067 import org.json.simple.parser.ParseException;
00068 import org.json.simple.parser.JSONParser;
00069
00070 import ros.pkg.srs_msgs.msg.SRSSpatialInfo;
00071
00076 public class MoveAndCheckWorkspaceActionUnit extends HighLevelActionUnit {
00077
00078 public MoveAndCheckWorkspaceActionUnit(ArrayList<Pose2D> positions, String objectClassName, SRSSpatialInfo targetSurface) {
00079 for(Pose2D position:positions) {
00080 GenericAction ga = new GenericAction();
00081
00082 ga.jsonActionInfo = SRSJSONParser.encodeMoveAction("move", position.x, position.y, position.theta);
00083 actionUnits.add(ga);
00084
00085 GenericAction detAct = new GenericAction();
00086
00087 detAct.jsonActionInfo = SRSJSONParser.encodeCheckObjectAction("check", objectClassName, targetSurface.pose.position.x, targetSurface.pose.position.y, targetSurface.pose.position.z, targetSurface.pose.orientation.x, targetSurface.pose.orientation.y, targetSurface.pose.orientation.z, targetSurface.pose.orientation.w, targetSurface.l, targetSurface.w, targetSurface.h);
00088
00089 actionUnits.add(detAct);
00090 }
00091
00092
00093 ifParametersSet = true;
00094
00095 int size = actionUnits.size();
00096 nextActionMapIfFail = new int[size];
00097 nextActionMapIfSuccess = new int[size];
00098
00099 for(int i = 0; i < size; i++) {
00100
00101 JSONObject tempAct = SRSJSONParser.decodeJsonActionInfo(actionUnits.get(i).jsonActionInfo);
00102 if(tempAct.get("action").equals("move")) {
00103 nextActionMapIfSuccess[i] = i + 1;
00104 nextActionMapIfFail[i] = i + 2;
00105 System.out.println("move ---- " + i);
00106 }
00107 else if(tempAct.get("action").equals("check")) {
00108 nextActionMapIfSuccess[i] = COMPLETED_SUCCESS;
00109 nextActionMapIfFail[i] = i + 1;
00110 System.out.println("check ---- " + i);
00111 }
00112 if(nextActionMapIfFail[i] >= size) {
00113
00114 nextActionMapIfFail[i] = COMPLETED_FAIL;
00115 System.out.println("overflow ---- " + i);
00116 }
00117 }
00118 }
00119
00120 @Override
00121 public String getActionType() {
00122 actionType = "MoveAndCheckWorkspace";
00123 return actionType;
00124 }
00125
00126 @Override
00127 public boolean ifParametersSet() {
00128 return ifParametersSet;
00129 }
00130
00131 @Override
00132 public boolean setParameters(String action, String para, String reservedParam) {
00133 return ifParametersSet;
00134 }
00135 }