diff --git a/.gitignore b/.gitignore index ed27e12..15958fd 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /out/ /nbproject/private/ .nb-gradle/ +inputlink.txt # Compiled class file *.class diff --git a/00 - Scripts/script.sh b/00 - Scripts/script.sh new file mode 100755 index 0000000..85e71b9 --- /dev/null +++ b/00 - Scripts/script.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +xhost + + +docker run --rm -it --name coppelia-sim \ + -e DISPLAY \ + --net=host \ + --privileged \ + brgsil/ws3d-coppelia + +xhost - diff --git a/0_ - DemoConsciousness/DemoCST b/0_ - DemoConsciousness/DemoCST new file mode 160000 index 0000000..a64f103 --- /dev/null +++ b/0_ - DemoConsciousness/DemoCST @@ -0,0 +1 @@ +Subproject commit a64f103f0ba94aaf85d8af2c2666b7641236e8e3 diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/.gitignore b/0_ - DemoBehaviorNetwork/DemoBNProject/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/LICENSE b/0_ - DemoBehaviorNetwork/DemoBNProject/LICENSE similarity index 100% rename from LICENSE rename to 0_ - DemoBehaviorNetwork/DemoBNProject/LICENSE diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/README.md b/0_ - DemoBehaviorNetwork/DemoBNProject/README.md new file mode 100644 index 0000000..77dab21 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/README.md @@ -0,0 +1 @@ +# DemoBehaviorNetwork \ No newline at end of file diff --git a/build.gradle b/0_ - DemoBehaviorNetwork/DemoBNProject/build.gradle similarity index 87% rename from build.gradle rename to 0_ - DemoBehaviorNetwork/DemoBNProject/build.gradle index e5d4d47..6d62ef8 100644 --- a/build.gradle +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/build.gradle @@ -14,14 +14,14 @@ repositories { maven { url "https://github.com/rosjava/rosjava_mvn_repo/raw/master" } - maven { url 'https://jitpack.io' } maven { - url 'https://cst-group.github.io/cst-dependencies/maven-repo/' - } + url "https://cst-group.github.io/cst-dependencies/maven-repo/" + } + maven { url 'https://jitpack.io' } } dependencies { - implementation 'com.github.CST-Group:cst-desktop:1.1.0' + implementation 'com.github.CST-Group:cst-desktop:f21d7ff' implementation 'com.github.CST-Group:WS3DProxy:0.0.3' implementation 'org.json:json:20180813' testImplementation group: 'junit', name: 'junit', version: '4.10' diff --git a/gradle/wrapper/gradle-wrapper.jar b/0_ - DemoBehaviorNetwork/DemoBNProject/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to 0_ - DemoBehaviorNetwork/DemoBNProject/gradle/wrapper/gradle-wrapper.jar diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/gradle/wrapper/gradle-wrapper.properties b/0_ - DemoBehaviorNetwork/DemoBNProject/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e411586 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/0_ - DemoBehaviorNetwork/DemoBNProject/gradlew similarity index 100% rename from gradlew rename to 0_ - DemoBehaviorNetwork/DemoBNProject/gradlew diff --git a/gradlew.bat b/0_ - DemoBehaviorNetwork/DemoBNProject/gradlew.bat similarity index 100% rename from gradlew.bat rename to 0_ - DemoBehaviorNetwork/DemoBNProject/gradlew.bat diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/settings.gradle b/0_ - DemoBehaviorNetwork/DemoBNProject/settings.gradle new file mode 100644 index 0000000..ab94bd7 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'DemoBehaviorNetwork' diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/AgentMind.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/AgentMind.java new file mode 100644 index 0000000..4555f2c --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/AgentMind.java @@ -0,0 +1,351 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import br.unicamp.cst.behavior.bn.Behavior; +import br.unicamp.cst.behavior.bn.BehaviorNetwork; +import br.unicamp.cst.behavior.bn.GlobalVariables; +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.Mind; +import br.unicamp.cst.memory.WorkingStorage; +import br.unicamp.cst.representation.idea.Idea; +import br.unicamp.cst.util.behavior.bn.BHMonitor; +import br.unicamp.cst.util.behavior.bn.BNplot; +import codelets.behaviors.BehaviorToActionCodelet; +import codelets.behaviors.EatBehavior; +import codelets.behaviors.ExploreBehavior; +import codelets.behaviors.ForageFoodBehavior; +import codelets.motor.HandsActionCodelet; +import codelets.motor.LegsActionCodelet; +import codelets.perception.AppleDetector; +import codelets.perception.ClosestAppleDetector; +import codelets.perception.WorldStateDetector; +import codelets.sensors.InnerSense; +import codelets.sensors.Vision; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import ws3dproxy.model.Thing; +/** + * + * @author rgudwin + */ +public class AgentMind extends Mind { + + + public ArrayList behavioralCodelets = new ArrayList<>(); + + public AgentMind(Environment env) { + super(); + + // Create CodeletGroups and MemoryGroups for organizing Codelets and Memories + createCodeletGroup("Sensory"); + createCodeletGroup("Motor"); + createCodeletGroup("Perception"); + createCodeletGroup("Competence"); + createCodeletGroup("ActionSelection"); + createCodeletGroup("Graph"); + + createMemoryGroup("Sensory"); + createMemoryGroup("Motor"); + createMemoryGroup("Working"); + + // Declare Memory Objects + Memory legsMO; // This Memory is going to be a MemoryContainer + Memory handsMO; + Memory visionMO; + Memory innerSenseMO; + Memory closestAppleMO; + Memory knownApplesMO; + + Memory worldStateHungryMO; + Memory worldStateFoundFoodMO; + Memory worldStateExploringMO; + Memory worldStateExploringDetectorMO; + Memory chosenBehaviorMO; + + //Declare world states + + String stateHungry = "hungry"; + String stateNotHungry = "NOT_hungry"; + String stateFoundFood = "foundFood"; + String stateExploring = "exploring"; + String stateNotExploring = "NOT_exploring"; + + //Initialize Memory Objects + legsMO=createMemoryContainer("LEGS"); + registerMemory(legsMO,"Motor"); + handsMO=createMemoryObject("HANDS", ""); + registerMemory(handsMO,"Motor"); + List vision_list = Collections.synchronizedList(new ArrayList<>()); + visionMO=createMemoryObject("VISION",vision_list); + registerMemory(visionMO,"Sensory"); + Idea cis = Idea.createIdea("cis","", Idea.guessType("AbstractObject", 1)); + cis.add(Idea.createIdea("cis.pitch", 0D, Idea.guessType("Property", 1))); + cis.add(Idea.createIdea("cis.fuel", 0D, Idea.guessType("Property", 1))); + Idea position = Idea.createIdea("cis.position","", Idea.guessType("Property",1)); + position.add(Idea.createIdea("cis.position.x",0D,Idea.guessType("QualityDimension",1))); + position.add(Idea.createIdea("cis.position.y",0D,Idea.guessType("QualityDimension",1))); + cis.add(position); + Idea fov = Idea.createIdea("cis.FOV","", Idea.guessType("Property", 1)); + Idea bounds = Idea.createIdea("cis.FOV.bounds","", Idea.guessType("Property", 1)); + bounds.add(Idea.createIdea("cis.FOV.bounds.x",null, Idea.guessType("Property", 1))); + bounds.add(Idea.createIdea("cis.FOV.bounds.y",null, Idea.guessType("Property", 1))); + bounds.add(Idea.createIdea("cis.FOV.bounds.height",null, Idea.guessType("Property", 1))); + bounds.add(Idea.createIdea("cis.FOV.bounds.width",null, Idea.guessType("Property", 1))); + fov.add(bounds); + fov.add(Idea.createIdea("cis.FOV.npoints",0, Idea.guessType("Property", 1))); + fov.add(Idea.createIdea("cis.FOV.points","", Idea.guessType("Property", 1))); + cis.add(fov); + innerSenseMO=createMemoryObject("INNER", cis); + registerMemory(innerSenseMO,"Sensory"); + Thing closestApple = null; + closestAppleMO=createMemoryObject("CLOSEST_APPLE", closestApple); + registerMemory(closestAppleMO,"Working"); + List knownApples = Collections.synchronizedList(new ArrayList<>()); + knownApplesMO=createMemoryObject("KNOWN_APPLES", knownApples); + registerMemory(knownApplesMO,"Working"); + + //Define Behavior Network MOs + chosenBehaviorMO = createMemoryObject("CHOSEN_BEHAVIOR", ""); + + worldStateHungryMO = createMemoryObject("WORLD_STATE", ""); + worldStateFoundFoodMO = createMemoryObject("WORLD_STATE", ""); + worldStateExploringMO = createMemoryObject("WORLD_STATE", ""); + worldStateExploringDetectorMO = createMemoryObject("EXPLORING_STATE_DETECTOR", stateNotExploring); + registerMemory(worldStateHungryMO,"Sensory"); + registerMemory(worldStateFoundFoodMO,"Sensory"); + registerMemory(worldStateExploringMO,"Sensory"); + + // Create Sensor Codelets + Codelet vision=new Vision(env.c); + vision.addOutput(visionMO); + insertCodelet(vision); //Creates a vision sensor + registerCodelet(vision,"Sensory"); + + Codelet innerSense=new InnerSense(env.c); + innerSense.addOutput(innerSenseMO); + insertCodelet(innerSense); //A sensor for the inner state of the creature + registerCodelet(innerSense,"Sensory"); + + // Create Actuator Codelets + Codelet legs=new LegsActionCodelet(env.c); + legs.addInput(legsMO); + legs.addOutput(worldStateExploringDetectorMO); + insertCodelet(legs); + registerCodelet(legs,"Motor"); + + Codelet hands=new HandsActionCodelet(env.c); + hands.addInput(handsMO); + hands.addOutput(worldStateHungryMO); + hands.addOutput(worldStateFoundFoodMO); + hands.addOutput(worldStateExploringDetectorMO); + + insertCodelet(hands); + registerCodelet(hands,"Motor"); + + // Create Perception Codelets + Codelet ad = new AppleDetector(); + ad.addInput(visionMO); + ad.addOutput(knownApplesMO); + insertCodelet(ad); + registerCodelet(ad,"Perception"); + + Codelet closestAppleDetector = new ClosestAppleDetector(); + closestAppleDetector.addInput(knownApplesMO); + closestAppleDetector.addInput(innerSenseMO); + closestAppleDetector.addOutput(closestAppleMO); + insertCodelet(closestAppleDetector); + registerCodelet(closestAppleDetector,"Perception"); + + //Create detector codelet for world state detections + Codelet worldStateDetector = new WorldStateDetector(env.c); + worldStateDetector.addInput(closestAppleMO); + worldStateDetector.addInput(innerSenseMO); + worldStateDetector.addInput(worldStateExploringDetectorMO); + + //Define Outputs + worldStateDetector.addOutput(worldStateHungryMO); + worldStateDetector.addOutput(worldStateFoundFoodMO); + worldStateDetector.addOutput(worldStateExploringMO); + insertCodelet(worldStateDetector); + registerCodelet(worldStateDetector,"Perception"); + + Memory stateHungryMO = createMemoryObject("WORLD_STATE", stateHungry); + Memory stateNotHungryMO = createMemoryObject("WORLD_STATE", stateNotHungry); + Memory stateFoundFoodMO = createMemoryObject("WORLD_STATE", stateFoundFood); + Memory stateExploringMO = createMemoryObject("WORLD_STATE", stateExploring); + + Memory goals1MO = createMemoryObject("PERMANENT_GOAL", stateNotHungry); + Memory goals2MO = createMemoryObject("PERMANENT_GOAL", stateExploring); + + //Define working storage and global variables for competences + WorkingStorage ws = null; + GlobalVariables gv = new GlobalVariables(); + + Behavior forageFoodCompetence = new ForageFoodBehavior(ws, gv); + + //Define HARD-PRE-CONDITIONS + ArrayList preconditionsListForage = new ArrayList<>(); + preconditionsListForage.add(stateHungryMO); + forageFoodCompetence.setListOfPreconditions(preconditionsListForage); + + //Define ADD-LIST + ArrayList addListForage = new ArrayList<>(); + addListForage.add(stateFoundFoodMO); + forageFoodCompetence.setAddList(addListForage); + + //Define DELETE-LIST + ArrayList deleteListForage = new ArrayList<>(); + deleteListForage.add(stateExploringMO); + forageFoodCompetence.setDeleteList(deleteListForage); + + //Define WORLD_STATE_PARAMETERS as inputs + forageFoodCompetence.addInput(worldStateHungryMO); + forageFoodCompetence.addInput(worldStateFoundFoodMO); + forageFoodCompetence.addInput(worldStateExploringMO); + + //Define GOALS + forageFoodCompetence.addInput(goals1MO); + forageFoodCompetence.addInput(goals2MO); + + //Define OUTPUT the chosen behavior + forageFoodCompetence.addOutput(chosenBehaviorMO); + + insertCodelet(forageFoodCompetence); + registerCodelet(forageFoodCompetence, "Competence"); + behavioralCodelets.add(forageFoodCompetence); + + Behavior eatCompetence = new EatBehavior(ws, gv); + + //Define HARD-PRE-CONDITIONS + ArrayList preconditionsListEat = new ArrayList<>(); + preconditionsListEat.add(stateFoundFoodMO); + eatCompetence.setListOfPreconditions(preconditionsListEat); + + //Define SOFT-PRE-CONDITIONS + ArrayList softPreconditionsListEat = new ArrayList<>(); + softPreconditionsListEat.add(stateHungryMO); + eatCompetence.setSoftPreconList(softPreconditionsListEat); + + //Define ADD-LIST + ArrayList addListEat = new ArrayList<>(); + addListEat.add(stateNotHungryMO); + eatCompetence.setAddList(addListEat); + + //Define DELETE-LIST + ArrayList deleteListEat= new ArrayList<>(); + deleteListEat.add(stateHungryMO); + eatCompetence.setDeleteList(deleteListEat); + + //Define WORLD_STATE_PARAMETERS as inputs + eatCompetence.addInput(worldStateHungryMO); + eatCompetence.addInput(worldStateFoundFoodMO); + eatCompetence.addInput(worldStateExploringMO); + + //Define GOALS + eatCompetence.addInput(goals1MO); + eatCompetence.addInput(goals2MO); + + //Define OUTPUT the chosen behavior + eatCompetence.addOutput(chosenBehaviorMO); + + insertCodelet(eatCompetence); + registerCodelet(eatCompetence, "Competence"); + behavioralCodelets.add(eatCompetence); + + Behavior exploreCompetence = new ExploreBehavior(ws, gv); + + //Define HARD-PRE-CONDITIONS + ArrayList preconditionsListExplore = new ArrayList<>(); + preconditionsListExplore.add(stateNotHungryMO); + exploreCompetence.setListOfPreconditions(preconditionsListExplore); + + //Define ADD-LIST + ArrayList addListExplore = new ArrayList<>(); + addListExplore.add(stateExploringMO); + addListExplore.add(stateHungryMO); + exploreCompetence.setAddList(addListExplore); + + //Define DELETE-LIST + ArrayList deleteListExplore= new ArrayList<>(); + deleteListExplore.add(stateNotHungryMO); + exploreCompetence.setDeleteList(deleteListExplore); + + //Define WORLD_STATE_PARAMETERS as inputs + exploreCompetence.addInput(worldStateHungryMO); + exploreCompetence.addInput(worldStateFoundFoodMO); + exploreCompetence.addInput(worldStateExploringMO); + + //Define GOALS as inputs + exploreCompetence.addInput(goals1MO); + exploreCompetence.addInput(goals2MO); + + //Define OUTPUTS with comands to actuator + exploreCompetence.addOutput(chosenBehaviorMO); + + insertCodelet(exploreCompetence); + registerCodelet(exploreCompetence, "Competence"); + behavioralCodelets.add(exploreCompetence); + + BehaviorNetwork bn = new BehaviorNetwork(this.getCodeRack(), ws); + bn.addCodelet(forageFoodCompetence); + bn.addCodelet(eatCompetence); + bn.addCodelet(exploreCompetence); + List allCodelets = this.getCodeRack().getAllCodelets(); + + ArrayList behaviorList = new ArrayList(); + behaviorList.add(eatCompetence); + behaviorList.add(forageFoodCompetence); + behaviorList.add(exploreCompetence); + + bn.setCoalition(behaviorList); + + BehaviorToActionCodelet behaviorToActionCodelet = new BehaviorToActionCodelet(); + behaviorToActionCodelet.addInput(chosenBehaviorMO); + behaviorToActionCodelet.addInput(closestAppleMO); + behaviorToActionCodelet.addInput(innerSenseMO); + behaviorToActionCodelet.addOutput(handsMO); + behaviorToActionCodelet.addOutput(knownApplesMO); + behaviorToActionCodelet.addOutput(legsMO); + insertCodelet(behaviorToActionCodelet); + registerCodelet(behaviorToActionCodelet, "ActionSelection"); + + BNplot bNplot = new BNplot(behaviorList); + bNplot.plot(); + + + ArrayList behaviorsIWantShownInGraphics = new ArrayList<>(); + behaviorsIWantShownInGraphics.add(eatCompetence.getName()); + behaviorsIWantShownInGraphics.add(forageFoodCompetence.getName()); + behaviorsIWantShownInGraphics.add(exploreCompetence.getName()); + BHMonitor bHMonitor = new BHMonitor(bn, behaviorsIWantShownInGraphics, gv); + insertCodelet(bHMonitor); + + registerCodelet(bHMonitor, "Graph"); + + // sets a time step for running the codelets to avoid heating too much your machine + for (Codelet c : this.getCodeRack().getAllCodelets()) + c.setTimeStep(200); + + // Start Cognitive Cycle + start(); + } + +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/Environment.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/Environment.java new file mode 100644 index 0000000..2a54a70 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/Environment.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import support.ResourcesGenerator; +import ws3dproxy.CommandExecException; +import ws3dproxy.WS3DProxy; +import ws3dproxy.model.Creature; +import ws3dproxy.model.World; +import ws3dproxy.util.Constants; +import ws3dproxy.util.Logger; + +/** + * + * @author rgudwin + */ +public final class Environment { + + public String host="localhost"; + public int port = 4011; + public String robotID="r0"; + public Creature c = null; + + public Environment() { + WS3DProxy proxy = new WS3DProxy(); + try { + World w = World.getInstance(); + w.reset(); + World.createFood(0, 350, 75); + World.createFood(0, 100, 220); + World.createFood(0, 250, 210); + c = proxy.createCreature(100,450,0,0); + c.start(); + grow(w,5); + } catch (CommandExecException e) { + + } + System.out.println("Robot "+c.getName()+" is ready to go."); + } + + public synchronized void grow(World w, int time) { + try { + if (time <= 0) { + time = Constants.TIMEFRAME; + } + w.getDimensionAndDeliverySpot(); + ResourcesGenerator rg = new ResourcesGenerator(time, w.getEnvironmentWidth(), w.getEnvironmentHeight(), w.getDeliverySpot().getX(), w.getDeliverySpot().getY()); + rg.start(); + } catch (CommandExecException ex) { + Logger.logException(World.class.getName(), ex); + } + } +} diff --git a/src/main/java/ExperimentMain.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/ExperimentMain.java similarity index 100% rename from src/main/java/ExperimentMain.java rename to 0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/ExperimentMain.java diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/BehaviorToActionCodelet.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/BehaviorToActionCodelet.java new file mode 100644 index 0000000..0a4bf2e --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/BehaviorToActionCodelet.java @@ -0,0 +1,271 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.behaviors; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.awt.Point; +import java.awt.geom.Point2D; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CopyOnWriteArrayList; +import org.json.JSONException; +import org.json.JSONObject; +import ws3dproxy.model.Thing; + +/** + * + * @author karenlima + */ +public class BehaviorToActionCodelet extends Codelet { + + private MemoryObject chosenBehaviorMO; + private String chosenBehavior; + private MemoryObject closestAppleMO; + private MemoryObject handsMO; + private MemoryObject knownApplesMO; + private Thing closestApple; + private List knownApples; + private MemoryContainer legsMO; + private final int creatureBasicSpeed=3; + private final double reachDistance = 50; + private String lastBehavior = ""; + private MemoryObject innerSenseMO; + private Idea cis; + private double positionX = -1; + private double positionY = -1; + + + public void BehaviorToActionCodelet() { + System.currentTimeMillis(); + this.name = "BehaviorToAction"; + } + + @Override + public void accessMemoryObjects() { + chosenBehaviorMO = (MemoryObject)this.getInput("CHOSEN_BEHAVIOR"); + + closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE"); + innerSenseMO=(MemoryObject)this.getInput("INNER"); + + handsMO=(MemoryObject)this.getOutput("HANDS"); + knownApplesMO = (MemoryObject)this.getOutput("KNOWN_APPLES"); + + legsMO = (MemoryContainer)this.getOutput("LEGS"); + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + if (chosenBehaviorMO != null) { + chosenBehavior = (String) chosenBehaviorMO.getI(); + System.out.println("Chosen behavior: " + chosenBehavior); + switch(chosenBehavior) { + case "EAT_COMPETENCE": + eatProc(); + break; + case "EXPLORE_COMPETENCE": +// exploreRandomProc(); + exploreRotateProc(); + break; + case "FORAGE_FOOD_COMPETENCE": + forageFoodProc(); + break; + default: + System.out.println("No behavior "); + break; + + } + lastBehavior = chosenBehavior; + } + } + + private void eatProc() { + String appleName=""; + closestApple = (Thing) closestAppleMO.getI(); + cis = (Idea) innerSenseMO.getI(); + knownApples = (List) knownApplesMO.getI(); + //Find distance between closest apple and self + //If closer than reachDistance, eat the apple + + if(closestApple != null){ + double appleX=0; + double appleY=0; + try { + appleX=closestApple.getCenterPosition().getX(); + appleY=closestApple.getCenterPosition().getY(); + appleName = closestApple.getName(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + + Point2D pApple = new Point(); + pApple.setLocation(appleX, appleY); + + Point2D pSelf = new Point(); + pSelf.setLocation(selfX, selfY); + + double distance = pSelf.distance(pApple); + JSONObject message=new JSONObject(); + try { + if(distance<=reachDistance){ //eat it + DestroyClosestApple(); + message.put("OBJECT", appleName); + message.put("ACTION", "EATIT"); + handsMO.setI(message.toString()); + + + }else{ + handsMO.setI(""); //nothing + } + + System.out.println(message); + } catch (JSONException e) { + e.printStackTrace(); + } + }else{ + handsMO.setI(""); //nothing + activation=0.0; + } + } + + public void DestroyClosestApple() { + int r = -1; + int i = 0; + synchronized(knownApples) { + for (Thing t : knownApples) { + if (closestApple != null) + if (t.getName().equals(closestApple.getName())) r = i; + i++; + } + if (r != -1) { + knownApples.remove(r); + } + closestApple = null; + knownApplesMO.setI(knownApples); + } + } + + private void exploreRandomProc() { + Random random = new Random(); + if(isCreatureInLastTarget() || !lastBehavior.equals("EXPLORE_COMPETENCE")) { + positionX = (double) random.nextInt(800); + positionY = (double) random.nextInt(600); + Idea message = Idea.createIdea("message","", Idea.guessType("Property",1)); + message.add(Idea.createIdea("ACTION","RANDOM", Idea.guessType("Property",1))); + message.add(Idea.createIdea("X",(int)positionX, Idea.guessType("Property",1))); + message.add(Idea.createIdea("Y",(int)positionY, Idea.guessType("Property",1))); + message.add(Idea.createIdea("SPEED",creatureBasicSpeed, Idea.guessType("Property",1))); + activation=1.0; + legsMO.setI(toJson(message),activation,name); + } + } + + private void exploreRotateProc() { + if(isCreatureInLastTarget() || !lastBehavior.equals("EXPLORE_COMPETENCE")) { + Idea message = Idea.createIdea("message","", Idea.guessType("Property",1)); + message.add(Idea.createIdea("ACTION","FORAGE", Idea.guessType("Property",1))); + activation=1.0; + legsMO.setI(toJson(message),activation,name); + } + } + + private Boolean isCreatureInLastTarget() { + if (positionX == -1) return true; + cis = (Idea) innerSenseMO.getI(); + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + return calculateDistance(positionX, positionY, selfX, selfY) < 50; + } + + private double calculateDistance(double x1, double y1, double x2, double y2) { + return(Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2))); + } + + private void forageFoodProc() { + // Find distance between creature and closest apple + //If far, go towards it + //If close, stops + + Thing closestApple = (Thing) closestAppleMO.getI(); + Idea cis = (Idea) innerSenseMO.getI(); + + if(closestApple != null) + { + double appleX=0; + double appleY=0; + try { + appleX = closestApple.getCenterPosition().getX(); + appleY = closestApple.getCenterPosition().getY(); + + } catch (Exception e) { + e.printStackTrace(); + } + + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + + Point2D pApple = new Point(); + pApple.setLocation(appleX, appleY); + + Point2D pSelf = new Point(); + pSelf.setLocation(selfX, selfY); + + double distance = pSelf.distance(pApple); + Idea message = Idea.createIdea("message","", Idea.guessType("Property",1)); + try { + if(distance>reachDistance){ //Go to it + message.add(Idea.createIdea("ACTION","GOTO", Idea.guessType("Property",1))); + message.add(Idea.createIdea("X",(int)appleX, Idea.guessType("Property",1))); + message.add(Idea.createIdea("Y",(int)appleY, Idea.guessType("Property",1))); + message.add(Idea.createIdea("SPEED",creatureBasicSpeed, Idea.guessType("Property",1))); + activation=1.0; + + }else{//Stop + message.add(Idea.createIdea("ACTION","GOTO", Idea.guessType("Property",1))); + message.add(Idea.createIdea("X",(int)appleX, Idea.guessType("Property",1))); + message.add(Idea.createIdea("Y",(int)appleY, Idea.guessType("Property",1))); + message.add(Idea.createIdea("SPEED",0, Idea.guessType("Property",1))); + activation=0.5; + } + legsMO.setI(toJson(message),activation,name); + } catch (JSONException e) { + e.printStackTrace(); + } + } + else { + activation=0.0; + legsMO.setI("",activation,name); + } + } + + String toJson(Idea i) { + String q = "\""; + String out = "{"; + String val; + int ii=0; + for (Idea il : i.getL()) { + if (il.getL().isEmpty()) { + if (il.isNumber()) val = il.getValue().toString(); + else val = q+il.getValue()+q; + } + else val = toJson(il); + if (ii == 0) out += q+il.getName()+q+":"+val; + else out += ","+q+il.getName()+q+":"+val; + ii++; + } + out += "}"; + return out; + } +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/EatBehavior.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/EatBehavior.java new file mode 100644 index 0000000..50ef630 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/EatBehavior.java @@ -0,0 +1,66 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.behaviors; + +import br.unicamp.cst.behavior.bn.Behavior; +import br.unicamp.cst.behavior.bn.GlobalVariables; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.memory.WorkingStorage; +import br.unicamp.cst.util.viewer.Inspectable; +import support.BehaviorCustomView; + +/** + * + * @author karenlima + */ +public class EatBehavior extends Behavior implements Inspectable { + + private Memory chosenBehaviorsMO; + BehaviorCustomView behaviorCustomView; + + public EatBehavior(WorkingStorage ws,GlobalVariables globalVariables) { + super(ws, globalVariables); + behaviorCustomView = new BehaviorCustomView("Eat Behavior"); + } + + @Override + public void proc() { + super.proc(); + updateBehaviorCustomView(); + } + + private void updateBehaviorCustomView() { + behaviorCustomView.updateInputFromGoals(this.getInputfromgoals()); + behaviorCustomView.updateInputFromState(this.getInputfromstate()); + behaviorCustomView.updateSpreadBw(this.getSpreadbw()); + behaviorCustomView.updateSpreadFw(this.getSpreadfw()); + behaviorCustomView.updateActivation(this.getActivation()); + behaviorCustomView.updateActivationWhenActive(this.getActivationWhenActive()); + behaviorCustomView.updateExecutable(this.isExecutable()); + behaviorCustomView.updateIsActive(this.isActive()); + } + + @Override + public void operation() { + chosenBehaviorsMO.setI("EAT_COMPETENCE"); + } + + @Override + public void accessMemoryObjects() { + chosenBehaviorsMO = (MemoryObject)this.getOutput("CHOSEN_BEHAVIOR"); + } + + @Override + public void calculateActivation() { + + } + + @Override + public void inspect() { + behaviorCustomView.setVisible(true); + } + +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ExploreBehavior.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ExploreBehavior.java new file mode 100644 index 0000000..85c2cb5 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ExploreBehavior.java @@ -0,0 +1,63 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.behaviors; + +import br.unicamp.cst.behavior.bn.Behavior; +import br.unicamp.cst.behavior.bn.GlobalVariables; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.memory.WorkingStorage; +import br.unicamp.cst.util.viewer.Inspectable; +import support.BehaviorCustomView; + +/** + * + * @author karenlima + */ +public class ExploreBehavior extends Behavior implements Inspectable { + + private MemoryObject chosenBehaviorsMO; + BehaviorCustomView behaviorCustomView; + + public ExploreBehavior(WorkingStorage ws,GlobalVariables globalVariables) { + super(ws, globalVariables); + behaviorCustomView = new BehaviorCustomView("Explore Behavior"); + } + + @Override + public void proc() { + super.proc(); + updateBehaviorCustomView(); + } + + private void updateBehaviorCustomView() { + behaviorCustomView.updateInputFromGoals(this.getInputfromgoals()); + behaviorCustomView.updateInputFromState(this.getInputfromstate()); + behaviorCustomView.updateSpreadBw(this.getSpreadbw()); + behaviorCustomView.updateSpreadFw(this.getSpreadfw()); + behaviorCustomView.updateActivation(this.getActivation()); + behaviorCustomView.updateActivationWhenActive(this.getActivationWhenActive()); + behaviorCustomView.updateExecutable(this.isExecutable()); + behaviorCustomView.updateIsActive(this.isActive()); + } + + @Override + public void operation() { + chosenBehaviorsMO.setI("EXPLORE_COMPETENCE"); + } + + @Override + public void accessMemoryObjects() { + chosenBehaviorsMO = (MemoryObject)this.getOutput("CHOSEN_BEHAVIOR"); + } + + @Override + public void calculateActivation() { + } + + @Override + public void inspect() { + behaviorCustomView.setVisible(true); + } +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ForageFoodBehavior.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ForageFoodBehavior.java new file mode 100644 index 0000000..c478854 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/behaviors/ForageFoodBehavior.java @@ -0,0 +1,66 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.behaviors; + +import br.unicamp.cst.behavior.bn.Behavior; +import br.unicamp.cst.behavior.bn.GlobalVariables; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.memory.WorkingStorage; +import br.unicamp.cst.util.viewer.Inspectable; +import support.BehaviorCustomView; + +/** + * + * @author karenlima + */ +public class ForageFoodBehavior extends Behavior implements Inspectable { + + private Memory chosenBehaviorsMO; + BehaviorCustomView behaviorCustomView; + + public ForageFoodBehavior(WorkingStorage ws,GlobalVariables globalVariables) { + super(ws, globalVariables); + behaviorCustomView = new BehaviorCustomView("Forage Food Behavior"); + } + + @Override + public void proc() { + super.proc(); + updateBehaviorCustomView(); + } + + @Override + public void operation() { + chosenBehaviorsMO.setI("FORAGE_FOOD_COMPETENCE"); + } + + private void updateBehaviorCustomView() { + behaviorCustomView.updateInputFromGoals(this.getInputfromgoals()); + behaviorCustomView.updateInputFromState(this.getInputfromstate()); + behaviorCustomView.updateSpreadBw(this.getSpreadbw()); + behaviorCustomView.updateSpreadFw(this.getSpreadfw()); + behaviorCustomView.updateActivation(this.getActivation()); + behaviorCustomView.updateActivationWhenActive(this.getActivationWhenActive()); + behaviorCustomView.updateExecutable(this.isExecutable()); + behaviorCustomView.updateIsActive(this.isActive()); + } + + @Override + public void accessMemoryObjects() { + chosenBehaviorsMO = (MemoryObject)this.getOutput("CHOSEN_BEHAVIOR"); + } + + @Override + public void calculateActivation() { + + } + + @Override + public void inspect() { + behaviorCustomView.setVisible(true); + } + +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/HandsActionCodelet.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/HandsActionCodelet.java new file mode 100644 index 0000000..239de38 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/HandsActionCodelet.java @@ -0,0 +1,132 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.motor; + + +import org.json.JSONException; +import org.json.JSONObject; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.ArrayList; +import java.util.Random; +import java.util.logging.Logger; +import ws3dproxy.model.Creature; + +/** + * Hands Action Codelet monitors working storage for instructions and acts on the World accordingly. + * + * @author klaus + * + */ + + +public class HandsActionCodelet extends Codelet{ + + private Memory handsMO; + private Memory worldStateExploringDetectorMO; + private ArrayList worldStateListMO; + private String previousHandsAction=""; + private Creature c; + private Random r = new Random(); + static Logger log = Logger.getLogger(HandsActionCodelet.class.getCanonicalName()); + + public HandsActionCodelet(Creature nc) { + c = nc; + this.name = "HandsActionCodelet"; + } + + @Override + public void accessMemoryObjects() { + handsMO=(MemoryObject)this.getInput("HANDS"); + worldStateExploringDetectorMO =(MemoryObject)this.getOutput("EXPLORING_STATE_DETECTOR"); + } + public void proc() { + + String command = (String) handsMO.getI(); + + if(!command.equals("") && (!command.equals(previousHandsAction))){ + JSONObject jsonAction; + try { + jsonAction = new JSONObject(command); + if(jsonAction.has("ACTION") && jsonAction.has("OBJECT")){ + String action=jsonAction.getString("ACTION"); + String objectName=jsonAction.getString("OBJECT"); + if(action.equals("PICKUP")){ + try { + c.putInSack(objectName); + } catch (Exception e) { + + } + log.info("Sending Put In Sack command to agent:****** "+objectName+"**********"); + + + // } + } + if(action.equals("EATIT")){ + try { + c.eatIt(objectName); +// worldStateFoundFoodMO.setI("NOT_foundFood"); + } catch (Exception e) { + + } + log.info("Sending Eat command to agent:****** "+objectName+"**********"); + } + if(action.equals("BURY")){ + try { + c.hideIt(objectName); + } catch (Exception e) { + + } + log.info("Sending Bury command to agent:****** "+objectName+"**********"); + } + worldStateExploringDetectorMO.setI("NOT_exploring"); + } +// else if (jsonAction.has("ACTION")) { +// int x=0,y=0; +// String action=jsonAction.getString("ACTION"); +// if(action.equals("FORAGE")){ +// try { +// x = r.nextInt(600); +// y = r.nextInt(800); +// c.moveto(1, x,y ); +// } catch (Exception e) { +// +// } +// System.out.println("Sending Forage command to agent:****** ("+x+","+y+") **********"); +// } +// } + } catch (JSONException e) { + e.printStackTrace(); + } + + } +// System.out.println("OK_hands"); + previousHandsAction = (String) handsMO.getI(); + }//end proc + + @Override + public void calculateActivation() { + + } + + +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/LegsActionCodelet.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/LegsActionCodelet.java new file mode 100644 index 0000000..ed5d5d0 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/motor/LegsActionCodelet.java @@ -0,0 +1,154 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.motor; + + +import org.json.JSONObject; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.Random; +import java.util.logging.Logger; +import org.json.JSONException; +import ws3dproxy.model.Creature; + +/** + * Legs Action Codelet monitors working storage for instructions and acts on the World accordingly. + * + * @author klaus + * + */ + +public class LegsActionCodelet extends Codelet{ + + private Memory legsActionMO; + private Memory worldStateExploringDetectorMO; + private double previousTargetx=0; + private double previousTargety=0; + private String previousLegsAction=""; + private Creature c; + double old_angle = 0; + int k=0; + static Logger log = Logger.getLogger(LegsActionCodelet.class.getCanonicalName()); + + public LegsActionCodelet(Creature nc) { + c = nc; + this.name = "LegsActionCodelet"; + } + + @Override + public void accessMemoryObjects() { + legsActionMO=(MemoryContainer)this.getInput("LEGS"); + worldStateExploringDetectorMO=(MemoryObject)this.getOutput("EXPLORING_STATE_DETECTOR"); + } + + @Override + public void proc() { + + String comm = (String) legsActionMO.getI(); + if (comm == null) comm = ""; + Random r = new Random(); + + if(!comm.equals("") ){ + + try { + JSONObject command=new JSONObject(comm); + if (command.has("ACTION")) { + int x=0,y=0; + String action=command.getString("ACTION"); + if(action.equals("FORAGE")){ + if (!comm.equals(previousLegsAction)) { + //if (!comm.equals(previousLegsAction)) + log.info("Sending Forage command to agent"); + try { + c.rotate(2); + worldStateExploringDetectorMO.setI("exploring"); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + else if(action.equals("GOTO")){ + if (!comm.equals(previousLegsAction)) { + double speed=command.getDouble("SPEED"); + double targetx=command.getDouble("X"); + double targety=command.getDouble("Y"); + if (!comm.equals(previousLegsAction)) + log.info("Sending move command to agent: ["+targetx+","+targety+"]"); + try { + c.moveto(speed, targetx, targety); + worldStateExploringDetectorMO.setI("NOT_exploring"); + } catch(Exception e) { + e.printStackTrace(); + } + previousTargetx=targetx; + previousTargety=targety; + } + + } else if (action.equals("RANDOM")) { + if (!comm.equals(previousLegsAction)) { + double speed=command.getDouble("SPEED"); + double targetx=command.getDouble("X"); + double targety=command.getDouble("Y"); + if (!comm.equals(previousLegsAction)) + log.info("Sending move command to agent: ["+targetx+","+targety+"]"); + try { + c.moveto(speed, targetx, targety); + worldStateExploringDetectorMO.setI("exploring"); + } catch(Exception e) { + e.printStackTrace(); + } + previousTargetx=targetx; + previousTargety=targety; + } + + } else { + log.info("Sending stop command to agent"); + try { + c.moveto(0,0,0); + } catch(Exception e) { + e.printStackTrace(); + } + } + } + previousLegsAction=comm; + k++; + } catch (JSONException e) {e.printStackTrace();} + } + else { + previousLegsAction = comm; + log.info("Sending stop command to agent"); + try { + //c.moveto(0,0,0); + } catch(Exception e) { + e.printStackTrace(); + } + } + }//end proc + + @Override + public void calculateActivation() { + + } + + +} diff --git a/src/main/java/codelets/perception/AppleDetector.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/AppleDetector.java similarity index 100% rename from src/main/java/codelets/perception/AppleDetector.java rename to 0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/AppleDetector.java diff --git a/src/main/java/codelets/perception/ClosestAppleDetector.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/ClosestAppleDetector.java similarity index 95% rename from src/main/java/codelets/perception/ClosestAppleDetector.java rename to 0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/ClosestAppleDetector.java index 0b37992..7cc4002 100644 --- a/src/main/java/codelets/perception/ClosestAppleDetector.java +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/ClosestAppleDetector.java @@ -80,7 +80,7 @@ public void proc() { } } // if (closest_apple != null) -// System.out.println("Closest apple: "+closest_apple.getName()+" known: "+known.size()); +// System.out.println("Closest apple in closestAppleDetector: "+closest_apple.getName()+" known size: "+known.size() +" known: "+known); // else // System.out.println("Closest apple: null"+" known: "+known.size()); closestAppleMO.setI(closest_apple); diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/WorldStateDetector.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/WorldStateDetector.java new file mode 100644 index 0000000..6e411c3 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/perception/WorldStateDetector.java @@ -0,0 +1,172 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.perception; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import br.unicamp.cst.util.viewer.Inspectable; +import java.awt.Point; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import support.WorldStateCustomView; +import ws3dproxy.model.Creature; +import ws3dproxy.model.Thing; + +/** + * + * @author karenlima + */ +public class WorldStateDetector extends Codelet implements Inspectable { + + private Memory closestAppleMO; + private Memory selfInfoMO; + private Memory worldStateExploringDetectorMO; + private Memory worldStateHungryMO; + private Memory worldStateFoundFoodMO; + private Memory worldStateExploringMO; + private ArrayList worldStateListMO; + + private static int reachDistance=50; + private Creature c; + + String stateHungry = "hungry"; + String stateNotHungry = "NOT_hungry"; + String stateFoundFood = "foundFood"; + String stateNotFoundFood = "NOT_foundFood"; + String stateExploring = "exploring"; + String stateNotExploring = "NOT_exploring"; + + private ArrayList currentWorldState = new ArrayList(); + private ArrayList lastWorldState = new ArrayList(); + private ArrayList lastDifferentWorldState = new ArrayList(); + + WorldStateCustomView worldStateCustomView; + + public WorldStateDetector(Creature nc) { + c = nc; + worldStateCustomView = new WorldStateCustomView("World State"); + this.name = "WorldStateDetector"; + } + + @Override + public void accessMemoryObjects() { + + closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE"); + selfInfoMO=(MemoryObject)this.getInput("INNER"); + worldStateExploringDetectorMO=(MemoryObject)this.getInput("EXPLORING_STATE_DETECTOR"); + worldStateListMO=(ArrayList)this.getOutputsOfType("WORLD_STATE"); + worldStateHungryMO = worldStateListMO.get(0); + worldStateFoundFoodMO = worldStateListMO.get(1); + worldStateExploringMO = worldStateListMO.get(2); + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + foundFood(); + hungry(); + exploring(); + saveWorldStateIfChanged(); + updateWorldStateCustomView(); + } + + private void saveWorldStateIfChanged(){ + currentWorldState.clear(); + currentWorldState.add((String) worldStateHungryMO.getI()); + currentWorldState.add((String) worldStateFoundFoodMO.getI()); + currentWorldState.add((String) worldStateExploringMO.getI()); + + if(!currentWorldState.equals(lastWorldState)){ + lastDifferentWorldState = new ArrayList<>(lastWorldState); + lastWorldState = new ArrayList<>(currentWorldState); + } + } + + private void updateWorldStateCustomView() { + worldStateCustomView.updateCurrentWorldState(currentWorldState); + worldStateCustomView.updateLastDifferentWorldState(lastDifferentWorldState); + } + + private void foundFood() { + // Find distance between creature and closest apple + //If far, go towards it + //If close, stops + + Thing closestApple = (Thing) closestAppleMO.getI(); + Idea cis = (Idea) selfInfoMO.getI(); + String currentWorldStateFoundFoodInfo = (String) worldStateFoundFoodMO.getI(); + String newWorldStateFoundFoodInfo = "stateNotFoundFood"; + + if(closestApple != null) + { + double appleX=0; + double appleY=0; + try { + appleX = closestApple.getCenterPosition().getX(); + appleY = closestApple.getCenterPosition().getY(); + + } catch (Exception e) { + e.printStackTrace(); + } + + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + + Point2D pApple = new Point(); + pApple.setLocation(appleX, appleY); + + Point2D pSelf = new Point(); + pSelf.setLocation(selfX, selfY); + + double distance = pSelf.distance(pApple); + + + if(distance>reachDistance){ + newWorldStateFoundFoodInfo = stateNotFoundFood; + } else { + newWorldStateFoundFoodInfo = stateFoundFood; + } + + } + + if (!newWorldStateFoundFoodInfo.equals(currentWorldStateFoundFoodInfo)) { + worldStateFoundFoodMO.setI(newWorldStateFoundFoodInfo); + } + } + + private void hungry(){ + String currentWorldStateHungryInfo = (String) worldStateHungryMO.getI(); + String newWorldStateHungryInfo = ""; + if (c.getFuel() < 850) { + newWorldStateHungryInfo = stateHungry; + } else { + newWorldStateHungryInfo = stateNotHungry; + + } + if (!newWorldStateHungryInfo.equals(currentWorldStateHungryInfo)) { + worldStateHungryMO.setI(newWorldStateHungryInfo); + } + } + + private void exploring() { + String currentWorldStateExploringInfo = (String) worldStateExploringMO.getI(); + String newWorldStateExploringyInfo = (String) worldStateExploringDetectorMO.getI(); + + if (!newWorldStateExploringyInfo.equals(currentWorldStateExploringInfo)) { + worldStateExploringMO.setI(newWorldStateExploringyInfo); + } + } + + @Override + public void inspect() { + worldStateCustomView.setVisible(true); + } + +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/sensors/InnerSense.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/sensors/InnerSense.java new file mode 100644 index 0000000..5ce8325 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/codelets/sensors/InnerSense.java @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.sensors; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.awt.Polygon; +import java.util.ArrayList; +import java.util.List; +import ws3dproxy.model.Creature; + + +/** + * This class reads information from this agent's state and writes it to an inner sense sensory buffer. + * @author klaus + * + */ + +public class InnerSense extends Codelet { + + private Memory innerSenseMO; + private Creature c; + private Idea cis; + + public InnerSense(Creature nc) { + c = nc; + this.name = "InnerSense"; + } + @Override + public void accessMemoryObjects() { + innerSenseMO=(MemoryObject)this.getOutput("INNER"); + cis = (Idea) innerSenseMO.getI(); + } + + public void proc() { + cis.get("position.x").setValue(c.getPosition().getX()); + cis.get("position.y").setValue(c.getPosition().getY()); + cis.get("pitch").setValue(c.getPitch()); + cis.get("fuel").setValue(c.getFuel()); + Polygon pol = c.getFOV(); + Idea poli = cis.get("FOV"); + poli.get("bounds.x").setValue(pol.getBounds().getX()); + poli.get("bounds.y").setValue(pol.getBounds().getY()); + poli.get("bounds.width").setValue(pol.getBounds().getWidth()); + poli.get("bounds.height").setValue(pol.getBounds().getHeight()); + poli.get("npoints").setValue(pol.npoints); + Idea points = poli.get("points"); + for (int i=0;i allThings = new ArrayList(); + private double width; + private double height; + private WorldPoint dsLocation; + + public ResourcesGenerator(int timeframe, double envWidth, double envHeight, double xDS, double yDS) { + super("ResourcesGenerator"); + if (timeframe == 0) timeInMinutes = Constants.TIMEFRAME; + else timeInMinutes = timeframe; + width = envWidth; + height = envHeight; + dsLocation = new WorldPoint(xDS,yDS); //delivery spot + } + + public void run() { + while (true) { + try { + //System.out.println(".......ResourcesGenerator cycle running........."); + + //generate food + //perishable + generateFood(0); + //non-perishable + //generateFood(1); + ///generate jewels + for (int jewelType = 0; jewelType < 6; jewelType++) { + generateJewel(jewelType); + } + + //System.out.println("..............ResourcesGenerator SLEEPING........"); + //Thread.sleep(timeInMinutes * 60000); + Thread.sleep(timeInMinutes * 1000); + + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(-1); + } + + } + + } + + /** + * Knuth's algorithm to generate random Poisson distributed numbers + * @param lambda average rate of success in a Poisson distribution + * @return random number + */ + public static int getPoissonRandomNumber(double lambda) { + int k = 1; + double p = 1.0; + Random rd = new Random(); + + do { + k += 1; + p *= rd.nextDouble(); + } while (p > Math.exp((double) -lambda)); + return k - 1; + } + + private boolean checkAvailability(double cX, double cY) { + //discard the location of the DeliverySpot: + if((dsLocation.getX() == cX) && (dsLocation.getY() == cY)){ + return false; + } + + for (Thing each : allThings) { + if (each.secAreaContain(cX, cY)) { + return false; + } + + } + return true; + } + + private void generateFood(int type) { + try { + allThings = World.getWorldEntities(); + int number = 1; + Random rdX = new Random(); + Random rdY = new Random(); + double cX, cY; + String pointListStr = "" ; + + switch (type) { + //perishable + case 0: + number = getPoissonRandomNumber(Constants.pFoodLAMBDA); + break; + case 1: + //non-perishable + number = getPoissonRandomNumber(Constants.npFoodLAMBDA); + break; + } + for (int i = 0; i < number; i++) { + do { + cX = rdX.nextDouble() * width; + cY = rdY.nextDouble() * height; + + } while (!checkAvailability(cX, cY)); + + pointListStr = pointListStr+" "+cX+" "+cY; + } + World.createFoodInBatch(type, number, pointListStr); + } catch (CommandExecException ex) { + Logger.logException(ResourcesGenerator.class.getName(), ex); + } + + } + + private void generateJewel(int type) { + try { + allThings = World.getWorldEntities(); + int number = 1; + Random rdX = new Random(); + Random rdY = new Random(); + double cX, cY; + String pointListStr = "" ; + + switch (type) { + case 0: + number = getPoissonRandomNumber(Constants.redLAMBDA); + break; + case 1: + number = getPoissonRandomNumber(Constants.greenLAMBDA); + break; + case 2: + number = getPoissonRandomNumber(Constants.blueLAMBDA); + break; + case 3: + number = getPoissonRandomNumber(Constants.yellowLAMBDA); + break; + case 4: + number = getPoissonRandomNumber(Constants.magentaLAMBDA); + break; + case 5: + number = getPoissonRandomNumber(Constants.whiteLAMBDA); + break; + } + for (int i = 0; i < number; i++) { + do { + cX = rdX.nextDouble() * width; + cY = rdY.nextDouble() * height; + + } while (!checkAvailability(cX, cY)); + + pointListStr = pointListStr+" "+cX+" "+cY; + } + World.createJewelsInBatch(type, number, pointListStr); + } catch (CommandExecException ex) { + Logger.logException(ResourcesGenerator.class.getName(), ex); + } + + } +} diff --git a/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/support/WorldStateCustomView.java b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/support/WorldStateCustomView.java new file mode 100644 index 0000000..0425df7 --- /dev/null +++ b/0_ - DemoBehaviorNetwork/DemoBNProject/src/main/java/support/WorldStateCustomView.java @@ -0,0 +1,65 @@ +package support; + +import java.util.ArrayList; +import javax.swing.*; + +public class WorldStateCustomView extends JFrame { + + private JTextArea textArea; + + private ArrayList lastDifferentWorldState = new ArrayList(); + private ArrayList currentWorldState = new ArrayList(); + + + public WorldStateCustomView(String name) { + setTitle(name); + initComponents(); + } + + private void initComponents() { + textArea = new JTextArea(); + textArea.setFont(new java.awt.Font("Liberation Sans", 0, 16)); + textArea.setEditable(false); + textArea.setFocusable(false); + textArea.setOpaque(false); + + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + // Usando um JScrollPane para o caso do texto crescer + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setBorder(null); + scrollPane.setOpaque(false); + scrollPane.getViewport().setOpaque(false); + + getContentPane().add(scrollPane); + + setSize(300, 200); + setLocationRelativeTo(null); + } + + // Atualiza o texto inteiro baseado nos valores atuais + private void refreshText() { + StringBuilder sb = new StringBuilder(); + sb.append("Current World State\n"); + for(String state : currentWorldState) { + sb.append(state).append("\n"); + } + if(lastDifferentWorldState.size() > 0) { + sb.append("\nLast World State\n"); + for(String state : lastDifferentWorldState) { + sb.append(state).append("\n"); + } + } + textArea.setText(sb.toString()); + } + + public void updateCurrentWorldState(ArrayList value) { + this.currentWorldState = value; + refreshText(); + } + + public void updateLastDifferentWorldState(ArrayList value) { + this.lastDifferentWorldState = value; + refreshText(); + } +} diff --git a/0_ - DemoBehaviorNetwork/READ.ME b/0_ - DemoBehaviorNetwork/READ.ME new file mode 100644 index 0000000..e69de29 diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/.gitignore b/0_ - DemoBraitenbergVehicles/DemoBVProject/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/build.gradle b/0_ - DemoBraitenbergVehicles/DemoBVProject/build.gradle new file mode 100644 index 0000000..e50590f --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/build.gradle @@ -0,0 +1,33 @@ +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() + maven { url 'https://jitpack.io' } + maven { + url "https://github.com/rosjava/rosjava_mvn_repo/raw/master" + } + maven { + url "https://cst-group.github.io/cst-dependencies/maven-repo/" + } +} + +dependencies { + // Use JUnit test framework. + testImplementation 'junit:junit:4.13.2' + + // This dependency is used by the application. + //implementation 'com.github.CST-Group:cst:1.4.1' + //implementation 'com.github.CST-Group:cst-desktop:1.0.6' + implementation 'com.github.CST-Group:cst-desktop:1.1.0' + implementation group: 'org.zeromq', name: 'jeromq', version:'0.5.2' + implementation group: 'co.nstant.in', name: 'cbor', version:'0.9' +} + +application { + // Define the main class for the application. + mainClass = 'actionselection.Main' +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.jar b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.jar differ diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.properties b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d700973 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 12 13:14:19 BRT 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/gradlew b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/settings.gradle b/0_ - DemoBraitenbergVehicles/DemoBVProject/settings.gradle new file mode 100644 index 0000000..a3f19fd --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ActionSelection' diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/AgentMind.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/AgentMind.java new file mode 100644 index 0000000..14e8799 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/AgentMind.java @@ -0,0 +1,94 @@ +package actionselection; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.Mind; +import br.unicamp.cst.util.viewer.MindViewer; + +import actionselection.codelets.sensory.SimulatorConnectionCodelet; +import actionselection.codelets.sensory.LightSensorCodelet; +import actionselection.codelets.cognition.ActionSelectionCodelet; +import actionselection.codelets.motor.WheelActuatorCodelet; +import java.util.ArrayList; +import remoteapi.zmq.RemoteAPIObjects._sim; + +public class AgentMind extends Mind { + public ArrayList codelets = new ArrayList(); + + public AgentMind(_sim sim) { + super(); + + // Codelets Groups declarations + createCodeletGroup("Sensory"); + createCodeletGroup("Cognition"); + createCodeletGroup("Motor"); + + // Memory Groups declarations + createMemoryGroup("SensorInput"); + createMemoryGroup("Motor"); + createMemoryGroup("Global"); + + // Memory Objects + Memory stepMO; + Memory positionsMO; + Memory lightIntensityMO; + Memory wheelsVelocityMO; + Memory memoryThree; + + // Memories initialization + stepMO = createMemoryObject("StepMO"); + stepMO.setI(0); + registerMemory(stepMO, "SensorInput"); + positionsMO = createMemoryObject("positionsMO"); + registerMemory(positionsMO, "SensorInput"); + lightIntensityMO = createMemoryObject("lightIntensityMO"); + registerMemory(lightIntensityMO, "SensorInput"); + wheelsVelocityMO = createMemoryObject("wheelsVelocityMO"); + registerMemory(wheelsVelocityMO, "Motor"); + memoryThree = createMemoryObject("memoryThree"); + registerMemory(memoryThree, "Global"); + + // Codelets initializations + + Codelet simulatorConnectionCodelet = new SimulatorConnectionCodelet(sim); + simulatorConnectionCodelet.addInput(stepMO); + simulatorConnectionCodelet.addOutput(positionsMO); + simulatorConnectionCodelet.addBroadcast(memoryThree); + insertCodelet(simulatorConnectionCodelet); + registerCodelet(simulatorConnectionCodelet, "Sensory"); + codelets.add(simulatorConnectionCodelet); + + Codelet lightSensorCodelet = new LightSensorCodelet(); + lightSensorCodelet.addInput(positionsMO); + lightSensorCodelet.addOutput(lightIntensityMO); + lightSensorCodelet.addBroadcast(memoryThree); + insertCodelet(lightSensorCodelet); + registerCodelet(lightSensorCodelet, "Sensory"); + codelets.add(lightSensorCodelet); + + Codelet actionSelectionCodelet = new ActionSelectionCodelet(); + actionSelectionCodelet.addInput(lightIntensityMO); + actionSelectionCodelet.addOutput(wheelsVelocityMO); + actionSelectionCodelet.addBroadcast(memoryThree); + insertCodelet(actionSelectionCodelet); + registerCodelet(actionSelectionCodelet, "Cognition"); + codelets.add(actionSelectionCodelet); + + Codelet wheelActuatorCodelet = new WheelActuatorCodelet(sim); + wheelActuatorCodelet.addInput(wheelsVelocityMO); + wheelActuatorCodelet.addOutput(stepMO); + wheelActuatorCodelet.addBroadcast(memoryThree); + insertCodelet(wheelActuatorCodelet); + registerCodelet(wheelActuatorCodelet, "Motor"); + codelets.add(wheelActuatorCodelet); + + + lightSensorCodelet.setPublishSubscribe(true); + actionSelectionCodelet.setPublishSubscribe(true); + wheelActuatorCodelet.setPublishSubscribe(true); + simulatorConnectionCodelet.setTimeStep(200); + + + start(); + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/Main.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/Main.java new file mode 100644 index 0000000..3955aba --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/Main.java @@ -0,0 +1,16 @@ +package actionselection; + +import br.unicamp.cst.util.viewer.MindViewer; +import remoteapi.zmq.RemoteAPIClient; + +class Main { + + public static void main(String[] args){ + var client = new RemoteAPIClient(); + var sim = client.getObject().sim(); + AgentMind mind = new AgentMind(sim); + MindViewer mv = new MindViewer(mind,"MindViewer", mind.codelets); + mv.setVisible(true); + } + +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/cognition/ActionSelectionCodelet.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/cognition/ActionSelectionCodelet.java new file mode 100644 index 0000000..803dac7 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/cognition/ActionSelectionCodelet.java @@ -0,0 +1,70 @@ +package actionselection.codelets.cognition; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import java.util.Arrays; +import java.util.List; + +public class ActionSelectionCodelet extends Codelet { + + + private Memory LightIntensityMO; + private Memory WheelsVelocityMO; + + @Override + public void accessMemoryObjects() { + + LightIntensityMO = getInput("LightIntensityMO"); + + WheelsVelocityMO = getOutput("WheelsVelocityMO"); + } + + @Override + public void calculateActivation() { + + } + + @Override + public void proc() { + List intensityValues = (List) LightIntensityMO.getI(); + + Double intensityLeft = intensityValues.get(0); + Double intensityRight = intensityValues.get(1); +//cross, the more, the more - destroy +// double vLeft = calculateVelocity(intensityRight, true); +// double vRight = calculateVelocity(intensityLeft, true); + +//paralel, the more, the more - coward +// double vLeft = calculateVelocity(intensityLeft, true); +// double vRight = calculateVelocity(intensityRight, true); + +//cross, the more, the less - explorador +// double vLeft = calculate >Velocity(intensityRight, false); +// double vRight = calcula/teVelocity(intensityLeft, false); + +// paralel, the more, the less - love + double vLeft = calculateVelocity(intensityLeft, false); + double vRight = calculateVelocity(intensityRight, false); + List wheelsVelocity = Arrays.asList(vLeft, vRight); + WheelsVelocityMO.setI(wheelsVelocity); + } + + + public static Double calculateVelocity(Double lightIntensity, Boolean more){ + double minimumIntensity = 0.001061032954; + double maximumIntensity = 0.1; + + double minimumVelocity = 0; + double maximumVelocity = 5; + + // Interpolação linear para mapear intensidade da luz para a velocidade + double velocity = 0.0; + if (more == true) { + velocity = minimumVelocity + ((lightIntensity - minimumIntensity) / (maximumIntensity - minimumIntensity)) * (maximumVelocity - minimumVelocity); + } else { + velocity = maximumVelocity - ((lightIntensity - minimumIntensity) / (maximumIntensity - minimumIntensity)) * (maximumVelocity - minimumVelocity); + } + velocity = Math.max(minimumVelocity, Math.min(maximumVelocity, velocity)); + return velocity; + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/motor/WheelActuatorCodelet.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/motor/WheelActuatorCodelet.java new file mode 100644 index 0000000..b5f56cf --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/motor/WheelActuatorCodelet.java @@ -0,0 +1,67 @@ +package actionselection.codelets.motor; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import co.nstant.in.cbor.CborException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import remoteapi.zmq.RemoteAPIObjects._sim; + +public class WheelActuatorCodelet extends Codelet { + + + private Memory WheelsVelocityMO; + private Memory StepMO; + Long motorLeft; + Long motorRight; + _sim sim; + + public WheelActuatorCodelet(_sim sim) { + this.sim = sim; + try { + this.getMotor(); + } catch (CborException ex) { + Logger.getLogger(WheelActuatorCodelet.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void getMotor() throws CborException { + motorLeft = sim.getObject("/leftMotor"); + motorRight = sim.getObject("/rightMotor"); + } + + @Override + public void accessMemoryObjects() { + + WheelsVelocityMO = getInput("WheelsVelocityMO"); + + StepMO = getOutput("StepMO"); + } + + @Override + public void calculateActivation() { + + } + + @Override + public void proc() { + List wheelsVelocity = (List) WheelsVelocityMO.getI(); + Double vLeft = wheelsVelocity.get(0); + Double vRight = wheelsVelocity.get(1); + + try { + setWheelsVelocity(vLeft, vRight); + sim.step(); + } catch (CborException ex) { + Logger.getLogger(WheelActuatorCodelet.class.getName()).log(Level.SEVERE, null, ex); + } + Integer currentStep = (Integer) StepMO.getI(); + StepMO.setI(currentStep+1); + } + + private void setWheelsVelocity(Double vLeft, Double vRight) throws CborException { + sim.setJointTargetVelocity(motorLeft, vLeft); + sim.setJointTargetVelocity(motorRight,vRight); + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/LightSensorCodelet.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/LightSensorCodelet.java new file mode 100644 index 0000000..440a084 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/LightSensorCodelet.java @@ -0,0 +1,62 @@ +package actionselection.codelets.sensory; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import java.util.Arrays; +import java.util.List; + +public class LightSensorCodelet extends Codelet { + + + private Memory PositionsMO; + private Memory LightIntensityMO; + + @Override + public void accessMemoryObjects() { + + PositionsMO = getInput("PositionsMO"); + + LightIntensityMO = getOutput("LightIntensityMO"); + } + + @Override + public void calculateActivation() { + + } + + @Override + public void proc() { + + List> allPositions = (List>) PositionsMO.getI(); + + List lightPosition = allPositions.get(0); // lightPosition + List visionLeftSensorPosition = allPositions.get(1); // visionLeftSensorPosition + List visionRightSensorPosition = allPositions.get(2); // visionRightSensorPosition + + double distanceSensorLeftLight = calculateDistanceBetween(lightPosition, visionLeftSensorPosition); + double distanceSensorRightLight = calculateDistanceBetween(lightPosition, visionRightSensorPosition); + double intensityLeft = calculateLightIntensity(distanceSensorLeftLight); + double intensityRight = calculateLightIntensity(distanceSensorRightLight); + + List intensityValues; + intensityValues = Arrays.asList(intensityLeft, intensityRight); + LightIntensityMO.setI(intensityValues); + } + + + private static Double calculateDistanceBetween(List position1, List position2){ + double dx = position1.get(0) - position2.get(0); + double dy = position1.get(1) - position2.get(1); + double dz = position1.get(2) - position2.get(2); + double distance = Math.sqrt(dx * dx + dy * dy + dz * dz); + + return distance; + } + + public static Double calculateLightIntensity(Double distance){ + double potency = 1; + double lightIntensity = potency / (4 * Math.PI * Math.pow(distance, 2)); + + return lightIntensity; + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/SimulatorConnectionCodelet.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/SimulatorConnectionCodelet.java new file mode 100644 index 0000000..12dc552 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/actionselection/codelets/sensory/SimulatorConnectionCodelet.java @@ -0,0 +1,86 @@ +package actionselection.codelets.sensory; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException; +import co.nstant.in.cbor.CborException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import remoteapi.zmq.*; + +public class SimulatorConnectionCodelet extends Codelet { + + + private Memory StepMO; + private Memory PositionsMO; + RemoteAPIObjects._sim sim; + Long visionLeftSensorHandle; + Long visionRightSensorHandle; + Long lightHandle; + Integer lastStep = -1; + + public SimulatorConnectionCodelet(RemoteAPIObjects._sim sim){ + this.sim = sim; + try { + this.configSimulator(); + } catch (IOException ex) { + Logger.getLogger(SimulatorConnectionCodelet.class.getName()).log(Level.SEVERE, null, ex); + } catch (CborException ex) { + Logger.getLogger(SimulatorConnectionCodelet.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void configSimulator() throws java.io.IOException, co.nstant.in.cbor.CborException { + visionLeftSensorHandle = sim.getObject("./Vision_sensor_left"); + visionRightSensorHandle = sim.getObject("./Vision_sensor_right"); + lightHandle = sim.getObject("/O_Light"); + sim.setStepping(true); + sim.startSimulation(); + } + + @Override + public void accessMemoryObjects() { + + StepMO = getInput("StepMO"); + + PositionsMO = getOutput("PositionsMO"); + } + + @Override + public void calculateActivation() { + Integer currentStep = (Integer) StepMO.getI(); + + try { + if (currentStep > this.lastStep) { + setActivation(1); + } else { + setActivation(0); + } + } catch (CodeletActivationBoundsException e) { + e.printStackTrace(); + } + } + + @Override + public void proc() { + try { + this.getData(); + } catch (IOException ex) { + Logger.getLogger(SimulatorConnectionCodelet.class.getName()).log(Level.SEVERE, null, ex); + } catch (CborException ex) { + Logger.getLogger(SimulatorConnectionCodelet.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void getData() throws java.io.IOException, co.nstant.in.cbor.CborException { + List lightPosition = sim.getObjectPosition(lightHandle, sim.handle_world); + List visionLeftSensorPosition = sim.getObjectPosition(visionLeftSensorHandle, sim.handle_world); + List visionRightSensorPosition = sim.getObjectPosition(visionRightSensorHandle, sim.handle_world); + + List> allPositions = Arrays.asList(lightPosition, visionLeftSensorPosition, visionRightSensorPosition); + PositionsMO.setI(allPositions); + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIClient.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIClient.java new file mode 100644 index 0000000..e5c7d59 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIClient.java @@ -0,0 +1,457 @@ +package remoteapi.zmq; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.UUID; +import java.util.function.Function; + +import java.math.BigInteger; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.IOException; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import co.nstant.in.cbor.*; +import co.nstant.in.cbor.model.DataItem; + +import org.zeromq.*; + +public class RemoteAPIClient +{ + public RemoteAPIClient() + { + this("localhost", -1); + } + + public RemoteAPIClient(String host, int rpcPort) + { + this(host, rpcPort, -1); + } + + public RemoteAPIClient(String host, int rpcPort, int cntPort) + { + this(host, rpcPort, cntPort, -1); + } + + public RemoteAPIClient(String host, int rpcPort, int cntPort, int verbose) + { + if(rpcPort == -1) rpcPort = 23000; + + this.verbose = verbose; + if(this.verbose == -1) + { + String verboseStr = System.getenv("VERBOSE"); + if(verboseStr != null) + this.verbose = Integer.parseInt(verboseStr); + else + this.verbose = 0; + } + + this.context = new ZContext(1); + + this.rpcSocket = context.createSocket(SocketType.REQ); + this.rpcSocket.connect(String.format("tcp://%s:%d", host, rpcPort)); + + this.uuid = UUID.randomUUID().toString(); + } + + public void close() throws CborException + { + DataItem k_func = convertArg("func"), + k_args = convertArg("args"), + k_err = convertArg("err"), + k_uuid = convertArg("uuid"), + k_ver = convertArg("ver"), + k_lang = convertArg("lang"), + k_ret = convertArg("ret"), + k_argsl = convertArg("argsL"); + + co.nstant.in.cbor.model.Map req = new co.nstant.in.cbor.model.Map(); + req.put(k_func, convertArg("_*end*_")); + req.put(k_args, new co.nstant.in.cbor.model.Array()); + req.put(k_uuid, convertArg(this.uuid)); + req.put(k_ver, convertArg(this.VERSION)); + this.send(req); + this.recv(); + this.rpcSocket.close(); + this.context.close(); + } + + protected void send(DataItem req) throws CborException + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + new CborEncoder(baos).encode(req); + byte[] data = baos.toByteArray(); + + if(this.verbose >= 3) + System.out.println("Sending (raw): " + dump(data, verbose >= 4 ? -1 : 16)); + + this.rpcSocket.send(data); + } + + protected DataItem recv() throws CborException + { + byte[] data = this.rpcSocket.recv(0); + + if(this.verbose >= 3) + System.out.println("Received (raw): " + dump(data, verbose >= 4 ? -1 : 16)); + + ByteArrayInputStream bais = new ByteArrayInputStream(data); + List dataItems = new CborDecoder(bais).decode(); + return dataItems.get(0); + } + + public String dump(byte[] data, int limit) + { + if(limit < 0) + limit = Integer.MAX_VALUE; + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < Math.min(limit, data.length); i++) + sb.append(String.format("%02X ", data[i])); + if(data.length > limit) + sb.append(String.format("(%d more)", data.length - limit)); + return sb.toString(); + } + + public List callCbor(String func, List args) throws CborException + { + DataItem k_func = convertArg("func"), + k_args = convertArg("args"), + k_err = convertArg("err"), + k_uuid = convertArg("uuid"), + k_ver = convertArg("ver"), + k_lang = convertArg("lang"), + k_ret = convertArg("ret"), + k_argsl = convertArg("argsL"); + + co.nstant.in.cbor.model.Map req = new co.nstant.in.cbor.model.Map(); + req.put(k_func, convertArg(func)); + co.nstant.in.cbor.model.Array v_args = new co.nstant.in.cbor.model.Array(); + for(int i = 0; i < args.size(); i++) + v_args.add(args.get(i)); + req.put(k_args, v_args); + req.put(k_uuid, convertArg(this.uuid)); + req.put(k_ver, convertArg(this.VERSION)); + req.put(k_argsl, convertArg(args.size())); + req.put(k_lang, convertArg("java")); + if(this.verbose >= 1) + System.out.println("Sending: " + req.toString()); + this.send(req); + + co.nstant.in.cbor.model.Map rep = (co.nstant.in.cbor.model.Map)this.recv(); + if(this.verbose >= 1) + System.out.println("Received: " + rep.toString()); + + while(rep.getKeys().contains(k_func)) + { + // Check if the function name is "_*wait*_", in which case we just wait + List callbackResults = new ArrayList(); + co.nstant.in.cbor.model.UnicodeString respFunc = (co.nstant.in.cbor.model.UnicodeString)rep.get(k_func); + // _*repeat*_ not yet implemented! + if(respFunc != null && !"_*wait*_".equals(respFunc.getString())) + { + List callbackArgs = ((co.nstant.in.cbor.model.Array)rep.get(k_args)).getDataItems(); + + callbackResults = executeCallback(respFunc.getString(), callbackArgs); + } + + co.nstant.in.cbor.model.Map req2 = new co.nstant.in.cbor.model.Map(); + req2.put(k_func, convertArg("_*executed*_")); + co.nstant.in.cbor.model.Array v_args1 = new co.nstant.in.cbor.model.Array(); + for(int i = 0; i < callbackResults.size(); i++) + v_args1.add(callbackResults.get(i)); + req2.put(k_args, v_args1); + req2.put(k_uuid, convertArg(this.uuid)); + req2.put(k_lang, convertArg("java")); + req2.put(k_ver, convertArg(this.VERSION)); + req2.put(k_argsl, convertArg(callbackResults.size())); + if(this.verbose >= 1) + System.out.println("Sending: " + req2.toString()); + this.send(req2); + + rep = (co.nstant.in.cbor.model.Map)this.recv(); + if(this.verbose >= 1) + System.out.println("Received: " + rep.toString()); + } + + if(rep.getKeys().contains(k_err)) + { + DataItem error = rep.get(k_err); + throw new RuntimeException(error != null ? toString(error) : "Unknown error"); + } + + DataItem ret = rep.get(k_ret); + // XXX: empty 'ret' comes in as a Map + if(ret instanceof co.nstant.in.cbor.model.Map) + return java.util.Collections.emptyList(); + return ((co.nstant.in.cbor.model.Array)ret).getDataItems(); + + } + + public void registerCallback(String funcName, Function callback) + { + if(callbacks.containsKey(funcName)) + throw new RuntimeException("A callback is already registered for function: " + funcName); + callbacks.put(funcName, callback); + } + + private List executeCallback(String funcName, List args) + { + if(callbacks.containsKey(funcName)) + { + Function callback = callbacks.get(funcName); + return convertArgs(callback.apply(toObjects(args).toArray())); + } + else + return new ArrayList(); // we cannot raise an error: e.g. a custom UI async callback cannot be assigned to a specific client + } + + public DataItem convertArg(Boolean arg) + { + return convertArg(arg.booleanValue()); + } + + public DataItem convertArg(String arg) + { + return new co.nstant.in.cbor.model.UnicodeString(arg); + } + + public DataItem convertArg(Integer arg) + { + return convertArg(arg.longValue()); + } + + public DataItem convertArg(Long arg) + { + return convertArg(arg.longValue()); + } + + public DataItem convertArg(Float arg) + { + return convertArg(arg.floatValue()); + } + + public DataItem convertArg(Double arg) + { + return convertArg(arg.doubleValue()); + } + + public DataItem convertArg(BigInteger arg) + { + if(arg.compareTo(BigInteger.ZERO) < 0) + return new co.nstant.in.cbor.model.NegativeInteger(arg); + else + return new co.nstant.in.cbor.model.UnsignedInteger(arg); + } + + public DataItem convertArg(Map arg) + { + throw new RuntimeException("unsupported conversion"); + } + + public DataItem convertArg(List arg) + { + co.nstant.in.cbor.model.Array array = new co.nstant.in.cbor.model.Array(); + for(Object arg1 : arg) + array.add(convertArg(arg1)); + return array; + } + + public DataItem convertArg(boolean arg) + { + if(arg) return co.nstant.in.cbor.model.SimpleValue.TRUE; + else return co.nstant.in.cbor.model.SimpleValue.FALSE; + } + + public DataItem convertArg(long arg) + { + if(arg < 0) + return new co.nstant.in.cbor.model.NegativeInteger(arg); + else + return new co.nstant.in.cbor.model.UnsignedInteger(arg); + } + + public DataItem convertArg(float arg) + { + return new co.nstant.in.cbor.model.SinglePrecisionFloat(arg); + } + + public DataItem convertArg(double arg) + { + return new co.nstant.in.cbor.model.DoublePrecisionFloat(arg); + } + + public DataItem convertArg(byte[] arg) + { + return new co.nstant.in.cbor.model.ByteString(arg); + } + + public DataItem convertArg(Object arg) + { + if(arg instanceof Boolean) + return convertArg((Boolean)arg); + if(arg instanceof String) + return convertArg((String)arg); + if(arg instanceof Integer) + return convertArg((Integer)arg); + if(arg instanceof Long) + return convertArg((Long)arg); + if(arg instanceof Float) + return convertArg((Float)arg); + if(arg instanceof Double) + return convertArg((Double)arg); + if(arg instanceof BigInteger) + return convertArg((BigInteger)arg); + if(arg instanceof List) + return convertArg((List)arg); + if(arg instanceof Map) + return convertArg((Map)arg); + if(arg.getClass().isArray()) + return convertArg((byte[])arg); + return null; + } + + public void convertArgs(List outArgs, Object[] inArgs) + { + for(int i = 0; i < inArgs.length; i++) + outArgs.add(convertArg(inArgs[i])); + } + + public List convertArgs(Object[] inArgs) + { + List outArgs = new ArrayList(); + for(int i = 0; i < inArgs.length; i++) + outArgs.add(convertArg(inArgs[i])); + return outArgs; + } + + public Boolean toBoolean(DataItem item) + { + co.nstant.in.cbor.model.SimpleValue v = (co.nstant.in.cbor.model.SimpleValue)item; + co.nstant.in.cbor.model.SimpleValueType t = v.getSimpleValueType(); + if(t == co.nstant.in.cbor.model.SimpleValueType.TRUE) return Boolean.TRUE; + if(t == co.nstant.in.cbor.model.SimpleValueType.FALSE) return Boolean.FALSE; + return null; + } + + public BigInteger toBigInteger(DataItem item) + { + return ((co.nstant.in.cbor.model.Number)item).getValue(); + } + + public int toInt(DataItem item) + { + return toBigInteger(item).intValue(); + } + + public long toLong(DataItem item) + { + return toBigInteger(item).longValue(); + } + + public double toFloat(DataItem item) + { + return ((co.nstant.in.cbor.model.AbstractFloat)item).getValue(); + } + + public double toDouble(DataItem item) + { + return ((co.nstant.in.cbor.model.DoublePrecisionFloat)item).getValue(); + } + + public String toString(DataItem item) + { + return ((co.nstant.in.cbor.model.UnicodeString)item).getString(); + } + + public byte[] toBytes(DataItem item) + { + return ((co.nstant.in.cbor.model.ByteString)item).getBytes(); + } + + public Map toMap(DataItem item) + { + co.nstant.in.cbor.model.Map m = (co.nstant.in.cbor.model.Map)item; + Map ret = new HashMap(); + for(DataItem k : m.getKeys()) + ret.put(toObject(k), toObject(m.get(k))); + return ret; + } + + public Object toObject(DataItem item) + { + if(item instanceof co.nstant.in.cbor.model.SimpleValue) { + Boolean b = toBoolean(item); + if(b != null) return b; + } + if(item instanceof co.nstant.in.cbor.model.ByteString) + return toBytes(item); + if(item instanceof co.nstant.in.cbor.model.AbstractFloat) + return toFloat(item); + if(item instanceof co.nstant.in.cbor.model.DoublePrecisionFloat) + return toDouble(item); + if(item instanceof co.nstant.in.cbor.model.UnicodeString) + return toString(item); + if(item instanceof co.nstant.in.cbor.model.Number) + return Long.valueOf(toLong(item)); + if(item instanceof co.nstant.in.cbor.model.Array) + return toObjects(((co.nstant.in.cbor.model.Array)item).getDataItems()); + if(item instanceof co.nstant.in.cbor.model.Map) + return toMap(item); + return null; + } + + public List toObjects(List items) + { + List ret = new ArrayList(); + for(DataItem item : items) + ret.add(toObject(item)); + return ret; + } + + public Object[] call(String func, Object[] args) throws CborException + { + return toObjects(callCbor(func, convertArgs(args))).toArray(); + } + + public void setStepping() throws CborException + { + setStepping(true); + } + + public void setStepping(Boolean enable) throws CborException + { + call("sim.setStepping", new Object[]{enable}); + } + + public void step() throws IOException, CborException + { + step(true); + } + + public void step(Boolean wait) throws IOException, CborException + { + call("sim.step", new Object[]{wait}); + } + + public RemoteAPIObjects getObject() + { + if(objs == null) + objs = new RemoteAPIObjects(this); + return objs; + } + + private Map> callbacks = new HashMap<>(); + private int verbose = -1; + ZContext context; + ZMQ.Socket rpcSocket; + String uuid; + int VERSION = 2; + RemoteAPIObjects objs = null; +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObject.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObject.java new file mode 100644 index 0000000..067757d --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObject.java @@ -0,0 +1,11 @@ +package remoteapi.zmq; + +public class RemoteAPIObject +{ + protected final RemoteAPIClient client; + + public RemoteAPIObject(RemoteAPIClient client) + { + this.client = client; + } +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObjects.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObjects.java new file mode 100644 index 0000000..703b3c6 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/RemoteAPIObjects.java @@ -0,0 +1,3813 @@ +package remoteapi.zmq; + +import java.util.*; + +import co.nstant.in.cbor.*; + +public class RemoteAPIObjects +{ + private final RemoteAPIClient client; + + public RemoteAPIObjects(RemoteAPIClient client) + { + this.client = client; + } + + public class _sim extends remoteapi.zmq.objects.special._sim + { + public _sim(RemoteAPIClient client) + { + super(client); + } + + public void acquireLock(Object... args) throws CborException + { + this.client.call("sim.acquireLock", args); + } + + public Long addDrawingObject(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addDrawingObject", args); + return ((Long)rets[0]); + } + + public Long addDrawingObjectItem(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addDrawingObjectItem", args); + return ((Long)rets[0]); + } + + public void addForce(Object... args) throws CborException + { + this.client.call("sim.addForce", args); + } + + public void addForceAndTorque(Object... args) throws CborException + { + this.client.call("sim.addForceAndTorque", args); + } + + public Long addGraphCurve(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addGraphCurve", args); + return ((Long)rets[0]); + } + + public Long addGraphStream(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addGraphStream", args); + return ((Long)rets[0]); + } + + public void addItemToCollection(Object... args) throws CborException + { + this.client.call("sim.addItemToCollection", args); + } + + public void addLog(Object... args) throws CborException + { + this.client.call("sim.addLog", args); + } + + public Long addParticleObject(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addParticleObject", args); + return ((Long)rets[0]); + } + + public void addParticleObjectItem(Object... args) throws CborException + { + this.client.call("sim.addParticleObjectItem", args); + } + + public void addReferencedHandle(Object... args) throws CborException + { + this.client.call("sim.addReferencedHandle", args); + } + + public Long addScript(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.addScript", args); + return ((Long)rets[0]); + } + + public Long adjustView(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.adjustView", args); + return ((Long)rets[0]); + } + + public Long alignShapeBB(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.alignShapeBB", args); + return ((Long)rets[0]); + } + + public Object[] alphaBetaGammaToYawPitchRoll(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.alphaBetaGammaToYawPitchRoll", args); + return rets; + } + + public Long announceSceneContentChange(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.announceSceneContentChange", args); + return ((Long)rets[0]); + } + + public void associateScriptWithObject(Object... args) throws CborException + { + this.client.call("sim.associateScriptWithObject", args); + } + + public Long auxiliaryConsoleClose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.auxiliaryConsoleClose", args); + return ((Long)rets[0]); + } + + public Long auxiliaryConsoleOpen(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.auxiliaryConsoleOpen", args); + return ((Long)rets[0]); + } + + public Long auxiliaryConsolePrint(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.auxiliaryConsolePrint", args); + return ((Long)rets[0]); + } + + public Long auxiliaryConsoleShow(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.auxiliaryConsoleShow", args); + return ((Long)rets[0]); + } + + public void broadcastMsg(Object... args) throws CborException + { + this.client.call("sim.broadcastMsg", args); + } + + public List buildIdentityMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.buildIdentityMatrix", args); + return ((List)rets[0]); + } + + public List buildMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.buildMatrix", args); + return ((List)rets[0]); + } + + public List buildMatrixQ(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.buildMatrixQ", args); + return ((List)rets[0]); + } + + public List buildPose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.buildPose", args); + return ((List)rets[0]); + } + + public Long cameraFitToView(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.cameraFitToView", args); + return ((Long)rets[0]); + } + + public List> changeEntityColor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.changeEntityColor", args); + return ((List>)rets[0]); + } + + public Object[] checkCollision(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkCollision", args); + return rets; + } + + public Object[] checkCollisionEx(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkCollisionEx", args); + return rets; + } + + public Object[] checkDistance(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkDistance", args); + return rets; + } + + public Object[] checkOctreePointOccupancy(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkOctreePointOccupancy", args); + return rets; + } + + public Object[] checkProximitySensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkProximitySensor", args); + return rets; + } + + public Object[] checkProximitySensorEx(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkProximitySensorEx", args); + return rets; + } + + public Object[] checkProximitySensorEx2(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkProximitySensorEx2", args); + return rets; + } + + public Object[] checkVisionSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkVisionSensor", args); + return rets; + } + + public List checkVisionSensorEx(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.checkVisionSensorEx", args); + return ((List)rets[0]); + } + + public void clearFloatSignal(Object... args) throws CborException + { + this.client.call("sim.clearFloatSignal", args); + } + + public void clearInt32Signal(Object... args) throws CborException + { + this.client.call("sim.clearInt32Signal", args); + } + + public void clearStringSignal(Object... args) throws CborException + { + this.client.call("sim.clearStringSignal", args); + } + + public Long closeScene(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.closeScene", args); + return ((Long)rets[0]); + } + + public byte[] combineRgbImages(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.combineRgbImages", args); + return ((byte[])rets[0]); + } + + public Long computeMassAndInertia(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.computeMassAndInertia", args); + return ((Long)rets[0]); + } + + public Long convexDecompose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.convexDecompose", args); + return ((Long)rets[0]); + } + + public List copyPasteObjects(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.copyPasteObjects", args); + return ((List)rets[0]); + } + + public List copyTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.copyTable", args); + return ((List)rets[0]); + } + + public Long createCollection(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createCollection", args); + return ((Long)rets[0]); + } + + public Long createDummy(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createDummy", args); + return ((Long)rets[0]); + } + + public Long createForceSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createForceSensor", args); + return ((Long)rets[0]); + } + + public Long createHeightfieldShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createHeightfieldShape", args); + return ((Long)rets[0]); + } + + public Long createJoint(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createJoint", args); + return ((Long)rets[0]); + } + + public Long createOctree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createOctree", args); + return ((Long)rets[0]); + } + + public Long createPath(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createPath", args); + return ((Long)rets[0]); + } + + public Long createPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createPointCloud", args); + return ((Long)rets[0]); + } + + public Long createPrimitiveShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createPrimitiveShape", args); + return ((Long)rets[0]); + } + + public Long createProximitySensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createProximitySensor", args); + return ((Long)rets[0]); + } + + public Long createShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createShape", args); + return ((Long)rets[0]); + } + + public Object[] createTexture(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createTexture", args); + return rets; + } + + public Long createVisionSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.createVisionSensor", args); + return ((Long)rets[0]); + } + + public void destroyCollection(Object... args) throws CborException + { + this.client.call("sim.destroyCollection", args); + } + + public void destroyGraphCurve(Object... args) throws CborException + { + this.client.call("sim.destroyGraphCurve", args); + } + + public Long duplicateGraphCurveToStatic(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.duplicateGraphCurveToStatic", args); + return ((Long)rets[0]); + } + + public Object[] executeScriptString(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.executeScriptString", args); + return rets; + } + + public void exportMesh(Object... args) throws CborException + { + this.client.call("sim.exportMesh", args); + } + + public Long floatingViewAdd(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.floatingViewAdd", args); + return ((Long)rets[0]); + } + + public Long floatingViewRemove(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.floatingViewRemove", args); + return ((Long)rets[0]); + } + + public Long generateShapeFromPath(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.generateShapeFromPath", args); + return ((Long)rets[0]); + } + + public Long generateTextShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.generateTextShape", args); + return ((Long)rets[0]); + } + + public Object[] generateTimeOptimalTrajectory(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.generateTimeOptimalTrajectory", args); + return rets; + } + + public List getAlternateConfigs(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getAlternateConfigs", args); + return ((List)rets[0]); + } + + public List getApiFunc(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getApiFunc", args); + return ((List)rets[0]); + } + + public String getApiInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getApiInfo", args); + return ((String)rets[0]); + } + + public List getArrayParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getArrayParam", args); + return ((List)rets[0]); + } + + public Double getAutoYieldDelay(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getAutoYieldDelay", args); + return ((Double)rets[0]); + } + + public Boolean getBoolParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getBoolParam", args); + return ((Boolean)rets[0]); + } + + public Double getClosestPosOnPath(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getClosestPosOnPath", args); + return ((Double)rets[0]); + } + + public List getCollectionObjects(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getCollectionObjects", args); + return ((List)rets[0]); + } + + public Double getConfigDistance(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getConfigDistance", args); + return ((Double)rets[0]); + } + + public Object[] getContactInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getContactInfo", args); + return rets; + } + + public Object[] getDecimatedMesh(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getDecimatedMesh", args); + return rets; + } + + public Boolean getEngineBoolParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getEngineBoolParam", args); + return ((Boolean)rets[0]); + } + + public Double getEngineFloatParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getEngineFloatParam", args); + return ((Double)rets[0]); + } + + public Long getEngineInt32Param(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getEngineInt32Param", args); + return ((Long)rets[0]); + } + + public List getEulerAnglesFromMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getEulerAnglesFromMatrix", args); + return ((List)rets[0]); + } + + public Long getExplicitHandling(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getExplicitHandling", args); + return ((Long)rets[0]); + } + + public String getExtensionString(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getExtensionString", args); + return ((String)rets[0]); + } + + public Double getFloatParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getFloatParam", args); + return ((Double)rets[0]); + } + + public Double getFloatSignal(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getFloatSignal", args); + return ((Double)rets[0]); + } + + public List> getGenesisEvents(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getGenesisEvents", args); + return ((List>)rets[0]); + } + + public Object[] getGraphCurve(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getGraphCurve", args); + return rets; + } + + public Object[] getGraphInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getGraphInfo", args); + return rets; + } + + public Long getInt32Param(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getInt32Param", args); + return ((Long)rets[0]); + } + + public Long getInt32Signal(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getInt32Signal", args); + return ((Long)rets[0]); + } + + public Long getIsRealTimeSimulation(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getIsRealTimeSimulation", args); + return ((Long)rets[0]); + } + + public Object[] getJointDependency(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointDependency", args); + return rets; + } + + public Double getJointForce(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointForce", args); + return ((Double)rets[0]); + } + + public Object[] getJointInterval(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointInterval", args); + return rets; + } + + public Object[] getJointMode(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointMode", args); + return rets; + } + + public Double getJointPosition(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointPosition", args); + return ((Double)rets[0]); + } + + public Double getJointTargetForce(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointTargetForce", args); + return ((Double)rets[0]); + } + + public Double getJointTargetPosition(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointTargetPosition", args); + return ((Double)rets[0]); + } + + public Double getJointTargetVelocity(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointTargetVelocity", args); + return ((Double)rets[0]); + } + + public Long getJointType(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointType", args); + return ((Long)rets[0]); + } + + public Double getJointVelocity(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getJointVelocity", args); + return ((Double)rets[0]); + } + + public String getLastInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getLastInfo", args); + return ((String)rets[0]); + } + + public Object[] getLightParameters(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getLightParameters", args); + return rets; + } + + public Long getLinkDummy(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getLinkDummy", args); + return ((Long)rets[0]); + } + + public List getMatchingPersistentDataTags(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getMatchingPersistentDataTags", args); + return ((List)rets[0]); + } + + public List getMatrixInverse(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getMatrixInverse", args); + return ((List)rets[0]); + } + + public Long getModelProperty(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getModelProperty", args); + return ((Long)rets[0]); + } + + public Boolean getNamedBoolParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getNamedBoolParam", args); + return ((Boolean)rets[0]); + } + + public Double getNamedFloatParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getNamedFloatParam", args); + return ((Double)rets[0]); + } + + public Long getNamedInt32Param(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getNamedInt32Param", args); + return ((Long)rets[0]); + } + + public byte[] getNamedStringParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getNamedStringParam", args); + return ((byte[])rets[0]); + } + + public Long getNavigationMode(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getNavigationMode", args); + return ((Long)rets[0]); + } + + public Long getObject(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObject", args); + return ((Long)rets[0]); + } + + public String getObjectAlias(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectAlias", args); + return ((String)rets[0]); + } + + public String getObjectAliasRelative(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectAliasRelative", args); + return ((String)rets[0]); + } + + public Long getObjectChild(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectChild", args); + return ((Long)rets[0]); + } + + public List getObjectChildPose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectChildPose", args); + return ((List)rets[0]); + } + + public List getObjectColor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectColor", args); + return ((List)rets[0]); + } + + public List getObjectFloatArrayParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectFloatArrayParam", args); + return ((List)rets[0]); + } + + public Double getObjectFloatParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectFloatParam", args); + return ((Double)rets[0]); + } + + public void getObjectFromUid(Object... args) throws CborException + { + this.client.call("sim.getObjectFromUid", args); + } + + public Long getObjectInt32Param(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectInt32Param", args); + return ((Long)rets[0]); + } + + public List getObjectMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectMatrix", args); + return ((List)rets[0]); + } + + public List getObjectOrientation(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectOrientation", args); + return ((List)rets[0]); + } + + public Long getObjectParent(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectParent", args); + return ((Long)rets[0]); + } + + public List getObjectPose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectPose", args); + return ((List)rets[0]); + } + + public List getObjectPosition(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectPosition", args); + return ((List)rets[0]); + } + + public Long getObjectProperty(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectProperty", args); + return ((Long)rets[0]); + } + + public List getObjectQuaternion(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectQuaternion", args); + return ((List)rets[0]); + } + + public List getObjectSel(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectSel", args); + return ((List)rets[0]); + } + + public Double getObjectSizeFactor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectSizeFactor", args); + return ((Double)rets[0]); + } + + public Long getObjectSpecialProperty(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectSpecialProperty", args); + return ((Long)rets[0]); + } + + public byte[] getObjectStringParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectStringParam", args); + return ((byte[])rets[0]); + } + + public Long getObjectType(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectType", args); + return ((Long)rets[0]); + } + + public Long getObjectUid(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectUid", args); + return ((Long)rets[0]); + } + + public Object[] getObjectVelocity(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectVelocity", args); + return rets; + } + + public Long getObjects(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjects", args); + return ((Long)rets[0]); + } + + public List getObjectsInTree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getObjectsInTree", args); + return ((List)rets[0]); + } + + public List getOctreeVoxels(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getOctreeVoxels", args); + return ((List)rets[0]); + } + + public Long getPage(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPage", args); + return ((Long)rets[0]); + } + + public List getPathInterpolatedConfig(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPathInterpolatedConfig", args); + return ((List)rets[0]); + } + + public Object[] getPathLengths(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPathLengths", args); + return rets; + } + + public List getPersistentDataTags(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPersistentDataTags", args); + return ((List)rets[0]); + } + + public String getPluginInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPluginInfo", args); + return ((String)rets[0]); + } + + public String getPluginName(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPluginName", args); + return ((String)rets[0]); + } + + public Object[] getPointCloudOptions(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPointCloudOptions", args); + return rets; + } + + public List getPointCloudPoints(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPointCloudPoints", args); + return ((List)rets[0]); + } + + public List getPoseInverse(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getPoseInverse", args); + return ((List)rets[0]); + } + + public Object[] getQHull(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getQHull", args); + return rets; + } + + public List getQuaternionFromMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getQuaternionFromMatrix", args); + return ((List)rets[0]); + } + + public Double getRandom(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getRandom", args); + return ((Double)rets[0]); + } + + public Boolean getRealTimeSimulation(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getRealTimeSimulation", args); + return ((Boolean)rets[0]); + } + + public List getReferencedHandles(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getReferencedHandles", args); + return ((List)rets[0]); + } + + public Object[] getRotationAxis(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getRotationAxis", args); + return rets; + } + + public Object[] getScaledImage(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getScaledImage", args); + return rets; + } + + public Long getScript(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getScript", args); + return ((Long)rets[0]); + } + + public Map getScriptFunctions(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getScriptFunctions", args); + return ((Map)rets[0]); + } + + public Long getScriptInt32Param(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getScriptInt32Param", args); + return ((Long)rets[0]); + } + + public byte[] getScriptStringParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getScriptStringParam", args); + return ((byte[])rets[0]); + } + + public Boolean getSettingBool(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSettingBool", args); + return ((Boolean)rets[0]); + } + + public Double getSettingFloat(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSettingFloat", args); + return ((Double)rets[0]); + } + + public Long getSettingInt32(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSettingInt32", args); + return ((Long)rets[0]); + } + + public String getSettingString(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSettingString", args); + return ((String)rets[0]); + } + + public List getShapeBB(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeBB", args); + return ((List)rets[0]); + } + + public Object[] getShapeColor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeColor", args); + return rets; + } + + public Object[] getShapeGeomInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeGeomInfo", args); + return rets; + } + + public Object[] getShapeInertia(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeInertia", args); + return rets; + } + + public Double getShapeMassAndInertia(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeMassAndInertia", args); + return ((Double)rets[0]); + } + + public Object[] getShapeMesh(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeMesh", args); + return rets; + } + + public Long getShapeTextureId(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeTextureId", args); + return ((Long)rets[0]); + } + + public Map getShapeViz(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getShapeViz", args); + return ((Map)rets[0]); + } + + public String getSignalName(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSignalName", args); + return ((String)rets[0]); + } + + public Long getSimulationState(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSimulationState", args); + return ((Long)rets[0]); + } + + public Boolean getSimulationStopping(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSimulationStopping", args); + return ((Boolean)rets[0]); + } + + public Double getSimulationTime(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSimulationTime", args); + return ((Double)rets[0]); + } + + public Double getSimulationTimeStep(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSimulationTimeStep", args); + return ((Double)rets[0]); + } + + public Object[] getSimulatorMessage(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSimulatorMessage", args); + return rets; + } + + public String getStackTraceback(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getStackTraceback", args); + return ((String)rets[0]); + } + + public String getStringParam(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getStringParam", args); + return ((String)rets[0]); + } + + public byte[] getStringSignal(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getStringSignal", args); + return ((byte[])rets[0]); + } + + public Double getSystemTime(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getSystemTime", args); + return ((Double)rets[0]); + } + + public Object[] getTextureId(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getTextureId", args); + return rets; + } + + public Long getThreadId(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getThreadId", args); + return ((Long)rets[0]); + } + + public List getUserVariables(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getUserVariables", args); + return ((List)rets[0]); + } + + public Object[] getVelocity(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getVelocity", args); + return rets; + } + + public Object[] getVisionSensorDepth(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getVisionSensorDepth", args); + return rets; + } + + public Object[] getVisionSensorImg(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.getVisionSensorImg", args); + return rets; + } + + public void getVisionSensorRes(Object... args) throws CborException + { + this.client.call("sim.getVisionSensorRes", args); + } + + public Long groupShapes(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.groupShapes", args); + return ((Long)rets[0]); + } + + public Long handleAddOnScripts(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleAddOnScripts", args); + return ((Long)rets[0]); + } + + public Long handleChildScripts(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleChildScripts", args); + return ((Long)rets[0]); + } + + public Long handleDynamics(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleDynamics", args); + return ((Long)rets[0]); + } + + public Long handleEmbeddedScripts(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleEmbeddedScripts", args); + return ((Long)rets[0]); + } + + public void handleExtCalls(Object... args) throws CborException + { + this.client.call("sim.handleExtCalls", args); + } + + public void handleGraph(Object... args) throws CborException + { + this.client.call("sim.handleGraph", args); + } + + public void handleJointMotion(Object... args) throws CborException + { + this.client.call("sim.handleJointMotion", args); + } + + public Object[] handleProximitySensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleProximitySensor", args); + return rets; + } + + public void handleSandboxScript(Object... args) throws CborException + { + this.client.call("sim.handleSandboxScript", args); + } + + public void handleSensingStart(Object... args) throws CborException + { + this.client.call("sim.handleSensingStart", args); + } + + public void handleSimulationStart(Object... args) throws CborException + { + this.client.call("sim.handleSimulationStart", args); + } + + public Object[] handleVisionSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.handleVisionSensor", args); + return rets; + } + + public Object[] importMesh(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.importMesh", args); + return rets; + } + + public Long importShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.importShape", args); + return ((Long)rets[0]); + } + + public void initScript(Object... args) throws CborException + { + this.client.call("sim.initScript", args); + } + + public Long insertObjectIntoOctree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.insertObjectIntoOctree", args); + return ((Long)rets[0]); + } + + public Long insertObjectIntoPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.insertObjectIntoPointCloud", args); + return ((Long)rets[0]); + } + + public Long insertPointsIntoPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.insertPointsIntoPointCloud", args); + return ((Long)rets[0]); + } + + public Long insertVoxelsIntoOctree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.insertVoxelsIntoOctree", args); + return ((Long)rets[0]); + } + + public List interpolateMatrices(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.interpolateMatrices", args); + return ((List)rets[0]); + } + + public List interpolatePoses(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.interpolatePoses", args); + return ((List)rets[0]); + } + + public Long intersectPointsWithPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.intersectPointsWithPointCloud", args); + return ((Long)rets[0]); + } + + public Long isDeprecated(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.isDeprecated", args); + return ((Long)rets[0]); + } + + public Boolean isDynamicallyEnabled(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.isDynamicallyEnabled", args); + return ((Boolean)rets[0]); + } + + public Boolean isHandle(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.isHandle", args); + return ((Boolean)rets[0]); + } + + public void launchExecutable(Object... args) throws CborException + { + this.client.call("sim.launchExecutable", args); + } + + public Object[] loadImage(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.loadImage", args); + return rets; + } + + public Long loadModel(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.loadModel", args); + return ((Long)rets[0]); + } + + public void loadScene(Object... args) throws CborException + { + this.client.call("sim.loadScene", args); + } + + public List matrixToPose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.matrixToPose", args); + return ((List)rets[0]); + } + + public Long moduleEntry(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.moduleEntry", args); + return ((Long)rets[0]); + } + + public Object[] moveToConfig(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.moveToConfig", args); + return rets; + } + + public Object[] moveToPose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.moveToPose", args); + return rets; + } + + public List multiplyMatrices(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.multiplyMatrices", args); + return ((List)rets[0]); + } + + public List multiplyPoses(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.multiplyPoses", args); + return ((List)rets[0]); + } + + public List multiplyVector(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.multiplyVector", args); + return ((List)rets[0]); + } + + public byte[] packDoubleTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packDoubleTable", args); + return ((byte[])rets[0]); + } + + public byte[] packFloatTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packFloatTable", args); + return ((byte[])rets[0]); + } + + public byte[] packInt32Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packInt32Table", args); + return ((byte[])rets[0]); + } + + public byte[] packTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packTable", args); + return ((byte[])rets[0]); + } + + public byte[] packUInt16Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packUInt16Table", args); + return ((byte[])rets[0]); + } + + public byte[] packUInt32Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packUInt32Table", args); + return ((byte[])rets[0]); + } + + public byte[] packUInt8Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.packUInt8Table", args); + return ((byte[])rets[0]); + } + + public void pauseSimulation(Object... args) throws CborException + { + this.client.call("sim.pauseSimulation", args); + } + + public byte[] persistentDataRead(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.persistentDataRead", args); + return ((byte[])rets[0]); + } + + public void persistentDataWrite(Object... args) throws CborException + { + this.client.call("sim.persistentDataWrite", args); + } + + public List poseToMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.poseToMatrix", args); + return ((List)rets[0]); + } + + public void pushUserEvent(Object... args) throws CborException + { + this.client.call("sim.pushUserEvent", args); + } + + public void quitSimulator(Object... args) throws CborException + { + this.client.call("sim.quitSimulator", args); + } + + public byte[] readCustomDataBlock(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readCustomDataBlock", args); + return ((byte[])rets[0]); + } + + public void readCustomDataBlockEx(Object... args) throws CborException + { + this.client.call("sim.readCustomDataBlockEx", args); + } + + public List readCustomDataBlockTags(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readCustomDataBlockTags", args); + return ((List)rets[0]); + } + + public void readCustomTableData(Object... args) throws CborException + { + this.client.call("sim.readCustomTableData", args); + } + + public Object[] readForceSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readForceSensor", args); + return rets; + } + + public Object[] readProximitySensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readProximitySensor", args); + return rets; + } + + public byte[] readTexture(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readTexture", args); + return ((byte[])rets[0]); + } + + public Object[] readVisionSensor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.readVisionSensor", args); + return rets; + } + + public Long refreshDialogs(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.refreshDialogs", args); + return ((Long)rets[0]); + } + + public void releaseLock(Object... args) throws CborException + { + this.client.call("sim.releaseLock", args); + } + + public Long relocateShapeFrame(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.relocateShapeFrame", args); + return ((Long)rets[0]); + } + + public void removeDrawingObject(Object... args) throws CborException + { + this.client.call("sim.removeDrawingObject", args); + } + + public Long removeModel(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.removeModel", args); + return ((Long)rets[0]); + } + + public void removeObjects(Object... args) throws CborException + { + this.client.call("sim.removeObjects", args); + } + + public void removeParticleObject(Object... args) throws CborException + { + this.client.call("sim.removeParticleObject", args); + } + + public Long removePointsFromPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.removePointsFromPointCloud", args); + return ((Long)rets[0]); + } + + public void removeReferencedObjects(Object... args) throws CborException + { + this.client.call("sim.removeReferencedObjects", args); + } + + public void removeScript(Object... args) throws CborException + { + this.client.call("sim.removeScript", args); + } + + public Long removeVoxelsFromOctree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.removeVoxelsFromOctree", args); + return ((Long)rets[0]); + } + + public List resamplePath(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.resamplePath", args); + return ((List)rets[0]); + } + + public void resetDynamicObject(Object... args) throws CborException + { + this.client.call("sim.resetDynamicObject", args); + } + + public void resetGraph(Object... args) throws CborException + { + this.client.call("sim.resetGraph", args); + } + + public void resetProximitySensor(Object... args) throws CborException + { + this.client.call("sim.resetProximitySensor", args); + } + + public void resetVisionSensor(Object... args) throws CborException + { + this.client.call("sim.resetVisionSensor", args); + } + + public void restoreEntityColor(Object... args) throws CborException + { + this.client.call("sim.restoreEntityColor", args); + } + + public List rotateAroundAxis(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.rotateAroundAxis", args); + return ((List)rets[0]); + } + + public Long ruckigPos(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.ruckigPos", args); + return ((Long)rets[0]); + } + + public void ruckigRemove(Object... args) throws CborException + { + this.client.call("sim.ruckigRemove", args); + } + + public Object[] ruckigStep(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.ruckigStep", args); + return rets; + } + + public Long ruckigVel(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.ruckigVel", args); + return ((Long)rets[0]); + } + + public byte[] saveImage(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.saveImage", args); + return ((byte[])rets[0]); + } + + public void saveModel(Object... args) throws CborException + { + this.client.call("sim.saveModel", args); + } + + public void saveScene(Object... args) throws CborException + { + this.client.call("sim.saveScene", args); + } + + public void scaleObject(Object... args) throws CborException + { + this.client.call("sim.scaleObject", args); + } + + public void scaleObjects(Object... args) throws CborException + { + this.client.call("sim.scaleObjects", args); + } + + public Long serialCheck(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.serialCheck", args); + return ((Long)rets[0]); + } + + public void serialClose(Object... args) throws CborException + { + this.client.call("sim.serialClose", args); + } + + public Long serialOpen(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.serialOpen", args); + return ((Long)rets[0]); + } + + public byte[] serialRead(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.serialRead", args); + return ((byte[])rets[0]); + } + + public Long serialSend(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.serialSend", args); + return ((Long)rets[0]); + } + + public void setArrayParam(Object... args) throws CborException + { + this.client.call("sim.setArrayParam", args); + } + + public void setAutoYieldDelay(Object... args) throws CborException + { + this.client.call("sim.setAutoYieldDelay", args); + } + + public void setBoolParam(Object... args) throws CborException + { + this.client.call("sim.setBoolParam", args); + } + + public void setEngineBoolParam(Object... args) throws CborException + { + this.client.call("sim.setEngineBoolParam", args); + } + + public void setEngineFloatParam(Object... args) throws CborException + { + this.client.call("sim.setEngineFloatParam", args); + } + + public void setEngineInt32Param(Object... args) throws CborException + { + this.client.call("sim.setEngineInt32Param", args); + } + + public void setExplicitHandling(Object... args) throws CborException + { + this.client.call("sim.setExplicitHandling", args); + } + + public void setFloatParam(Object... args) throws CborException + { + this.client.call("sim.setFloatParam", args); + } + + public void setFloatSignal(Object... args) throws CborException + { + this.client.call("sim.setFloatSignal", args); + } + + public void setGraphStreamTransformation(Object... args) throws CborException + { + this.client.call("sim.setGraphStreamTransformation", args); + } + + public void setGraphStreamValue(Object... args) throws CborException + { + this.client.call("sim.setGraphStreamValue", args); + } + + public void setInt32Param(Object... args) throws CborException + { + this.client.call("sim.setInt32Param", args); + } + + public void setInt32Signal(Object... args) throws CborException + { + this.client.call("sim.setInt32Signal", args); + } + + public void setJointDependency(Object... args) throws CborException + { + this.client.call("sim.setJointDependency", args); + } + + public void setJointInterval(Object... args) throws CborException + { + this.client.call("sim.setJointInterval", args); + } + + public void setJointMode(Object... args) throws CborException + { + this.client.call("sim.setJointMode", args); + } + + public void setJointPosition(Object... args) throws CborException + { + this.client.call("sim.setJointPosition", args); + } + + public void setJointTargetForce(Object... args) throws CborException + { + this.client.call("sim.setJointTargetForce", args); + } + + public void setJointTargetPosition(Object... args) throws CborException + { + this.client.call("sim.setJointTargetPosition", args); + } + + public void setJointTargetVelocity(Object... args) throws CborException + { + this.client.call("sim.setJointTargetVelocity", args); + } + + public void setLightParameters(Object... args) throws CborException + { + this.client.call("sim.setLightParameters", args); + } + + public void setLinkDummy(Object... args) throws CborException + { + this.client.call("sim.setLinkDummy", args); + } + + public void setModelProperty(Object... args) throws CborException + { + this.client.call("sim.setModelProperty", args); + } + + public void setNamedBoolParam(Object... args) throws CborException + { + this.client.call("sim.setNamedBoolParam", args); + } + + public void setNamedFloatParam(Object... args) throws CborException + { + this.client.call("sim.setNamedFloatParam", args); + } + + public void setNamedInt32Param(Object... args) throws CborException + { + this.client.call("sim.setNamedInt32Param", args); + } + + public void setNamedStringParam(Object... args) throws CborException + { + this.client.call("sim.setNamedStringParam", args); + } + + public void setNavigationMode(Object... args) throws CborException + { + this.client.call("sim.setNavigationMode", args); + } + + public void setObjectAlias(Object... args) throws CborException + { + this.client.call("sim.setObjectAlias", args); + } + + public void setObjectChildPose(Object... args) throws CborException + { + this.client.call("sim.setObjectChildPose", args); + } + + public Boolean setObjectColor(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.setObjectColor", args); + return ((Boolean)rets[0]); + } + + public void setObjectFloatArrayParam(Object... args) throws CborException + { + this.client.call("sim.setObjectFloatArrayParam", args); + } + + public void setObjectFloatParam(Object... args) throws CborException + { + this.client.call("sim.setObjectFloatParam", args); + } + + public void setObjectInt32Param(Object... args) throws CborException + { + this.client.call("sim.setObjectInt32Param", args); + } + + public void setObjectMatrix(Object... args) throws CborException + { + this.client.call("sim.setObjectMatrix", args); + } + + public void setObjectOrientation(Object... args) throws CborException + { + this.client.call("sim.setObjectOrientation", args); + } + + public void setObjectParent(Object... args) throws CborException + { + this.client.call("sim.setObjectParent", args); + } + + public void setObjectPose(Object... args) throws CborException + { + this.client.call("sim.setObjectPose", args); + } + + public void setObjectPosition(Object... args) throws CborException + { + this.client.call("sim.setObjectPosition", args); + } + + public void setObjectProperty(Object... args) throws CborException + { + this.client.call("sim.setObjectProperty", args); + } + + public void setObjectQuaternion(Object... args) throws CborException + { + this.client.call("sim.setObjectQuaternion", args); + } + + public void setObjectSel(Object... args) throws CborException + { + this.client.call("sim.setObjectSel", args); + } + + public void setObjectSpecialProperty(Object... args) throws CborException + { + this.client.call("sim.setObjectSpecialProperty", args); + } + + public void setObjectStringParam(Object... args) throws CborException + { + this.client.call("sim.setObjectStringParam", args); + } + + public void setPage(Object... args) throws CborException + { + this.client.call("sim.setPage", args); + } + + public void setPluginInfo(Object... args) throws CborException + { + this.client.call("sim.setPluginInfo", args); + } + + public void setPointCloudOptions(Object... args) throws CborException + { + this.client.call("sim.setPointCloudOptions", args); + } + + public void setReferencedHandles(Object... args) throws CborException + { + this.client.call("sim.setReferencedHandles", args); + } + + public void setScriptInt32Param(Object... args) throws CborException + { + this.client.call("sim.setScriptInt32Param", args); + } + + public void setScriptStringParam(Object... args) throws CborException + { + this.client.call("sim.setScriptStringParam", args); + } + + public void setShapeBB(Object... args) throws CborException + { + this.client.call("sim.setShapeBB", args); + } + + public void setShapeColor(Object... args) throws CborException + { + this.client.call("sim.setShapeColor", args); + } + + public void setShapeInertia(Object... args) throws CborException + { + this.client.call("sim.setShapeInertia", args); + } + + public void setShapeMass(Object... args) throws CborException + { + this.client.call("sim.setShapeMass", args); + } + + public void setShapeMaterial(Object... args) throws CborException + { + this.client.call("sim.setShapeMaterial", args); + } + + public void setShapeTexture(Object... args) throws CborException + { + this.client.call("sim.setShapeTexture", args); + } + + public Long setStepping(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.setStepping", args); + return ((Long)rets[0]); + } + + public void setStringParam(Object... args) throws CborException + { + this.client.call("sim.setStringParam", args); + } + + public void setStringSignal(Object... args) throws CborException + { + this.client.call("sim.setStringSignal", args); + } + + public void setVisionSensorImg(Object... args) throws CborException + { + this.client.call("sim.setVisionSensorImg", args); + } + + public void startSimulation(Object... args) throws CborException + { + this.client.call("sim.startSimulation", args); + } + + public void step(Object... args) throws CborException + { + this.client.call("sim.step", args); + } + + public void stopSimulation(Object... args) throws CborException + { + this.client.call("sim.stopSimulation", args); + } + + public Long subtractObjectFromOctree(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.subtractObjectFromOctree", args); + return ((Long)rets[0]); + } + + public Long subtractObjectFromPointCloud(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.subtractObjectFromPointCloud", args); + return ((Long)rets[0]); + } + + public Long testCB(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.testCB", args); + return ((Long)rets[0]); + } + + public Object[] textEditorClose(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.textEditorClose", args); + return rets; + } + + public Object[] textEditorGetInfo(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.textEditorGetInfo", args); + return rets; + } + + public Long textEditorOpen(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.textEditorOpen", args); + return ((Long)rets[0]); + } + + public void textEditorShow(Object... args) throws CborException + { + this.client.call("sim.textEditorShow", args); + } + + public byte[] transformBuffer(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.transformBuffer", args); + return ((byte[])rets[0]); + } + + public void transformImage(Object... args) throws CborException + { + this.client.call("sim.transformImage", args); + } + + public List ungroupShape(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.ungroupShape", args); + return ((List)rets[0]); + } + + public List unpackDoubleTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackDoubleTable", args); + return ((List)rets[0]); + } + + public List unpackFloatTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackFloatTable", args); + return ((List)rets[0]); + } + + public List unpackInt32Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackInt32Table", args); + return ((List)rets[0]); + } + + public Object unpackTable(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackTable", args); + return ((Object)rets[0]); + } + + public List unpackUInt16Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackUInt16Table", args); + return ((List)rets[0]); + } + + public List unpackUInt32Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackUInt32Table", args); + return ((List)rets[0]); + } + + public List unpackUInt8Table(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.unpackUInt8Table", args); + return ((List)rets[0]); + } + + public void visitTree(Object... args) throws CborException + { + this.client.call("sim.visitTree", args); + } + + public Double wait(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.wait", args); + return ((Double)rets[0]); + } + + public Object waitForSignal(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.waitForSignal", args); + return ((Object)rets[0]); + } + + public void writeCustomDataBlock(Object... args) throws CborException + { + this.client.call("sim.writeCustomDataBlock", args); + } + + public void writeCustomDataBlockEx(Object... args) throws CborException + { + this.client.call("sim.writeCustomDataBlockEx", args); + } + + public void writeCustomTableData(Object... args) throws CborException + { + this.client.call("sim.writeCustomTableData", args); + } + + public void writeTexture(Object... args) throws CborException + { + this.client.call("sim.writeTexture", args); + } + + public Object[] yawPitchRollToAlphaBetaGamma(Object... args) throws CborException + { + Object[] rets = this.client.call("sim.yawPitchRollToAlphaBetaGamma", args); + return rets; + } + + public void yield(Object... args) throws CborException + { + this.client.call("sim.yield", args); + } + + public static final int addonscriptcall_cleanup = 1; + public static final int addonscriptcall_initialization = 2; + public static final int addonscriptcall_restarting = 17; + public static final int addonscriptcall_run = 15; + public static final int addonscriptcall_suspend = 16; + public static final int api_error_output = 2; + public static final int api_error_report = 1; + public static final int api_warning_output = 4; + public static final int appobj_2delement_type = 116; + public static final int appobj_collection_type = 115; + public static final int appobj_collision_type = 110; + public static final int appobj_distance_type = 111; + public static final int appobj_ik_type = 113; + public static final int appobj_object_type = 109; + public static final int appobj_pathplanning_type = 118; + public static final int appobj_script_type = 117; + public static final int appobj_simulation_type = 112; + public static final int appobj_texture_type = 120; + public static final int appobj_ui_type = 116; + public static final int arrayparam_ambient_light = 5; + public static final int arrayparam_background_color1 = 3; + public static final int arrayparam_background_color2 = 4; + public static final int arrayparam_fog = 1; + public static final int arrayparam_fog_color = 2; + public static final int arrayparam_gravity = 0; + public static final int arrayparam_random_euler = 6; + public static final int arrayparam_raydirection = 8; + public static final int arrayparam_rayorigin = 7; + public static final int banner_backfaceculling = 512; + public static final int banner_bitmapfont = 2048; + public static final int banner_clickselectsparent = 32; + public static final int banner_clicktriggersevent = 64; + public static final int banner_facingcamera = 128; + public static final int banner_followparentvisibility = 16; + public static final int banner_fullyfacingcamera = 256; + public static final int banner_keepsamesize = 1024; + public static final int banner_left = 1; + public static final int banner_nobackground = 4; + public static final int banner_overlay = 8; + public static final int banner_right = 2; + public static final int boolparam_aux_clip_planes_enabled = 23; + public static final int boolparam_browser_toolbarbutton_enabled = 36; + public static final int boolparam_browser_visible = 12; + public static final int boolparam_calcmodules_toolbarbutton_enabled = 47; + public static final int boolparam_cansave = 60; + public static final int boolparam_collision_handling_enabled = 2; + public static final int boolparam_console_visible = 1; + public static final int boolparam_display_enabled = 16; + public static final int boolparam_distance_handling_enabled = 3; + public static final int boolparam_dynamics_handling_enabled = 6; + public static final int boolparam_execunsafe = 58; + public static final int boolparam_execunsafeext = 59; + public static final int boolparam_exit_request = 41; + public static final int boolparam_fog_enabled = 19; + public static final int boolparam_force_calcstruct_all = 40; + public static final int boolparam_force_calcstruct_all_visible = 39; + public static final int boolparam_force_show_wireless_emission = 27; + public static final int boolparam_force_show_wireless_reception = 28; + public static final int boolparam_full_model_copy_from_api = 24; + public static final int boolparam_fullscreen = 33; + public static final int boolparam_gcs_handling_enabled = 5; + public static final int boolparam_headless = 34; + public static final int boolparam_hierarchy_toolbarbutton_enabled = 35; + public static final int boolparam_hierarchy_visible = 0; + public static final int boolparam_ik_handling_enabled = 4; + public static final int boolparam_infotext_visible = 17; + public static final int boolparam_mill_handling_enabled = 11; + public static final int boolparam_mirrors_enabled = 22; + public static final int boolparam_objectrotate_toolbarbutton_enabled = 38; + public static final int boolparam_objectshift_toolbarbutton_enabled = 37; + public static final int boolparam_objproperties_toolbarbutton_enabled = 46; + public static final int boolparam_pause_toolbarbutton_enabled = 43; + public static final int boolparam_play_toolbarbutton_enabled = 42; + public static final int boolparam_proximity_sensor_handling_enabled = 9; + public static final int boolparam_rayvalid = 56; + public static final int boolparam_realtime_simulation = 25; + public static final int boolparam_rendering_sensor_handling_enabled = 10; + public static final int boolparam_rml2_available = 20; + public static final int boolparam_rml4_available = 21; + public static final int boolparam_rosinterface_donotrunmainscript = 48; + public static final int boolparam_scene_and_model_load_messages = 13; + public static final int boolparam_scene_closing = 52; + public static final int boolparam_shape_textures_are_visible = 15; + public static final int boolparam_show_w_emitters = 53; + public static final int boolparam_show_w_receivers = 54; + public static final int boolparam_statustext_open = 18; + public static final int boolparam_stop_toolbarbutton_enabled = 44; + public static final int boolparam_use_glfinish_cmd = 26; + public static final int boolparam_video_recording_triggered = 29; + public static final int boolparam_vision_sensor_handling_enabled = 10; + public static final int boolparam_waiting_for_trigger = 45; + public static final int buffer_base64 = 12; + public static final int buffer_clamp = 256; + public static final int buffer_double = 7; + public static final int buffer_float = 6; + public static final int buffer_int16 = 3; + public static final int buffer_int32 = 5; + public static final int buffer_int8 = 1; + public static final int buffer_split = 13; + public static final int buffer_uint16 = 2; + public static final int buffer_uint32 = 4; + public static final int buffer_uint8 = 0; + public static final int buffer_uint8argb = 11; + public static final int buffer_uint8bgr = 9; + public static final int buffer_uint8rgb = 8; + public static final int buffer_uint8rgba = 10; + public static final int bullet_body_angulardamping = 6005; + public static final int bullet_body_autoshrinkconvex = 8004; + public static final int bullet_body_bitcoded = 7001; + public static final int bullet_body_friction = 6003; + public static final int bullet_body_lineardamping = 6004; + public static final int bullet_body_nondefaultcollisionmargingfactor = 6006; + public static final int bullet_body_nondefaultcollisionmargingfactorconvex = 6007; + public static final int bullet_body_oldfriction = 6002; + public static final int bullet_body_restitution = 6001; + public static final int bullet_body_sticky = 8001; + public static final int bullet_body_usenondefaultcollisionmargin = 8002; + public static final int bullet_body_usenondefaultcollisionmarginconvex = 8003; + public static final int bullet_constraintsolvertype_dantzig = 2; + public static final int bullet_constraintsolvertype_nncg = 1; + public static final int bullet_constraintsolvertype_projectedgaussseidel = 3; + public static final int bullet_constraintsolvertype_sequentialimpulse = 0; + public static final int bullet_global_bitcoded = 1002; + public static final int bullet_global_collisionmarginfactor = 3; + public static final int bullet_global_computeinertias = 2002; + public static final int bullet_global_constraintsolvertype = 1003; + public static final int bullet_global_constraintsolvingiterations = 1001; + public static final int bullet_global_fullinternalscaling = 2001; + public static final int bullet_global_internalscalingfactor = 2; + public static final int bullet_global_stepsize = 1; + public static final int bullet_joint_normalcfm = 3003; + public static final int bullet_joint_pospid1 = 3006; + public static final int bullet_joint_pospid2 = 3007; + public static final int bullet_joint_pospid3 = 3008; + public static final int bullet_joint_stopcfm = 3002; + public static final int bullet_joint_stoperp = 3001; + public static final int buttonproperty_borderless = 32; + public static final int buttonproperty_button = 0; + public static final int buttonproperty_closeaction = 4096; + public static final int buttonproperty_downupevent = 16384; + public static final int buttonproperty_editbox = 3; + public static final int buttonproperty_enabled = 16; + public static final int buttonproperty_horizontallycentered = 64; + public static final int buttonproperty_ignoremouse = 128; + public static final int buttonproperty_isdown = 256; + public static final int buttonproperty_label = 1; + public static final int buttonproperty_nobackgroundcolor = 1024; + public static final int buttonproperty_rollupaction = 2048; + public static final int buttonproperty_slider = 2; + public static final int buttonproperty_staydown = 8; + public static final int buttonproperty_transparent = 512; + public static final int buttonproperty_verticallycentered = 8192; + public static final int callbackid_dynstep = 2; + public static final int callbackid_rossubscriber = 1; + public static final int callbackid_userdefined = 1000; + public static final int camerafarrayparam_viewfrustum = 9013; + public static final int camerafloatparam_far_clipping = 9009; + public static final int camerafloatparam_near_clipping = 9008; + public static final int camerafloatparam_ortho_size = 9002; + public static final int camerafloatparam_perspective_angle = 9001; + public static final int camerafloatparam_pov_aperture = 9006; + public static final int camerafloatparam_pov_blur_distance = 9005; + public static final int cameraintparam_disabled_light_components = 9000; + public static final int cameraintparam_perspective_operation = 9010; + public static final int cameraintparam_pov_blur_samples = 9007; + public static final int cameraintparam_pov_focal_blur = 9004; + public static final int cameraintparam_rendering_attributes = 9003; + public static final int cameraintparam_trackedobject = 9011; + public static final int childscriptattribute_automaticcascadingcalls = 3; + public static final int childscriptattribute_enabled = 4; + public static final int childscriptcall_actuation = 6; + public static final int childscriptcall_cleanup = 1; + public static final int childscriptcall_initialization = 2; + public static final int childscriptcall_sensing = 7; + public static final int colorcomponent_ambient = 0; + public static final int colorcomponent_ambient_diffuse = 0; + public static final int colorcomponent_auxiliary = 5; + public static final int colorcomponent_diffuse = 1; + public static final int colorcomponent_emission = 3; + public static final int colorcomponent_specular = 2; + public static final int colorcomponent_transparency = 4; + public static final int customizationscriptattribute_activeduringsimulation = 0; + public static final int customizationscriptattribute_cleanupbeforesave = 5; + public static final int customizationscriptcall_aftercopy = 14; + public static final int customizationscriptcall_beforecopy = 13; + public static final int customizationscriptcall_cleanup = 1; + public static final int customizationscriptcall_firstafterinstanceswitch = 12; + public static final int customizationscriptcall_firstaftersimulation = 5; + public static final int customizationscriptcall_initialization = 2; + public static final int customizationscriptcall_lastbeforeinstanceswitch = 11; + public static final int customizationscriptcall_lastbeforesimulation = 4; + public static final int customizationscriptcall_nonsimulation = 3; + public static final int customizationscriptcall_simulationactuation = 6; + public static final int customizationscriptcall_simulationpause = 8; + public static final int customizationscriptcall_simulationpausefirst = 9; + public static final int customizationscriptcall_simulationpauselast = 10; + public static final int customizationscriptcall_simulationsensing = 7; + public static final int displayattribute_colorcoded = 8192; + public static final int displayattribute_colorcodedpickpass = 4096; + public static final int displayattribute_colorcodedtriangles = 134217728; + public static final int displayattribute_depthpass = 2; + public static final int displayattribute_dynamiccontentonly = 131072; + public static final int displayattribute_forbidedges = 256; + public static final int displayattribute_forbidwireframe = 128; + public static final int displayattribute_forcewireframe = 64; + public static final int displayattribute_forvisionsensor = 2048; + public static final int displayattribute_ignorelayer = 1024; + public static final int displayattribute_ignorerenderableflag = 1048576; + public static final int displayattribute_mainselection = 32; + public static final int displayattribute_mirror = 262144; + public static final int displayattribute_nodrawingobjects = 33554432; + public static final int displayattribute_noghosts = 8388608; + public static final int displayattribute_noopenglcallbacks = 2097152; + public static final int displayattribute_noparticles = 67108864; + public static final int displayattribute_nopointclouds = 16777216; + public static final int displayattribute_originalcolors = 512; + public static final int displayattribute_pickpass = 4; + public static final int displayattribute_renderpass = 1; + public static final int displayattribute_selected = 8; + public static final int displayattribute_thickEdges = 65536; + public static final int displayattribute_trianglewireframe = 16384; + public static final int displayattribute_useauxcomponent = 524288; + public static final int distcalcmethod_dac = 1; + public static final int distcalcmethod_dac_if_nonzero = 6; + public static final int distcalcmethod_dl = 0; + public static final int distcalcmethod_dl_and_dac = 3; + public static final int distcalcmethod_dl_if_nonzero = 5; + public static final int distcalcmethod_max_dl_dac = 2; + public static final int distcalcmethod_sqrt_dl2_and_dac2 = 4; + public static final int dlgret_cancel = 2; + public static final int dlgret_no = 4; + public static final int dlgret_ok = 1; + public static final int dlgret_still_open = 0; + public static final int dlgret_yes = 3; + public static final int dlgstyle_dont_center = 32; + public static final int dlgstyle_input = 1; + public static final int dlgstyle_message = 0; + public static final int dlgstyle_ok = 2; + public static final int dlgstyle_ok_cancel = 3; + public static final int dlgstyle_yes_no = 4; + public static final int drawing_12percenttransparency = 32768; + public static final int drawing_25percenttransparency = 16384; + public static final int drawing_50percenttransparency = 8192; + public static final int drawing_auxchannelcolor1 = 2097152; + public static final int drawing_auxchannelcolor2 = 4194304; + public static final int drawing_backfaceculling = 256; + public static final int drawing_cubepoints = 6; + public static final int drawing_cubepts = 12; + public static final int drawing_cyclic = 4096; + public static final int drawing_discpoints = 5; + public static final int drawing_discpts = 11; + public static final int drawing_emissioncolor = 65536; + public static final int drawing_facingcamera = 131072; + public static final int drawing_followparentvisibility = 2048; + public static final int drawing_itemcolors = 32; + public static final int drawing_itemsizes = 128; + public static final int drawing_itemtransparency = 524288; + public static final int drawing_lines = 1; + public static final int drawing_linestrip = 8; + public static final int drawing_local = 8388608; + public static final int drawing_overlay = 262144; + public static final int drawing_painttag = 1024; + public static final int drawing_persistent = 1048576; + public static final int drawing_points = 0; + public static final int drawing_quadpoints = 4; + public static final int drawing_quadpts = 10; + public static final int drawing_spherepoints = 7; + public static final int drawing_spherepts = 7; + public static final int drawing_trianglepoints = 3; + public static final int drawing_trianglepts = 9; + public static final int drawing_triangles = 2; + public static final int drawing_vertexcolors = 64; + public static final int drawing_wireframe = 512; + public static final int dummy_linktype_dynamics_force_constraint = 1; + public static final int dummy_linktype_dynamics_loop_closure = 0; + public static final int dummy_linktype_gcs_loop_closure = 2; + public static final int dummy_linktype_gcs_target = 4; + public static final int dummy_linktype_gcs_tip = 3; + public static final int dummy_linktype_ik_tip_target = 5; + public static final int dummyfloatparam_follow_path_offset = 10002; + public static final int dummyfloatparam_size = 10003; + public static final int dummyintparam_dummytype = 10000; + public static final int dummyintparam_follow_path = 10001; + public static final int dummyintparam_link_type = 10000; + public static final int dummylink_dynloopclosure = 0; + public static final int dummylink_dyntendon = 7; + public static final int dummystringparam_assemblytag = 10004; + public static final int dummytype_assembly = 9; + public static final int dummytype_default = 8; + public static final int dummytype_dynloopclosure = 0; + public static final int dummytype_dyntendon = 7; + public static final int dynmat_default = 2310013; + public static final int dynmat_floor = 2310021; + public static final int dynmat_foot = 2310018; + public static final int dynmat_gripper = 2310020; + public static final int dynmat_highfriction = 2310014; + public static final int dynmat_lowfriction = 2310015; + public static final int dynmat_nofriction = 2310016; + public static final int dynmat_reststackgrasp = 2310017; + public static final int dynmat_wheel = 2310019; + public static final int filedlg_type_folder = 3; + public static final int filedlg_type_load = 0; + public static final int filedlg_type_load_multiple = 2; + public static final int filedlg_type_save = 1; + public static final int filtercomponent_3x3filter = 18; + public static final int filtercomponent_5x5filter = 19; + public static final int filtercomponent_addbuffer1 = 10; + public static final int filtercomponent_addtobuffer1 = 30; + public static final int filtercomponent_binary = 28; + public static final int filtercomponent_blobextraction = 34; + public static final int filtercomponent_circularcut = 23; + public static final int filtercomponent_colorsegmentation = 33; + public static final int filtercomponent_correlationwithbuffer1 = 32; + public static final int filtercomponent_customized = 1000; + public static final int filtercomponent_edge = 21; + public static final int filtercomponent_frombuffer1 = 7; + public static final int filtercomponent_frombuffer2 = 8; + public static final int filtercomponent_horizontalflip = 13; + public static final int filtercomponent_imagetocoord = 35; + public static final int filtercomponent_intensityscale = 25; + public static final int filtercomponent_keeporremovecolors = 26; + public static final int filtercomponent_multiplywithbuffer1 = 12; + public static final int filtercomponent_normalize = 24; + public static final int filtercomponent_originaldepth = 2; + public static final int filtercomponent_originalimage = 1; + public static final int filtercomponent_pixelchange = 36; + public static final int filtercomponent_rectangularcut = 22; + public static final int filtercomponent_resize = 17; + public static final int filtercomponent_rotate = 15; + public static final int filtercomponent_scaleandoffsetcolors = 27; + public static final int filtercomponent_sharpen = 20; + public static final int filtercomponent_shift = 16; + public static final int filtercomponent_subtractbuffer1 = 11; + public static final int filtercomponent_subtractfrombuffer1 = 31; + public static final int filtercomponent_swapbuffers = 9; + public static final int filtercomponent_swapwithbuffer1 = 29; + public static final int filtercomponent_tobuffer1 = 5; + public static final int filtercomponent_tobuffer2 = 6; + public static final int filtercomponent_todepthoutput = 38; + public static final int filtercomponent_tooutput = 4; + public static final int filtercomponent_uniformimage = 3; + public static final int filtercomponent_velodyne = 37; + public static final int filtercomponent_verticalflip = 14; + public static final int floatparam_dynamic_step_size = 3; + public static final int floatparam_maxtrisizeabs = 6; + public static final int floatparam_mintrisizerel = 7; + public static final int floatparam_mouse_wheel_zoom_factor = 4; + public static final int floatparam_physicstimestep = 5; + public static final int floatparam_rand = 0; + public static final int floatparam_simulation_time_step = 1; + public static final int floatparam_stereo_distance = 2; + public static final int forcefloatparam_error_a = 5003; + public static final int forcefloatparam_error_angle = 5007; + public static final int forcefloatparam_error_b = 5004; + public static final int forcefloatparam_error_g = 5005; + public static final int forcefloatparam_error_pos = 5006; + public static final int forcefloatparam_error_x = 5000; + public static final int forcefloatparam_error_y = 5001; + public static final int forcefloatparam_error_z = 5002; + public static final int graphintparam_needs_refresh = 10500; + public static final int handle_all = -2; + public static final int handle_all_except_explicit = -3; + public static final int handle_all_except_self = -10; + public static final int handle_app = -13; + public static final int handle_chain = -7; + public static final int handle_default = -9; + public static final int handle_inverse = -14; + public static final int handle_main_script = -5; + public static final int handle_parent = -11; + public static final int handle_scene = -12; + public static final int handle_self = -4; + public static final int handle_single = -8; + public static final int handle_tree = -6; + public static final int handle_world = -1; + public static final int handleflag_abscoords = 8388608; + public static final int handleflag_addmultiple = 16777216; + public static final int handleflag_altname = 4194304; + public static final int handleflag_assembly = 4194304; + public static final int handleflag_axis = 4194304; + public static final int handleflag_camera = 4194304; + public static final int handleflag_codedstring = 4194304; + public static final int handleflag_depthbuffer = 8388608; + public static final int handleflag_depthbuffermeters = 8388608; + public static final int handleflag_extended = 4194304; + public static final int handleflag_greyscale = 4194304; + public static final int handleflag_keeporiginal = 4194304; + public static final int handleflag_model = 8388608; + public static final int handleflag_rawvalue = 16777216; + public static final int handleflag_reljointbaseframe = 4194304; + public static final int handleflag_resetforce = 4194304; + public static final int handleflag_resetforcetorque = 12582912; + public static final int handleflag_resettorque = 8388608; + public static final int handleflag_setmultiple = 4194304; + public static final int handleflag_silenterror = 33554432; + public static final int handleflag_togglevisibility = 4194304; + public static final int handleflag_wxyzquat = 16777216; + public static final int ik_alpha_beta_constraint = 8; + public static final int ik_damped_least_squares_method = 1; + public static final int ik_gamma_constraint = 16; + public static final int ik_jacobian_transpose_method = 2; + public static final int ik_pseudo_inverse_method = 0; + public static final int ik_undamped_pseudo_inverse_method = 3; + public static final int ik_x_constraint = 1; + public static final int ik_y_constraint = 2; + public static final int ik_z_constraint = 4; + public static final int ikresult_fail = 2; + public static final int ikresult_not_performed = 0; + public static final int ikresult_success = 1; + public static final int imgcomb_horizontal = 1; + public static final int imgcomb_vertical = 0; + public static final int intparam_compilation_version = 4; + public static final int intparam_core_count = 24; + public static final int intparam_current_page = 5; + public static final int intparam_dlgverbosity = 42; + public static final int intparam_dynamic_engine = 8; + public static final int intparam_dynamic_iteration_count = 37; + public static final int intparam_dynamic_step_divider = 7; + public static final int intparam_dynamic_warning_disabled_mask = 32; + public static final int intparam_edit_mode_type = 14; + public static final int intparam_error_report_mode = 0; + public static final int intparam_exitcode = 44; + public static final int intparam_flymode_camera_handle = 6; + public static final int intparam_hierarchychangecounter = 50; + public static final int intparam_idle_fps = 26; + public static final int intparam_infotext_style = 12; + public static final int intparam_motionplanning_seed = 35; + public static final int intparam_mouse_buttons = 31; + public static final int intparam_mouse_x = 22; + public static final int intparam_mouse_y = 23; + public static final int intparam_mouseclickcounterdown = 46; + public static final int intparam_mouseclickcounterup = 47; + public static final int intparam_objectcreationcounter = 48; + public static final int intparam_objectdestructioncounter = 49; + public static final int intparam_platform = 19; + public static final int intparam_program_full_version = 39; + public static final int intparam_program_revision = 30; + public static final int intparam_program_version = 1; + public static final int intparam_prox_sensor_select_down = 27; + public static final int intparam_prox_sensor_select_up = 28; + public static final int intparam_qt_version = 16; + public static final int intparam_scene_index = 34; + public static final int intparam_scene_unique_id = 20; + public static final int intparam_server_port_next = 15; + public static final int intparam_server_port_range = 10; + public static final int intparam_server_port_start = 9; + public static final int intparam_settings = 13; + public static final int intparam_simulation_warning_disabled_mask = 33; + public static final int intparam_speedmodifier = 36; + public static final int intparam_statusbarverbosity = 41; + public static final int intparam_stop_request_counter = 29; + public static final int intparam_verbosity = 40; + public static final int intparam_videoencoderindex = 43; + public static final int intparam_visible_layers = 11; + public static final int intparam_work_thread_calc_time_ms = 25; + public static final int intparam_work_thread_count = 21; + public static final int joint_prismatic_subtype = 11; + public static final int joint_revolute_subtype = 10; + public static final int joint_spherical_subtype = 12; + public static final int jointdynctrl_callback = 16; + public static final int jointdynctrl_force = 1; + public static final int jointdynctrl_free = 0; + public static final int jointdynctrl_position = 8; + public static final int jointdynctrl_spring = 12; + public static final int jointdynctrl_velocity = 4; + public static final int jointfloatparam_error_a = 2025; + public static final int jointfloatparam_error_angle = 2029; + public static final int jointfloatparam_error_b = 2026; + public static final int jointfloatparam_error_g = 2027; + public static final int jointfloatparam_error_pos = 2028; + public static final int jointfloatparam_error_x = 2022; + public static final int jointfloatparam_error_y = 2023; + public static final int jointfloatparam_error_z = 2024; + public static final int jointfloatparam_ik_weight = 2021; + public static final int jointfloatparam_intrinsic_qw = 2011; + public static final int jointfloatparam_intrinsic_qx = 2008; + public static final int jointfloatparam_intrinsic_qy = 2009; + public static final int jointfloatparam_intrinsic_qz = 2010; + public static final int jointfloatparam_intrinsic_x = 2005; + public static final int jointfloatparam_intrinsic_y = 2006; + public static final int jointfloatparam_intrinsic_z = 2007; + public static final int jointfloatparam_kc_c = 2019; + public static final int jointfloatparam_kc_k = 2018; + public static final int jointfloatparam_maxaccel = 2037; + public static final int jointfloatparam_maxjerk = 2038; + public static final int jointfloatparam_maxvel = 2036; + public static final int jointfloatparam_pid_d = 2004; + public static final int jointfloatparam_pid_i = 2003; + public static final int jointfloatparam_pid_p = 2002; + public static final int jointfloatparam_screw_pitch = 2034; + public static final int jointfloatparam_screwlead = 2042; + public static final int jointfloatparam_spherical_qw = 2016; + public static final int jointfloatparam_spherical_qx = 2013; + public static final int jointfloatparam_spherical_qy = 2014; + public static final int jointfloatparam_spherical_qz = 2015; + public static final int jointfloatparam_step_size = 2035; + public static final int jointfloatparam_upper_limit = 2017; + public static final int jointfloatparam_velocity = 2012; + public static final int jointfloatparam_vortex_dep_multiplication = 2032; + public static final int jointfloatparam_vortex_dep_offset = 2033; + public static final int jointintparam_ctrl_enabled = 2001; + public static final int jointintparam_dynctrlmode = 2039; + public static final int jointintparam_dynposctrltype = 2041; + public static final int jointintparam_dynvelctrltype = 2040; + public static final int jointintparam_motor_enabled = 2000; + public static final int jointintparam_velocity_lock = 2030; + public static final int jointintparam_vortex_dep_handle = 2031; + public static final int jointmode_dependent = 4; + public static final int jointmode_dynamic = 5; + public static final int jointmode_force = 5; + public static final int jointmode_ik = 2; + public static final int jointmode_ikdependent = 3; + public static final int jointmode_kinematic = 0; + public static final int jointmode_passive = 0; + public static final int light_directional_subtype = 3; + public static final int light_omnidirectional_subtype = 1; + public static final int light_spot_subtype = 2; + public static final int lightfloatparam_const_attenuation = 8003; + public static final int lightfloatparam_lin_attenuation = 8004; + public static final int lightfloatparam_quad_attenuation = 8005; + public static final int lightfloatparam_spot_cutoff = 8002; + public static final int lightfloatparam_spot_exponent = 8001; + public static final int lightintparam_pov_casts_shadows = 8000; + public static final int mainscriptcall_cleanup = 1; + public static final int mainscriptcall_initialization = 2; + public static final int mainscriptcall_regular = 6; + public static final int message_bannerclicked = 7; + public static final int message_keypress = 6; + public static final int message_model_loaded = 4; + public static final int message_object_selection_changed = 2; + public static final int message_pick_select_down = 11; + public static final int message_prox_sensor_select_down = 9; + public static final int message_prox_sensor_select_up = 10; + public static final int message_scene_loaded = 8; + public static final int message_ui_button_state_change = 0; + public static final int mill_cone_subtype = 43; + public static final int mill_cylinder_subtype = 41; + public static final int mill_disc_subtype = 42; + public static final int mill_pyramid_subtype = 40; + public static final int millintparam_volume_type = 11000; + public static final int mirrorfloatparam_height = 12001; + public static final int mirrorfloatparam_reflectance = 12002; + public static final int mirrorfloatparam_width = 12000; + public static final int mirrorintparam_enable = 12003; + public static final int modelproperty_not_collidable = 1; + public static final int modelproperty_not_detectable = 8; + public static final int modelproperty_not_dynamic = 32; + public static final int modelproperty_not_measurable = 2; + public static final int modelproperty_not_model = 61440; + public static final int modelproperty_not_renderable = 4; + public static final int modelproperty_not_reset = 128; + public static final int modelproperty_not_respondable = 64; + public static final int modelproperty_not_showasinsidemodel = 1024; + public static final int modelproperty_not_visible = 256; + public static final int modelproperty_scripts_inactive = 512; + public static final int moduleinfo_builddatestr = 1; + public static final int moduleinfo_extversionint = 2; + public static final int moduleinfo_extversionstr = 0; + public static final int moduleinfo_statusbarverbosity = 4; + public static final int moduleinfo_verbosity = 3; + public static final int msgbox_buttons_ok = 0; + public static final int msgbox_buttons_okcancel = 3; + public static final int msgbox_buttons_yesno = 1; + public static final int msgbox_buttons_yesnocancel = 2; + public static final int msgbox_return_cancel = 0; + public static final int msgbox_return_error = 4; + public static final int msgbox_return_no = 1; + public static final int msgbox_return_ok = 3; + public static final int msgbox_return_yes = 2; + public static final int msgbox_type_critical = 3; + public static final int msgbox_type_info = 0; + public static final int msgbox_type_question = 1; + public static final int msgbox_type_warning = 2; + public static final int mujoco_body_condim = 44001; + public static final int mujoco_body_friction1 = 43001; + public static final int mujoco_body_friction2 = 43002; + public static final int mujoco_body_friction3 = 43003; + public static final int mujoco_body_margin = 43012; + public static final int mujoco_body_priority = 44002; + public static final int mujoco_body_solimp1 = 43006; + public static final int mujoco_body_solimp2 = 43007; + public static final int mujoco_body_solimp3 = 43008; + public static final int mujoco_body_solimp4 = 43009; + public static final int mujoco_body_solimp5 = 43010; + public static final int mujoco_body_solmix = 43011; + public static final int mujoco_body_solref1 = 43004; + public static final int mujoco_body_solref2 = 43005; + public static final int mujoco_dummy_bitcoded = 47001; + public static final int mujoco_dummy_damping = 46013; + public static final int mujoco_dummy_limited = 48001; + public static final int mujoco_dummy_margin = 46010; + public static final int mujoco_dummy_proxyjointid = 47002; + public static final int mujoco_dummy_range1 = 46001; + public static final int mujoco_dummy_range2 = 46002; + public static final int mujoco_dummy_solimplimit1 = 46005; + public static final int mujoco_dummy_solimplimit2 = 46006; + public static final int mujoco_dummy_solimplimit3 = 46007; + public static final int mujoco_dummy_solimplimit4 = 46008; + public static final int mujoco_dummy_solimplimit5 = 46009; + public static final int mujoco_dummy_solreflimit1 = 46003; + public static final int mujoco_dummy_solreflimit2 = 46004; + public static final int mujoco_dummy_springlength = 46011; + public static final int mujoco_dummy_stiffness = 46012; + public static final int mujoco_global_balanceinertias = 39004; + public static final int mujoco_global_bitcoded = 38001; + public static final int mujoco_global_boundinertia = 37009; + public static final int mujoco_global_boundmass = 37008; + public static final int mujoco_global_computeinertias = 39001; + public static final int mujoco_global_cone = 38007; + public static final int mujoco_global_density = 37006; + public static final int mujoco_global_impratio = 37002; + public static final int mujoco_global_integrator = 38003; + public static final int mujoco_global_iterations = 38002; + public static final int mujoco_global_kininertia = 37019; + public static final int mujoco_global_kinmass = 37018; + public static final int mujoco_global_multiccd = 39003; + public static final int mujoco_global_multithreaded = 39002; + public static final int mujoco_global_nconmax = 38006; + public static final int mujoco_global_njmax = 38005; + public static final int mujoco_global_nstack = 38009; + public static final int mujoco_global_overridecontacts = 39005; + public static final int mujoco_global_overridekin = 38008; + public static final int mujoco_global_overridemargin = 37010; + public static final int mujoco_global_overridesolimp1 = 37013; + public static final int mujoco_global_overridesolimp2 = 37014; + public static final int mujoco_global_overridesolimp3 = 37015; + public static final int mujoco_global_overridesolimp4 = 37016; + public static final int mujoco_global_overridesolimp5 = 37017; + public static final int mujoco_global_overridesolref1 = 37011; + public static final int mujoco_global_overridesolref2 = 37012; + public static final int mujoco_global_rebuildtrigger = 38010; + public static final int mujoco_global_solver = 38004; + public static final int mujoco_global_viscosity = 37007; + public static final int mujoco_global_wind1 = 37003; + public static final int mujoco_global_wind2 = 37004; + public static final int mujoco_global_wind3 = 37005; + public static final int mujoco_joint_armature = 40021; + public static final int mujoco_joint_damping = 40017; + public static final int mujoco_joint_dependentobjectid = 41002; + public static final int mujoco_joint_frictionloss = 40008; + public static final int mujoco_joint_margin = 40022; + public static final int mujoco_joint_polycoef1 = 40023; + public static final int mujoco_joint_polycoef2 = 40024; + public static final int mujoco_joint_polycoef3 = 40025; + public static final int mujoco_joint_polycoef4 = 40026; + public static final int mujoco_joint_polycoef5 = 40027; + public static final int mujoco_joint_pospid1 = 40028; + public static final int mujoco_joint_pospid2 = 40029; + public static final int mujoco_joint_pospid3 = 40030; + public static final int mujoco_joint_solimpfriction1 = 40011; + public static final int mujoco_joint_solimpfriction2 = 40012; + public static final int mujoco_joint_solimpfriction3 = 40013; + public static final int mujoco_joint_solimpfriction4 = 40014; + public static final int mujoco_joint_solimpfriction5 = 40015; + public static final int mujoco_joint_solimplimit1 = 40003; + public static final int mujoco_joint_solimplimit2 = 40004; + public static final int mujoco_joint_solimplimit3 = 40005; + public static final int mujoco_joint_solimplimit4 = 40006; + public static final int mujoco_joint_solimplimit5 = 40007; + public static final int mujoco_joint_solreffriction1 = 40009; + public static final int mujoco_joint_solreffriction2 = 40010; + public static final int mujoco_joint_solreflimit1 = 40001; + public static final int mujoco_joint_solreflimit2 = 40002; + public static final int mujoco_joint_springdamper1 = 40019; + public static final int mujoco_joint_springdamper2 = 40020; + public static final int mujoco_joint_springref = 40018; + public static final int mujoco_joint_stiffness = 40016; + public static final int navigation_cameraangle = 5; + public static final int navigation_camerafly = 6; + public static final int navigation_camerarotate = 2; + public static final int navigation_camerarotatemiddlebutton = 8192; + public static final int navigation_camerarotaterightbutton = 8192; + public static final int navigation_camerashift = 1; + public static final int navigation_cameratilt = 4; + public static final int navigation_camerazoom = 3; + public static final int navigation_camerazoomwheel = 4096; + public static final int navigation_clickselection = 512; + public static final int navigation_createpathpoint = 256; + public static final int navigation_ctrlselection = 1024; + public static final int navigation_objectrotate = 8; + public static final int navigation_objectshift = 7; + public static final int navigation_passive = 0; + public static final int navigation_shiftselection = 2048; + public static final int newton_body_angulardrag = 33005; + public static final int newton_body_bitcoded = 34001; + public static final int newton_body_fastmoving = 35001; + public static final int newton_body_kineticfriction = 33002; + public static final int newton_body_lineardrag = 33004; + public static final int newton_body_restitution = 33003; + public static final int newton_body_staticfriction = 33001; + public static final int newton_global_bitcoded = 28002; + public static final int newton_global_computeinertias = 29004; + public static final int newton_global_constraintsolvingiterations = 28001; + public static final int newton_global_contactmergetolerance = 27002; + public static final int newton_global_exactsolver = 29002; + public static final int newton_global_highjointaccuracy = 29003; + public static final int newton_global_multithreading = 29001; + public static final int newton_global_stepsize = 27001; + public static final int newton_joint_dependencyfactor = 30001; + public static final int newton_joint_dependencyoffset = 30002; + public static final int newton_joint_dependentobjectid = 31002; + public static final int newton_joint_objectid = 31001; + public static final int newton_joint_pospid1 = 30003; + public static final int newton_joint_pospid2 = 30004; + public static final int newton_joint_pospid3 = 30005; + public static final int object_camera_type = 3; + public static final int object_dummy_type = 4; + public static final int object_forcesensor_type = 12; + public static final int object_graph_type = 2; + public static final int object_joint_type = 1; + public static final int object_light_type = 13; + public static final int object_mill_type = 11; + public static final int object_mirror_type = 14; + public static final int object_no_subtype = 200; + public static final int object_octree_type = 15; + public static final int object_path_type = 8; + public static final int object_pointcloud_type = 16; + public static final int object_proximitysensor_type = 5; + public static final int object_renderingsensor_type = 9; + public static final int object_shape_type = 0; + public static final int object_visionsensor_type = 9; + public static final int objectproperty_cannotdelete = 8192; + public static final int objectproperty_cannotdeleteduringsim = 16384; + public static final int objectproperty_canupdatedna = 1024; + public static final int objectproperty_collapsed = 16; + public static final int objectproperty_depthinvisible = 4096; + public static final int objectproperty_dontshowasinsidemodel = 256; + public static final int objectproperty_hiddenforsimulation = 65536; + public static final int objectproperty_hierarchyhiddenmodelchild = 32768; + public static final int objectproperty_ignoreviewfitting = 1; + public static final int objectproperty_selectable = 32; + public static final int objectproperty_selectinvisible = 2048; + public static final int objectproperty_selectmodelbaseinstead = 128; + public static final int objectspecialproperty_collidable = 1; + public static final int objectspecialproperty_detectable = 496; + public static final int objectspecialproperty_detectable_all = 496; + public static final int objectspecialproperty_detectable_capacitive = 256; + public static final int objectspecialproperty_detectable_inductive = 128; + public static final int objectspecialproperty_detectable_infrared = 32; + public static final int objectspecialproperty_detectable_laser = 64; + public static final int objectspecialproperty_detectable_ultrasonic = 16; + public static final int objectspecialproperty_measurable = 2; + public static final int objectspecialproperty_pathplanning_ignored = 2048; + public static final int objectspecialproperty_renderable = 512; + public static final int objfloatparam_abs_rot_velocity = 14; + public static final int objfloatparam_abs_x_velocity = 11; + public static final int objfloatparam_abs_y_velocity = 12; + public static final int objfloatparam_abs_z_velocity = 13; + public static final int objfloatparam_modelbbox_max_x = 24; + public static final int objfloatparam_modelbbox_max_y = 25; + public static final int objfloatparam_modelbbox_max_z = 26; + public static final int objfloatparam_modelbbox_min_x = 21; + public static final int objfloatparam_modelbbox_min_y = 22; + public static final int objfloatparam_modelbbox_min_z = 23; + public static final int objfloatparam_objbbox_max_x = 18; + public static final int objfloatparam_objbbox_max_y = 19; + public static final int objfloatparam_objbbox_max_z = 20; + public static final int objfloatparam_objbbox_min_x = 15; + public static final int objfloatparam_objbbox_min_y = 16; + public static final int objfloatparam_objbbox_min_z = 17; + public static final int objfloatparam_size_factor = 34; + public static final int objfloatparam_transparency_offset = 28; + public static final int objintparam_child_role = 29; + public static final int objintparam_collection_self_collision_indicator = 27; + public static final int objintparam_hierarchycolor = 38; + public static final int objintparam_illumination_handle = 32; + public static final int objintparam_manipulation_permissions = 31; + public static final int objintparam_parent_role = 30; + public static final int objintparam_unique_id = 37; + public static final int objintparam_visibility_layer = 10; + public static final int objintparam_visible = 36; + public static final int objstringparam_dna = 33; + public static final int objstringparam_unique_id = 35; + public static final int ode_body_angulardamping = 15005; + public static final int ode_body_friction = 15001; + public static final int ode_body_lineardamping = 15004; + public static final int ode_body_maxcontacts = 16001; + public static final int ode_body_softcfm = 15003; + public static final int ode_body_softerp = 15002; + public static final int ode_global_bitcoded = 10002; + public static final int ode_global_cfm = 9003; + public static final int ode_global_computeinertias = 11003; + public static final int ode_global_constraintsolvingiterations = 10001; + public static final int ode_global_erp = 9004; + public static final int ode_global_fullinternalscaling = 11001; + public static final int ode_global_internalscalingfactor = 9002; + public static final int ode_global_quickstep = 11002; + public static final int ode_global_randomseed = 10003; + public static final int ode_global_stepsize = 9001; + public static final int ode_joint_bounce = 12003; + public static final int ode_joint_fudgefactor = 12004; + public static final int ode_joint_normalcfm = 12005; + public static final int ode_joint_pospid1 = 12006; + public static final int ode_joint_pospid2 = 12007; + public static final int ode_joint_pospid3 = 12008; + public static final int ode_joint_stopcfm = 12002; + public static final int ode_joint_stoperp = 12001; + public static final int particle_cyclic = 8192; + public static final int particle_emissioncolor = 16384; + public static final int particle_ignoresgravity = 256; + public static final int particle_invisible = 512; + public static final int particle_itemcolors = 4096; + public static final int particle_itemdensities = 2048; + public static final int particle_itemsizes = 1024; + public static final int particle_painttag = 65536; + public static final int particle_particlerespondable = 128; + public static final int particle_points1 = 0; + public static final int particle_points2 = 1; + public static final int particle_points4 = 2; + public static final int particle_respondable1to4 = 32; + public static final int particle_respondable5to8 = 64; + public static final int particle_roughspheres = 3; + public static final int particle_spheres = 4; + public static final int particle_water = 32768; + public static final int pathproperty_automatic_orientation = 8; + public static final int pathproperty_closed_path = 4; + public static final int pathproperty_flat_path = 64; + public static final int pathproperty_keep_x_up = 2048; + public static final int pathproperty_show_line = 1; + public static final int pathproperty_show_orientation = 2; + public static final int pathproperty_show_position = 128; + public static final int physics_bullet = 0; + public static final int physics_mujoco = 4; + public static final int physics_newton = 3; + public static final int physics_ode = 1; + public static final int physics_physx = 5; + public static final int physics_vortex = 2; + public static final int plugininfo_builddatestr = 1; + public static final int plugininfo_extversionint = 2; + public static final int plugininfo_extversionstr = 0; + public static final int plugininfo_statusbarverbosity = 4; + public static final int plugininfo_verbosity = 3; + public static final int primitiveshape_capsule = 8; + public static final int primitiveshape_cone = 6; + public static final int primitiveshape_cuboid = 3; + public static final int primitiveshape_cylinder = 5; + public static final int primitiveshape_disc = 2; + public static final int primitiveshape_heightfield = 7; + public static final int primitiveshape_none = 0; + public static final int primitiveshape_plane = 1; + public static final int primitiveshape_spheroid = 4; + public static final int proximitysensor_cone_subtype = 33; + public static final int proximitysensor_cylinder_subtype = 31; + public static final int proximitysensor_disc_subtype = 32; + public static final int proximitysensor_pyramid_subtype = 30; + public static final int proximitysensor_ray_subtype = 34; + public static final int proxintparam_entity_to_detect = 4002; + public static final int proxintparam_ray_invisibility = 4000; + public static final int proxintparam_volume_type = 4001; + public static final int pure_primitive_cone = 6; + public static final int pure_primitive_cuboid = 3; + public static final int pure_primitive_cylinder = 5; + public static final int pure_primitive_disc = 2; + public static final int pure_primitive_heightfield = 7; + public static final int pure_primitive_none = 0; + public static final int pure_primitive_plane = 1; + public static final int pure_primitive_spheroid = 4; + public static final int rml_disable_extremum_motion_states_calc = 0; + public static final int rml_keep_current_vel_if_fallback_strategy = 0; + public static final int rml_keep_target_vel = 0; + public static final int rml_no_sync = 3; + public static final int rml_only_phase_sync = 1; + public static final int rml_only_time_sync = 1; + public static final int rml_phase_sync_if_possible = 0; + public static final int rml_recompute_trajectory = 0; + public static final int ruckig_minaccel = 512; + public static final int ruckig_minvel = 256; + public static final int ruckig_nosync = 3; + public static final int ruckig_phasesync = 0; + public static final int ruckig_timesync = 1; + public static final int script_call_error = 16; + public static final int script_lua_error = 8; + public static final int script_main_not_called = 2; + public static final int script_main_script_nonexistent = 1; + public static final int script_no_error = 0; + public static final int script_reentrance_error = 4; + public static final int scriptattribute_debuglevel = 6; + public static final int scriptattribute_enabled = 4; + public static final int scriptattribute_executioncount = 2; + public static final int scriptattribute_executionorder = 1; + public static final int scriptattribute_scripthandle = 8; + public static final int scriptattribute_scripttype = 7; + public static final int scriptdebug_allcalls = 3; + public static final int scriptdebug_callsandvars = 5; + public static final int scriptdebug_none = 0; + public static final int scriptdebug_syscalls = 1; + public static final int scriptdebug_vars = 4; + public static final int scriptdebug_vars_interval = 2; + public static final int scriptexecorder_first = 0; + public static final int scriptexecorder_last = 2; + public static final int scriptexecorder_normal = 1; + public static final int scriptintparam_autorestartonerror = 7; + public static final int scriptintparam_enabled = 4; + public static final int scriptintparam_execcount = 1; + public static final int scriptintparam_execorder = 0; + public static final int scriptintparam_handle = 3; + public static final int scriptintparam_lang = 6; + public static final int scriptintparam_objecthandle = 5; + public static final int scriptintparam_type = 2; + public static final int scriptstringparam_description = 0; + public static final int scriptstringparam_name = 1; + public static final int scriptstringparam_nameext = 3; + public static final int scriptstringparam_text = 2; + public static final int scriptthreadresume_actuation_first = 1; + public static final int scriptthreadresume_actuation_last = 2; + public static final int scriptthreadresume_allnotyetresumed = -1; + public static final int scriptthreadresume_custom = 5; + public static final int scriptthreadresume_default = 0; + public static final int scriptthreadresume_sensing_first = 3; + public static final int scriptthreadresume_sensing_last = 4; + public static final int scripttype_addonfunction = 3; + public static final int scripttype_addonscript = 2; + public static final int scripttype_childscript = 1; + public static final int scripttype_customizationscript = 6; + public static final int scripttype_mainscript = 0; + public static final int scripttype_sandboxscript = 8; + public static final int scripttype_threaded = 240; + public static final int shape_multishape_subtype = 21; + public static final int shape_simpleshape_subtype = 20; + public static final int shapefloatparam_edge_angle = 3026; + public static final int shapefloatparam_init_ang_velocity_x = 3020; + public static final int shapefloatparam_init_ang_velocity_y = 3021; + public static final int shapefloatparam_init_ang_velocity_z = 3022; + public static final int shapefloatparam_init_velocity_a = 3020; + public static final int shapefloatparam_init_velocity_b = 3021; + public static final int shapefloatparam_init_velocity_g = 3022; + public static final int shapefloatparam_init_velocity_x = 3000; + public static final int shapefloatparam_init_velocity_y = 3001; + public static final int shapefloatparam_init_velocity_z = 3002; + public static final int shapefloatparam_mass = 3005; + public static final int shapefloatparam_shading_angle = 3025; + public static final int shapefloatparam_texture_a = 3009; + public static final int shapefloatparam_texture_b = 3010; + public static final int shapefloatparam_texture_g = 3011; + public static final int shapefloatparam_texture_scaling_x = 3012; + public static final int shapefloatparam_texture_scaling_y = 3013; + public static final int shapefloatparam_texture_x = 3006; + public static final int shapefloatparam_texture_y = 3007; + public static final int shapefloatparam_texture_z = 3008; + public static final int shapeintparam_component_cnt = 3028; + public static final int shapeintparam_compound = 3016; + public static final int shapeintparam_convex = 3017; + public static final int shapeintparam_convex_check = 3018; + public static final int shapeintparam_culling = 3014; + public static final int shapeintparam_edge_borders_hidden = 3027; + public static final int shapeintparam_edge_visibility = 3024; + public static final int shapeintparam_kinematic = 3030; + public static final int shapeintparam_respondable = 3004; + public static final int shapeintparam_respondable_mask = 3019; + public static final int shapeintparam_respondablesuspendcnt = 3031; + public static final int shapeintparam_sleepmodestart = 3029; + public static final int shapeintparam_static = 3003; + public static final int shapeintparam_wireframe = 3015; + public static final int shapestringparam_color_name = 3023; + public static final int shapestringparam_colorname = 3032; + public static final int sim_lang_lua = 0; + public static final int sim_lang_python = 1; + public static final int sim_lang_undefined = -1; + public static final int simulation_advancing = 16; + public static final int simulation_advancing_abouttostop = 21; + public static final int simulation_advancing_firstafterpause = 20; + public static final int simulation_advancing_firstafterstop = 16; + public static final int simulation_advancing_lastbeforepause = 19; + public static final int simulation_advancing_lastbeforestop = 22; + public static final int simulation_advancing_running = 17; + public static final int simulation_paused = 8; + public static final int simulation_stopped = 0; + public static final int stream_transf_cumulative = 3; + public static final int stream_transf_derivative = 1; + public static final int stream_transf_integral = 2; + public static final int stream_transf_raw = 0; + public static final int stringparam_additionalpythonpath = 135; + public static final int stringparam_addondir = 143; + public static final int stringparam_addonpath = 131; + public static final int stringparam_app_arg1 = 2; + public static final int stringparam_app_arg2 = 3; + public static final int stringparam_app_arg3 = 4; + public static final int stringparam_app_arg4 = 5; + public static final int stringparam_app_arg5 = 6; + public static final int stringparam_app_arg6 = 7; + public static final int stringparam_app_arg7 = 8; + public static final int stringparam_app_arg8 = 9; + public static final int stringparam_app_arg9 = 10; + public static final int stringparam_application_path = 0; + public static final int stringparam_datadir = 129; + public static final int stringparam_defaultpython = 134; + public static final int stringparam_dlgverbosity = 123; + public static final int stringparam_importexportdir = 130; + public static final int stringparam_legacymachinetag = 142; + public static final int stringparam_logfilter = 124; + public static final int stringparam_luadir = 136; + public static final int stringparam_machine_id = 119; + public static final int stringparam_machine_id_legacy = 120; + public static final int stringparam_modeldefaultdir = 133; + public static final int stringparam_mujocodir = 138; + public static final int stringparam_pythondir = 137; + public static final int stringparam_remoteapi_temp_file_dir = 16; + public static final int stringparam_resourcesdir = 141; + public static final int stringparam_sandboxlang = 144; + public static final int stringparam_scene_name = 15; + public static final int stringparam_scene_path = 14; + public static final int stringparam_scene_path_and_name = 13; + public static final int stringparam_scene_unique_id = 118; + public static final int stringparam_scenedefaultdir = 132; + public static final int stringparam_statusbarverbosity = 122; + public static final int stringparam_systemdir = 140; + public static final int stringparam_tempdir = 127; + public static final int stringparam_tempscenedir = 128; + public static final int stringparam_uniqueid = 126; + public static final int stringparam_usersettingsdir = 139; + public static final int stringparam_verbosity = 121; + public static final int stringparam_video_filename = 1; + public static final int syscb_actuation = 6; + public static final int syscb_aftercopy = 14; + public static final int syscb_aftercreate = 26; + public static final int syscb_afterdelete = 25; + public static final int syscb_afterinstanceswitch = 12; + public static final int syscb_aftersimulation = 5; + public static final int syscb_aos_resume = 17; + public static final int syscb_aos_run = 15; + public static final int syscb_aos_suspend = 16; + public static final int syscb_beforecopy = 13; + public static final int syscb_beforedelete = 24; + public static final int syscb_beforeinstanceswitch = 11; + public static final int syscb_beforemainscript = 29; + public static final int syscb_beforesimulation = 4; + public static final int syscb_cleanup = 1; + public static final int syscb_contact = 41; + public static final int syscb_contactcallback = 19; + public static final int syscb_customcallback1 = 20; + public static final int syscb_customcallback2 = 21; + public static final int syscb_customcallback3 = 22; + public static final int syscb_customcallback4 = 23; + public static final int syscb_data = 45; + public static final int syscb_dyn = 40; + public static final int syscb_dyncallback = 28; + public static final int syscb_init = 2; + public static final int syscb_joint = 42; + public static final int syscb_jointcallback = 18; + public static final int syscb_moduleentry = 33; + public static final int syscb_nonsimulation = 3; + public static final int syscb_regular = 6; + public static final int syscb_resume = 10; + public static final int syscb_selchange = 44; + public static final int syscb_sensing = 7; + public static final int syscb_suspend = 9; + public static final int syscb_suspended = 8; + public static final int syscb_thread = 43; + public static final int syscb_trigger = 31; + public static final int syscb_userconfig = 32; + public static final int syscb_vision = 30; + public static final int texturemap_cube = 3; + public static final int texturemap_cylinder = 1; + public static final int texturemap_plane = 0; + public static final int texturemap_sphere = 2; + public static final int verbosity_debug = 600; + public static final int verbosity_default = 400; + public static final int verbosity_errors = 200; + public static final int verbosity_infos = 500; + public static final int verbosity_loadinfos = 400; + public static final int verbosity_msgs = 450; + public static final int verbosity_none = 100; + public static final int verbosity_onlyterminal = 65536; + public static final int verbosity_questions = 410; + public static final int verbosity_scripterrors = 420; + public static final int verbosity_scriptinfos = 450; + public static final int verbosity_scriptwarnings = 430; + public static final int verbosity_trace = 700; + public static final int verbosity_traceall = 900; + public static final int verbosity_tracelua = 800; + public static final int verbosity_undecorated = 61440; + public static final int verbosity_useglobal = -1; + public static final int verbosity_warnings = 300; + public static final int visionfarrayparam_viewfrustum = 1019; + public static final int visionfloatparam_far_clipping = 1001; + public static final int visionfloatparam_near_clipping = 1000; + public static final int visionfloatparam_ortho_size = 1005; + public static final int visionfloatparam_perspective_angle = 1004; + public static final int visionfloatparam_pov_aperture = 1015; + public static final int visionfloatparam_pov_blur_distance = 1014; + public static final int visionintparam_depthignored = 1020; + public static final int visionintparam_disabled_light_components = 1006; + public static final int visionintparam_entity_to_render = 1008; + public static final int visionintparam_perspective_operation = 1018; + public static final int visionintparam_pov_blur_sampled = 1016; + public static final int visionintparam_pov_focal_blur = 1013; + public static final int visionintparam_render_mode = 1017; + public static final int visionintparam_rendering_attributes = 1007; + public static final int visionintparam_resolution_x = 1002; + public static final int visionintparam_resolution_y = 1003; + public static final int visionintparam_rgbignored = 1020; + public static final int visionintparam_windowed_pos_x = 1011; + public static final int visionintparam_windowed_pos_y = 1012; + public static final int visionintparam_windowed_size_x = 1009; + public static final int visionintparam_windowed_size_y = 1010; + public static final int volume_cone = 3; + public static final int volume_cylinder = 1; + public static final int volume_disc = 2; + public static final int volume_pyramid = 0; + public static final int volume_randomizedray = 5; + public static final int volume_ray = 4; + public static final int vortex_body_adhesiveforce = 24015; + public static final int vortex_body_angularvelocitydamping = 24017; + public static final int vortex_body_autoangulardamping = 26009; + public static final int vortex_body_autoangulardampingtensionratio = 24033; + public static final int vortex_body_autosleepangularaccelthreshold = 24031; + public static final int vortex_body_autosleepangularspeedthreshold = 24030; + public static final int vortex_body_autosleeplinearaccelthreshold = 24029; + public static final int vortex_body_autosleeplinearspeedthreshold = 24028; + public static final int vortex_body_autosleepsteplivethreshold = 25007; + public static final int vortex_body_autoslip = 26005; + public static final int vortex_body_bitcoded = 25006; + public static final int vortex_body_compliance = 24011; + public static final int vortex_body_convexshapesasrandom = 26002; + public static final int vortex_body_damping = 24012; + public static final int vortex_body_fastmoving = 26004; + public static final int vortex_body_linearvelocitydamping = 24016; + public static final int vortex_body_materialuniqueid = 25008; + public static final int vortex_body_normalangularaxisfriction = 24005; + public static final int vortex_body_normalangularaxisfrictionmodel = 25005; + public static final int vortex_body_normalangularaxisslide = 24022; + public static final int vortex_body_normalangularaxisslip = 24027; + public static final int vortex_body_normalangularaxisstaticfrictionscale = 24010; + public static final int vortex_body_normalmangulararaxisfrictionmodel = 25005; + public static final int vortex_body_normangaxissameasprimangaxis = 26008; + public static final int vortex_body_primangulararaxisfrictionmodel = 25003; + public static final int vortex_body_primangularaxisfriction = 24003; + public static final int vortex_body_primangularaxisslide = 24020; + public static final int vortex_body_primangularaxisslip = 24025; + public static final int vortex_body_primangularaxisstaticfrictionscale = 24008; + public static final int vortex_body_primaxisvectorx = 24034; + public static final int vortex_body_primaxisvectory = 24035; + public static final int vortex_body_primaxisvectorz = 24036; + public static final int vortex_body_primlinearaxisfriction = 24001; + public static final int vortex_body_primlinearaxisfrictionmodel = 25001; + public static final int vortex_body_primlinearaxisslide = 24018; + public static final int vortex_body_primlinearaxisslip = 24023; + public static final int vortex_body_primlinearaxisstaticfrictionscale = 24006; + public static final int vortex_body_pureshapesasconvex = 26001; + public static final int vortex_body_randomshapesasterrain = 26003; + public static final int vortex_body_restitution = 24013; + public static final int vortex_body_restitutionthreshold = 24014; + public static final int vortex_body_secangaxissameasprimangaxis = 26007; + public static final int vortex_body_secangularaxisfriction = 24004; + public static final int vortex_body_secangularaxisfrictionmodel = 25004; + public static final int vortex_body_secangularaxisslide = 24021; + public static final int vortex_body_secangularaxisslip = 24026; + public static final int vortex_body_secangularaxisstaticfrictionscale = 24009; + public static final int vortex_body_seclinaxissameasprimlinaxis = 26006; + public static final int vortex_body_seclinearaxisfriction = 24002; + public static final int vortex_body_seclinearaxisfrictionmodel = 25002; + public static final int vortex_body_seclinearaxisslide = 24019; + public static final int vortex_body_seclinearaxisslip = 24024; + public static final int vortex_body_seclinearaxisstaticfrictionscale = 24007; + public static final int vortex_body_secmangulararaxisfrictionmodel = 25004; + public static final int vortex_body_skinthickness = 24032; + public static final int vortex_bodyfrictionmodel_box = 0; + public static final int vortex_bodyfrictionmodel_neutral = 5; + public static final int vortex_bodyfrictionmodel_none = 6; + public static final int vortex_bodyfrictionmodel_prophigh = 3; + public static final int vortex_bodyfrictionmodel_proplow = 2; + public static final int vortex_bodyfrictionmodel_scaledbox = 1; + public static final int vortex_bodyfrictionmodel_scaledboxfast = 4; + public static final int vortex_global_autosleep = 20001; + public static final int vortex_global_bitcoded = 19001; + public static final int vortex_global_computeinertias = 20005; + public static final int vortex_global_constraintangularcompliance = 18007; + public static final int vortex_global_constraintangulardamping = 18008; + public static final int vortex_global_constraintangularkineticloss = 18009; + public static final int vortex_global_constraintlinearcompliance = 18004; + public static final int vortex_global_constraintlineardamping = 18005; + public static final int vortex_global_constraintlinearkineticloss = 18006; + public static final int vortex_global_contacttolerance = 18003; + public static final int vortex_global_internalscalingfactor = 18002; + public static final int vortex_global_multithreading = 20002; + public static final int vortex_global_stepsize = 18001; + public static final int vortex_joint_a0damping = 21032; + public static final int vortex_joint_a0frictioncoeff = 21033; + public static final int vortex_joint_a0frictionloss = 21035; + public static final int vortex_joint_a0frictionmaxforce = 21034; + public static final int vortex_joint_a0loss = 21030; + public static final int vortex_joint_a0stiffness = 21031; + public static final int vortex_joint_a1damping = 21038; + public static final int vortex_joint_a1frictioncoeff = 21039; + public static final int vortex_joint_a1frictionloss = 21041; + public static final int vortex_joint_a1frictionmaxforce = 21040; + public static final int vortex_joint_a1loss = 21036; + public static final int vortex_joint_a1stiffness = 21037; + public static final int vortex_joint_a2damping = 21044; + public static final int vortex_joint_a2frictioncoeff = 21045; + public static final int vortex_joint_a2frictionloss = 21047; + public static final int vortex_joint_a2frictionmaxforce = 21046; + public static final int vortex_joint_a2loss = 21042; + public static final int vortex_joint_a2stiffness = 21043; + public static final int vortex_joint_bitcoded = 22001; + public static final int vortex_joint_dependencyfactor = 21048; + public static final int vortex_joint_dependencyoffset = 21049; + public static final int vortex_joint_dependentobjectid = 22006; + public static final int vortex_joint_frictionenabledbc = 22003; + public static final int vortex_joint_frictionproportionalbc = 22004; + public static final int vortex_joint_lowerlimitdamping = 21001; + public static final int vortex_joint_lowerlimitmaxforce = 21007; + public static final int vortex_joint_lowerlimitrestitution = 21005; + public static final int vortex_joint_lowerlimitstiffness = 21003; + public static final int vortex_joint_motorconstraintfrictioncoeff = 21009; + public static final int vortex_joint_motorconstraintfrictionloss = 21011; + public static final int vortex_joint_motorconstraintfrictionmaxforce = 21010; + public static final int vortex_joint_motorfrictionenabled = 23001; + public static final int vortex_joint_objectid = 22005; + public static final int vortex_joint_p0damping = 21014; + public static final int vortex_joint_p0frictioncoeff = 21015; + public static final int vortex_joint_p0frictionloss = 21017; + public static final int vortex_joint_p0frictionmaxforce = 21016; + public static final int vortex_joint_p0loss = 21012; + public static final int vortex_joint_p0stiffness = 21013; + public static final int vortex_joint_p1damping = 21020; + public static final int vortex_joint_p1frictioncoeff = 21021; + public static final int vortex_joint_p1frictionloss = 21023; + public static final int vortex_joint_p1frictionmaxforce = 21022; + public static final int vortex_joint_p1loss = 21018; + public static final int vortex_joint_p1stiffness = 21019; + public static final int vortex_joint_p2damping = 21026; + public static final int vortex_joint_p2frictioncoeff = 21027; + public static final int vortex_joint_p2frictionloss = 21029; + public static final int vortex_joint_p2frictionmaxforce = 21028; + public static final int vortex_joint_p2loss = 21024; + public static final int vortex_joint_p2stiffness = 21025; + public static final int vortex_joint_pospid1 = 21052; + public static final int vortex_joint_pospid2 = 21053; + public static final int vortex_joint_pospid3 = 21054; + public static final int vortex_joint_proportionalmotorfriction = 23002; + public static final int vortex_joint_relaxationenabledbc = 22002; + public static final int vortex_joint_upperlimitdamping = 21002; + public static final int vortex_joint_upperlimitmaxforce = 21008; + public static final int vortex_joint_upperlimitrestitution = 21006; + public static final int vortex_joint_upperlimitstiffness = 21004; + } + + public _sim sim() { + return new _sim(this.client); + } + + public class _simIK extends RemoteAPIObject + { + public _simIK(RemoteAPIClient client) + { + super(client); + } + + public Long addElement(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.addElement", args); + return ((Long)rets[0]); + } + + public Object[] addElementFromScene(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.addElementFromScene", args); + return rets; + } + + public Object[] computeGroupJacobian(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.computeGroupJacobian", args); + return rets; + } + + public Object[] computeJacobian(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.computeJacobian", args); + return rets; + } + + public Long createDebugOverlay(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.createDebugOverlay", args); + return ((Long)rets[0]); + } + + public Long createDummy(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.createDummy", args); + return ((Long)rets[0]); + } + + public Long createEnvironment(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.createEnvironment", args); + return ((Long)rets[0]); + } + + public Long createGroup(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.createGroup", args); + return ((Long)rets[0]); + } + + public Long createJoint(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.createJoint", args); + return ((Long)rets[0]); + } + + public Boolean doesGroupExist(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.doesGroupExist", args); + return ((Boolean)rets[0]); + } + + public Boolean doesObjectExist(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.doesObjectExist", args); + return ((Boolean)rets[0]); + } + + public Long duplicateEnvironment(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.duplicateEnvironment", args); + return ((Long)rets[0]); + } + + public void eraseDebugOverlay(Object... args) throws CborException + { + this.client.call("simIK.eraseDebugOverlay", args); + } + + public void eraseEnvironment(Object... args) throws CborException + { + this.client.call("simIK.eraseEnvironment", args); + } + + public void eraseObject(Object... args) throws CborException + { + this.client.call("simIK.eraseObject", args); + } + + public List findConfig(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.findConfig", args); + return ((List)rets[0]); + } + + public List generatePath(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.generatePath", args); + return ((List)rets[0]); + } + + public List getAlternateConfigs(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getAlternateConfigs", args); + return ((List)rets[0]); + } + + public Object[] getElementBase(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getElementBase", args); + return rets; + } + + public Long getElementConstraints(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getElementConstraints", args); + return ((Long)rets[0]); + } + + public Long getElementFlags(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getElementFlags", args); + return ((Long)rets[0]); + } + + public List getElementPrecision(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getElementPrecision", args); + return ((List)rets[0]); + } + + public List getElementWeights(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getElementWeights", args); + return ((List)rets[0]); + } + + public String getFailureDescription(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getFailureDescription", args); + return ((String)rets[0]); + } + + public Object[] getGroupCalculation(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getGroupCalculation", args); + return rets; + } + + public Long getGroupFlags(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getGroupFlags", args); + return ((Long)rets[0]); + } + + public Long getGroupHandle(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getGroupHandle", args); + return ((Long)rets[0]); + } + + public Object[] getGroupJointLimitHits(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getGroupJointLimitHits", args); + return rets; + } + + public List getGroupJoints(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getGroupJoints", args); + return ((List)rets[0]); + } + + public Object[] getJointDependency(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointDependency", args); + return rets; + } + + public Object[] getJointInterval(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointInterval", args); + return rets; + } + + public Double getJointLimitMargin(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointLimitMargin", args); + return ((Double)rets[0]); + } + + public List getJointMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointMatrix", args); + return ((List)rets[0]); + } + + public Double getJointMaxStepSize(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointMaxStepSize", args); + return ((Double)rets[0]); + } + + public Long getJointMode(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointMode", args); + return ((Long)rets[0]); + } + + public Double getJointPosition(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointPosition", args); + return ((Double)rets[0]); + } + + public Double getJointScrewLead(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointScrewLead", args); + return ((Double)rets[0]); + } + + public Object[] getJointTransformation(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointTransformation", args); + return rets; + } + + public Long getJointType(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointType", args); + return ((Long)rets[0]); + } + + public Double getJointWeight(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getJointWeight", args); + return ((Double)rets[0]); + } + + public Long getObjectHandle(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectHandle", args); + return ((Long)rets[0]); + } + + public List getObjectMatrix(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectMatrix", args); + return ((List)rets[0]); + } + + public Long getObjectParent(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectParent", args); + return ((Long)rets[0]); + } + + public List getObjectPose(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectPose", args); + return ((List)rets[0]); + } + + public Object[] getObjectTransformation(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectTransformation", args); + return rets; + } + + public Long getObjectType(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjectType", args); + return ((Long)rets[0]); + } + + public Object[] getObjects(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getObjects", args); + return rets; + } + + public Long getTargetDummy(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.getTargetDummy", args); + return ((Long)rets[0]); + } + + public Object[] handleGroup(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.handleGroup", args); + return rets; + } + + public Object[] handleGroups(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.handleGroups", args); + return rets; + } + + public void load(Object... args) throws CborException + { + this.client.call("simIK.load", args); + } + + public String save(Object... args) throws CborException + { + Object[] rets = this.client.call("simIK.save", args); + return ((String)rets[0]); + } + + public void setElementBase(Object... args) throws CborException + { + this.client.call("simIK.setElementBase", args); + } + + public void setElementConstraints(Object... args) throws CborException + { + this.client.call("simIK.setElementConstraints", args); + } + + public void setElementFlags(Object... args) throws CborException + { + this.client.call("simIK.setElementFlags", args); + } + + public void setElementPrecision(Object... args) throws CborException + { + this.client.call("simIK.setElementPrecision", args); + } + + public void setElementWeights(Object... args) throws CborException + { + this.client.call("simIK.setElementWeights", args); + } + + public void setGroupCalculation(Object... args) throws CborException + { + this.client.call("simIK.setGroupCalculation", args); + } + + public void setGroupFlags(Object... args) throws CborException + { + this.client.call("simIK.setGroupFlags", args); + } + + public void setJointDependency(Object... args) throws CborException + { + this.client.call("simIK.setJointDependency", args); + } + + public void setJointInterval(Object... args) throws CborException + { + this.client.call("simIK.setJointInterval", args); + } + + public void setJointLimitMargin(Object... args) throws CborException + { + this.client.call("simIK.setJointLimitMargin", args); + } + + public void setJointMaxStepSize(Object... args) throws CborException + { + this.client.call("simIK.setJointMaxStepSize", args); + } + + public void setJointMode(Object... args) throws CborException + { + this.client.call("simIK.setJointMode", args); + } + + public void setJointPosition(Object... args) throws CborException + { + this.client.call("simIK.setJointPosition", args); + } + + public void setJointScrewLead(Object... args) throws CborException + { + this.client.call("simIK.setJointScrewLead", args); + } + + public void setJointWeight(Object... args) throws CborException + { + this.client.call("simIK.setJointWeight", args); + } + + public void setObjectMatrix(Object... args) throws CborException + { + this.client.call("simIK.setObjectMatrix", args); + } + + public void setObjectParent(Object... args) throws CborException + { + this.client.call("simIK.setObjectParent", args); + } + + public void setObjectPose(Object... args) throws CborException + { + this.client.call("simIK.setObjectPose", args); + } + + public void setObjectTransformation(Object... args) throws CborException + { + this.client.call("simIK.setObjectTransformation", args); + } + + public void setSphericalJointMatrix(Object... args) throws CborException + { + this.client.call("simIK.setSphericalJointMatrix", args); + } + + public void setSphericalJointRotation(Object... args) throws CborException + { + this.client.call("simIK.setSphericalJointRotation", args); + } + + public void setTargetDummy(Object... args) throws CborException + { + this.client.call("simIK.setTargetDummy", args); + } + + public void syncFromSim(Object... args) throws CborException + { + this.client.call("simIK.syncFromSim", args); + } + + public void syncToSim(Object... args) throws CborException + { + this.client.call("simIK.syncToSim", args); + } + + } + + public _simIK simIK() { + return new _simIK(this.client); + } + +} diff --git a/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/objects/special/_sim.java b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/objects/special/_sim.java new file mode 100644 index 0000000..d650821 --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/DemoBVProject/src/main/java/remoteapi/zmq/objects/special/_sim.java @@ -0,0 +1,19 @@ +package remoteapi.zmq.objects.special; + +import co.nstant.in.cbor.CborException; + +import remoteapi.zmq.RemoteAPIClient; +import remoteapi.zmq.RemoteAPIObject; + +public class _sim extends RemoteAPIObject +{ + public _sim(RemoteAPIClient client) + { + super(client); + } + + public Object[] callScriptFunction(Object... args) throws CborException + { + return this.client.call("sim.callScriptFunction", args); + } +} diff --git a/0_ - DemoBraitenbergVehicles/README.md b/0_ - DemoBraitenbergVehicles/README.md new file mode 100644 index 0000000..4899e4d --- /dev/null +++ b/0_ - DemoBraitenbergVehicles/README.md @@ -0,0 +1,41 @@ +# `CST Action Selection Educative Experiment` + + +This project implements the Vehicle proposed in (BRAINTENBERG, 1986) as an experiment of action selection using CST. + +This project was developed as part of the Cognitive Architectures research line from +the Hub for Artificial Intelligence and Cognitive Architectures (H.IAAC) of the State University of Campinas (UNICAMP). +See more projects from the group [here](https://github.com/brgsil/RepoOrganizer). + +[![](https://img.shields.io/badge/-H.IAAC-eb901a?style=for-the-badge&labelColor=black)](https://hiaac.unicamp.br/) +[![](https://img.shields.io/badge/-Arq.Cog-black?style=for-the-badge&labelColor=white&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4gPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1Ni4wMDQiIGhlaWdodD0iNTYiIHZpZXdCb3g9IjAgMCA1Ni4wMDQgNTYiPjxwYXRoIGlkPSJhcnFjb2ctMiIgZD0iTTk1NS43NzQsMjc0LjJhNi41Nyw2LjU3LDAsMCwxLTYuNTItNmwtLjA5MS0xLjE0NS04LjEtMi41LS42ODksMS4xMjNhNi41NCw2LjU0LDAsMCwxLTExLjEzNi4wMjEsNi41Niw2LjU2LDAsMCwxLDEuMzY4LTguNDQxbC44LS42NjUtMi4xNS05LjQ5MS0xLjIxNy0uMTJhNi42NTUsNi42NTUsMCwwLDEtMi41OS0uODIyLDYuNTI4LDYuNTI4LDAsMCwxLTIuNDQzLTguOSw2LjU1Niw2LjU1NiwwLDAsMSw1LjctMy4zLDYuNDU2LDYuNDU2LDAsMCwxLDIuNDU4LjQ4M2wxLC40MSw2Ljg2Ny02LjM2Ni0uNDg4LTEuMTA3YTYuNTMsNi41MywwLDAsMSw1Ljk3OC05LjE3Niw2LjU3NSw2LjU3NSwwLDAsMSw2LjUxOCw2LjAxNmwuMDkyLDEuMTQ1LDguMDg3LDIuNS42ODktMS4xMjJhNi41MzUsNi41MzUsMCwxLDEsOS4yODksOC43ODZsLS45NDcuNjUyLDIuMDk1LDkuMjE4LDEuMzQzLjAxM2E2LjUwNyw2LjUwNywwLDAsMSw1LjYwOSw5LjcyMSw2LjU2MSw2LjU2MSwwLDAsMS01LjcsMy4zMWgwYTYuNCw2LjQsMCwwLDEtMi45ODctLjczMmwtMS4wNjEtLjU1LTYuNjgsNi4xOTIuNjM0LDEuMTU5YTYuNTM1LDYuNTM1LDAsMCwxLTUuNzI1LDkuNjkxWm0wLTExLjQ2MWE0Ljk1LDQuOTUsMCwxLDAsNC45NTIsNC45NUE0Ljk1Nyw0Ljk1NywwLDAsMCw5NTUuNzc0LDI2Mi43MzlaTTkzNC44LDI1Ny4zMjVhNC45NTIsNC45NTIsMCwxLDAsNC4yMjEsMi4zNDVBNC45Myw0LjkzLDAsMCwwLDkzNC44LDI1Ny4zMjVabS0uMDIyLTEuNThhNi41MTQsNi41MTQsMCwwLDEsNi41NDksNi4xTDk0MS40LDI2M2w4LjA2MSwyLjUuNjg0LTEuMTQ1YTYuNTkxLDYuNTkxLDAsMCwxLDUuNjI0LTMuMjA2LDYuNDQ4LDYuNDQ4LDAsMCwxLDIuODQ0LjY1bDEuMDQ5LjUxOSw2LjczNC02LjI1MS0uNTkzLTEuMTQ1YTYuNTI1LDYuNTI1LDAsMCwxLC4xMTUtNi4yMjksNi42MTgsNi42MTgsMCwwLDEsMS45NjYtMi4xMzRsLjk0NC0uNjUyLTIuMDkzLTkuMjIyLTEuMzM2LS4wMThhNi41MjEsNi41MjEsMCwwLDEtNi40MjktNi4xbC0uMDc3LTEuMTY1LTguMDc0LTIuNS0uNjg0LDEuMTQ4YTYuNTM0LDYuNTM0LDAsMCwxLTguOTY2LDIuMjY0bC0xLjA5MS0uNjUyLTYuNjE3LDYuMTMxLjc1MSwxLjE5MmE2LjUxOCw2LjUxOCwwLDAsMS0yLjMsOS4xNjRsLTEuMS42MTksMi4wNiw5LjA4NywxLjQ1MS0uMUM5MzQuNDc1LDI1NS43NSw5MzQuNjI2LDI1NS43NDQsOTM0Ljc3OSwyNTUuNzQ0Wm0zNi44NDQtOC43NjJhNC45NzcsNC45NzcsMCwwLDAtNC4zMTYsMi41LDQuODg5LDQuODg5LDAsMCwwLS40NjQsMy43NjIsNC45NDgsNC45NDgsMCwxLDAsNC43NzktNi4yNjZaTTkyOC43LDIzNS41MzNhNC45NzksNC45NzksMCwwLDAtNC4zMTcsMi41LDQuOTQ4LDQuOTQ4LDAsMCwwLDQuMjkxLDcuMzkxLDQuOTc1LDQuOTc1LDAsMCwwLDQuMzE2LTIuNSw0Ljg4Miw0Ljg4MiwwLDAsMCwuNDY0LTMuNzYxLDQuOTQsNC45NCwwLDAsMC00Ljc1NC0zLjYzWm0zNi43NzYtMTAuMzQ2YTQuOTUsNC45NSwwLDEsMCw0LjIyMiwyLjM0NUE0LjkyMyw0LjkyMywwLDAsMCw5NjUuNDc5LDIyNS4xODdabS0yMC45NTItNS40MTVhNC45NTEsNC45NTEsMCwxLDAsNC45NTEsNC45NTFBNC45NTcsNC45NTcsMCwwLDAsOTQ0LjUyNywyMTkuNzcyWiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTkyMi4xNDMgLTIxOC4yKSIgZmlsbD0iIzgzMDNmZiI+PC9wYXRoPjwvc3ZnPiA=)](https://github.com/brgsil/RepoOrganizer) + +## Repository Structure + +- ActionSelection: Projeto contendo o experimento +- Scene: Contém a scene para uso no CoppeliaSim + + +## Dependencies / Requirements + +- CoppeliaSim 4.6.0 +- Netbeans 21 + +## Installation / Usage + +Open the scene *vehicleSimulationPositionTrasmissionViaRemoteApi.ttt* with CoppeliSim. +Build and run the Action Selection project with Netbeans. + +## Citation + +BRAITENBERG, Valentino. Vehicles: Experiments in synthetic psychology. MIT press, 1986. + + +## Authors + + +- (2024-2024) Karen Lima: Masters Candidate, UNICAMP + +## Acknowledgements + +This project is part of the Hub for Artificial Intelligence and Cognitive Architectures (H.IAAC- Hub de Inteligência Artificial e Arquiteturas Cognitivas). Project supported by the brazilian Ministry of Science, Technology and Innovations, with resources from Law No. 8,248, of October 23, 1991. \ No newline at end of file diff --git a/0_ - DemoBraitenbergVehicles/Scene/vehicleSimulationPositionTrasmissionViaRemoteApiWalls.ttt b/0_ - DemoBraitenbergVehicles/Scene/vehicleSimulationPositionTrasmissionViaRemoteApiWalls.ttt new file mode 100644 index 0000000..24e7c6e Binary files /dev/null and b/0_ - DemoBraitenbergVehicles/Scene/vehicleSimulationPositionTrasmissionViaRemoteApiWalls.ttt differ diff --git a/0_ - DemoCSTCore/.gitignore b/0_ - DemoCSTCore/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoCSTCore/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/.gitignore b/0_ - DemoCSTCore/DemoCSTCoreProject/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/LICENSE b/0_ - DemoCSTCore/DemoCSTCoreProject/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/build.gradle b/0_ - DemoCSTCore/DemoCSTCoreProject/build.gradle new file mode 100644 index 0000000..83850f8 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/build.gradle @@ -0,0 +1,52 @@ + + + +apply plugin: 'application' +mainClassName = 'ExperimentMain' +version = '0.0.4' + +//sourceCompatibility = '1.8' +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +if (!hasProperty('mainClass')) { + ext.mainClass = 'ExperimentMain' +} + +repositories { + mavenCentral() + maven { + url "https://github.com/rosjava/rosjava_mvn_repo/raw/master" + } + maven { url 'https://jitpack.io' } + maven { + url 'https://cst-group.github.io/cst-dependencies/maven-repo/' + } +} + +dependencies { + implementation 'com.github.CST-Group:cst-desktop:36588ca' + implementation 'com.github.CST-Group:WS3DProxy:0.0.4' + implementation 'org.json:json:20180813' + testImplementation group: 'junit', name: 'junit', version: '4.10' +} + +run { + main = mainClassName + args = project.hasProperty('args') ? project.args.split(' ') : [] +} + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archiveClassifier = 'full' + manifest { + attributes( + 'Main-Class': mainClassName + ) + } + from sourceSets.main.output + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } + } + exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' +} \ No newline at end of file diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/gradle.properties b/0_ - DemoCSTCore/DemoCSTCoreProject/gradle.properties new file mode 100644 index 0000000..616521b --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/gradle.properties @@ -0,0 +1,4 @@ +action.run.args=${javaExec.workingDir} ${javaExec.environment} run ${javaExec.jvmArgs} ${javaExec.args} +org.gradle.parallel=true +org.gradle.daemon=true +netbeans.hint.jdkPlatform=JDK_21 diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/gradle/wrapper/gradle-wrapper.jar b/0_ - DemoCSTCore/DemoCSTCoreProject/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..457aad0 Binary files /dev/null and b/0_ - DemoCSTCore/DemoCSTCoreProject/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/0_ - DemoCSTCore/DemoCSTCoreProject/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/wrapper/gradle-wrapper.properties rename to 0_ - DemoCSTCore/DemoCSTCoreProject/gradle/wrapper/gradle-wrapper.properties diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew b/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew new file mode 100755 index 0000000..af6708f --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew.bat b/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew.bat new file mode 100644 index 0000000..0f8d593 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/settings.gradle b/0_ - DemoCSTCore/DemoCSTCoreProject/settings.gradle new file mode 100644 index 0000000..bf16fd2 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'DemoCSTCore' diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/AgentMind.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/AgentMind.java new file mode 100644 index 0000000..8620313 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/AgentMind.java @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.CodeletContainer; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.Mind; +import br.unicamp.cst.representation.idea.Idea; +import codelets.behaviors.EatClosestApple; +import codelets.behaviors.Explore; +import codelets.behaviors.GoToClosestApple; +import codelets.motor.HandsActionCodelet; +import codelets.motor.LegsActionCodelet; +import codelets.perception.AppleDetector; +import codelets.perception.ClosestAppleDetector; +import codelets.sensors.InnerSense; +import codelets.sensors.Vision; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import static support.Constants.*; +import ws3dproxy.model.Creature; +import ws3dproxy.model.Thing; +/** + * + * @author rgudwin + */ +public class AgentMind extends Mind { + + private static int creatureBasicSpeed=3; + private static int reachDistance=50; + public ArrayList behavioralCodelets = new ArrayList(); + public String name; + + public AgentMind(Creature creature, String name) { + super(); + this.name = name; + + // Create CodeletGroups and MemoryGroups for organizing Codelets and Memories + createCodeletGroup(SENSORY); + createCodeletGroup(MOTOR); + createCodeletGroup(PERCEPTION); + createCodeletGroup(BEHAVIORAL); + createMemoryGroup(SENSORY); + createMemoryGroup(MOTOR); + createMemoryGroup(WORKING); + createMemoryGroup("Container"); + + // Declare Memory Objects + MemoryContainer legsMC; // This Memory is going to be a MemoryContainer + Memory legsExploreMO; + Memory legsGoToClosestAppleMO; + Memory handsMO; + Memory visionMO; + Memory innerSenseMO; + Memory closestAppleMO; + Memory knownApplesMO; + + //Initialize Memory Objects + legsMC=createMemoryContainer(LEGS); + legsExploreMO=createMemoryObject("GoToClosestApple"); + legsGoToClosestAppleMO=createMemoryObject("Explore"); + legsMC.add(legsExploreMO); + legsMC.add(legsGoToClosestAppleMO); + registerMemory(legsMC,MOTOR); + handsMO=createMemoryObject(HANDS, ""); + registerMemory(handsMO,MOTOR); + List vision_list = Collections.synchronizedList(new ArrayList()); + visionMO=createMemoryObject(VISION_MO,vision_list); + registerMemory(visionMO,SENSORY); + //CreatureInnerSense cis = new CreatureInnerSense(); + Idea cis = Idea.createIdea("cis" + name,"", Idea.guessType("AbstractObject",null,1.0,0.5)); + cis.add(Idea.createIdea("cis"+ name +".pitch", 0D, Idea.guessType("Property", null,1.0,0.5))); + cis.add(Idea.createIdea("cis"+ name +".fuel", 0D, Idea.guessType("Property", null,1.0,0.5))); + Idea position = Idea.createIdea("cis"+ name +".position","", Idea.guessType("Property",null,1.0,0.5)); + position.add(Idea.createIdea("cis"+ name +".position.x",0D,Idea.guessType("QualityDimension",null,1.0,0.5))); + position.add(Idea.createIdea("cis"+ name +".position.y",0D,Idea.guessType("QualityDimension",null,1.0,0.5))); + cis.add(position); + Idea fov = Idea.createIdea("cis"+ name +".FOV","", Idea.guessType("Property", null,1.0,0.5)); + Idea bounds = Idea.createIdea("cis"+ name +".FOV.bounds","", Idea.guessType("Property", null,1.0,0.5)); + bounds.add(Idea.createIdea("cis"+ name +".FOV.bounds.x",null, Idea.guessType("Property", null,1.0,0.5))); + bounds.add(Idea.createIdea("cis"+ name +".FOV.bounds.y",null, Idea.guessType("Property", null,1.0,0.5))); + bounds.add(Idea.createIdea("cis"+ name +".FOV.bounds.height",null, Idea.guessType("Property", null,1.0,0.5))); + bounds.add(Idea.createIdea("cis"+ name +".FOV.bounds.width",null, Idea.guessType("Property", null,1.0,0.5))); + fov.add(bounds); + fov.add(Idea.createIdea("cis"+ name +".FOV.npoints",0, Idea.guessType("Property", null,1.0,0.5))); + fov.add(Idea.createIdea("cis"+ name +".FOV.points","", Idea.guessType("Property", null,1.0,0.5))); + cis.add(fov); + innerSenseMO=createMemoryObject(INNER, cis); + registerMemory(innerSenseMO,SENSORY); + Thing closestApple = null; + closestAppleMO=createMemoryObject(CLOSEST_APPLE, closestApple); + registerMemory(closestAppleMO, WORKING); + List knownApples = Collections.synchronizedList(new ArrayList()); + knownApplesMO=createMemoryObject(KNOWN_APPLES, knownApples); + registerMemory(knownApplesMO,WORKING); + + // Create Sensor Codelets + Codelet vision=new Vision(creature); + vision.addOutput(visionMO); + insertCodelet(vision); //Creates a vision sensor + registerCodelet(vision, SENSORY); + + Codelet innerSense=new InnerSense(creature); + innerSense.addOutput(innerSenseMO); + insertCodelet(innerSense); //A sensor for the inner state of the creature + registerCodelet(innerSense,SENSORY); + + + + // Create Perception Codelets + Codelet appleDetector = new AppleDetector(); + appleDetector.addInput(visionMO); + appleDetector.addOutput(knownApplesMO); + + insertCodelet(appleDetector); + registerCodelet(appleDetector,PERCEPTION); + + Codelet closestAppleDetector = new ClosestAppleDetector(); + closestAppleDetector.addInput(knownApplesMO); + closestAppleDetector.addInput(innerSenseMO); + closestAppleDetector.addOutput(closestAppleMO); + + insertCodelet(closestAppleDetector); + registerCodelet(closestAppleDetector,PERCEPTION); + + // Create Behavior Codelets + +// CodeletContainer appleBehaviorContainer = new CodeletContainer(); +// ArrayList inputsAppleBehaviorContainer = new ArrayList<>(); +// inputsAppleBehaviorContainer.add(closestApplaeMO); +// inputsAppleBehaviorContainer.add(innerSenseMO); +// appleBehaviorContainer.setInputs(inputsAppleBehaviorContainer); + + Codelet goToClosestApple = new GoToClosestApple(creatureBasicSpeed,reachDistance); + goToClosestApple.addInput(closestAppleMO); + goToClosestApple.addInput(innerSenseMO); + goToClosestApple.addOutput(legsMC); + + insertCodelet(goToClosestApple); + registerCodelet(goToClosestApple,BEHAVIORAL); + behavioralCodelets.add(goToClosestApple); + + Codelet eatApple=new EatClosestApple(reachDistance); + eatApple.addInput(closestAppleMO); + eatApple.addInput(innerSenseMO); + eatApple.addOutput(handsMO); + eatApple.addOutput(knownApplesMO); + insertCodelet(eatApple); + registerCodelet(eatApple,BEHAVIORAL); + behavioralCodelets.add(eatApple); + + //appleBehaviorContainer.addCodelet(goToClosestApple, false); + //appleBehaviorContainer.addCodelet(eatApple, false); + + + + Codelet explore=new Explore(); + explore.addInput(knownApplesMO); + explore.addOutput(legsMC); + insertCodelet(explore); + registerCodelet(explore,BEHAVIORAL); + behavioralCodelets.add(explore); + + + // Create Actuator Codelets + Codelet legs=new LegsActionCodelet(creature); + legs.addInput(legsMC); + insertCodelet(legs); + registerCodelet(legs,MOTOR); + + + Codelet hands=new HandsActionCodelet(creature); + hands.addInput(handsMO); + insertCodelet(hands); + registerCodelet(hands,MOTOR); + +// appleDetector.setPublishSubscribe(true); +// closestAppleDetector.setPublishSubscribe(true); +// eatApple.setPublishSubscribe(true); +// goToClosestApple.setPublishSubscribe(true); +// explore.setPublishSubscribe(true); +// legs.setPublishSubscribe(true); +// hands.setPublishSubscribe(true); + + // sets a time step for running the codelets to avoid heating too much your machine + for (Codelet c : this.getCodeRack().getAllCodelets()) + c.setTimeStep(200); + + // Start Cognitive Cycle + start(); + } + +} diff --git a/src/main/java/Environment.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/Environment.java similarity index 100% rename from src/main/java/Environment.java rename to 0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/Environment.java diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/ExperimentMain.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/ExperimentMain.java new file mode 100644 index 0000000..3c6c4d7 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/ExperimentMain.java @@ -0,0 +1,49 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import br.unicamp.cst.util.viewer.MindViewer; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author rgudwin + */ +public class ExperimentMain { + public Logger logger = Logger.getLogger(ExperimentMain.class.getName()); + + public ExperimentMain(String growOption) { + Logger.getLogger("codelets").setLevel(Level.SEVERE); + // Create Environment + Environment env=new Environment(); //Creates only a creature and some apples + String creatureName = env.c.getName(); + AgentMind a1 = new AgentMind(env.c, "AgentCSTCore " + creatureName); + MindViewer mv = new MindViewer(a1,"MindViewer - AgentCSTCore " + creatureName, a1.behavioralCodelets); + mv.setVisible(true); + } + + + /** + * @param args + */ + public static void main(String[] args) { + ExperimentMain em = new ExperimentMain("grow-food"); + } + +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/EatClosestApple.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/EatClosestApple.java new file mode 100644 index 0000000..3c76c16 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/EatClosestApple.java @@ -0,0 +1,150 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.behaviors; + +import java.awt.Point; +import java.awt.geom.Point2D; + +import org.json.JSONException; +import org.json.JSONObject; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.*; +import ws3dproxy.model.Thing; + +public class EatClosestApple extends Codelet { + + private Memory closestAppleMO; + private Memory innerSenseMO; + private Memory knownMO; + private int reachDistance; + private Memory handsMO; + Thing closestApple; + Idea cis; + List known; + + public EatClosestApple(int reachDistance) { + setTimeStep(50); + this.reachDistance=reachDistance; + this.name = "EatClosestApple"; + } + + @Override + public void accessMemoryObjects() { + closestAppleMO=(MemoryObject)this.getInput(CLOSEST_APPLE); + innerSenseMO=(MemoryObject)this.getInput(INNER); + handsMO=(MemoryObject)this.getOutput(HANDS); + knownMO = (MemoryObject)this.getOutput(KNOWN_APPLES); + } + + @Override + public void proc() { + System.out.println("Executing proc eat closest apple"); + String appleName=""; + closestApple = (Thing) closestAppleMO.getI(); + cis = (Idea) innerSenseMO.getI(); + known = (List) knownMO.getI(); + //Find distance between closest apple and self + //If closer than reachDistance, eat the apple + + if(closestApple != null) + { + double appleX=0; + double appleY=0; + try { + appleX=closestApple.getCenterPosition().getX(); + appleY=closestApple.getCenterPosition().getY(); + appleName = closestApple.getName(); + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + + Point2D pApple = new Point(); + pApple.setLocation(appleX, appleY); + + Point2D pSelf = new Point(); + pSelf.setLocation(selfX, selfY); + + double distance = pSelf.distance(pApple); + JSONObject message=new JSONObject(); + try { + if(distance<=reachDistance){ //eat it + message.put(OBJECT, appleName); + message.put(ACTION, EATIT); + handsMO.setI(message.toString()); + activation=1.0; + DestroyClosestApple(); + }else{ + handsMO.setI(""); //nothing + activation=0.0; + } + +// System.out.println(message); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else{ + if(handsMO.getI() != ""){ + handsMO.setI(""); //nothing + activation=0.0; + } + + } + //System.out.println("Before: "+known.size()+ " "+known); + + //System.out.println("After: "+known.size()+ " "+known); + //System.out.println("EatClosestApple: "+ handsMO.getInfo()); + + } + + @Override + public void calculateActivation() { + + } + + public void DestroyClosestApple() { + int r = -1; + int i = 0; + synchronized(known) { + CopyOnWriteArrayList myknown = new CopyOnWriteArrayList<>(known); + for (Thing t : known) { + if (closestApple != null) + if (t.getName().equals(closestApple.getName())) r = i; + i++; + } + if (r != -1) known.remove(r); + closestApple = null; + knownMO.setI(known); + } + } + +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/Explore.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/Explore.java new file mode 100644 index 0000000..f5ead6e --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/Explore.java @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.behaviors; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.List; +import org.json.JSONException; +import org.json.JSONObject; +import static support.Constants.*; +import ws3dproxy.model.Thing; + +/** + * + * @author klaus + * + * + */ + +public class Explore extends Codelet { + + private Memory knownMO; + private List known; + private MemoryContainer legsMO; + + + /** + * Default constructor + */ + public Explore(){ + this.name = "Explore"; + } + + @Override + public void proc() { + System.out.println("Executing proc explore"); + known = (List) knownMO.getI(); + if (known.size() == 0) { + activation=1.0; + } + else activation=0.0; + JSONObject message=new JSONObject(); + message.put(ACTION, EXPLORE); + if(legsMO.getI() == message.toString() && legsMO.getEvaluation() == activation) { + System.out.println("Nothing changed explore"); + } else { + legsMO.setI(message.toString(),activation,name); + } + + } + + @Override + public void accessMemoryObjects() { + knownMO = (MemoryObject)this.getInput(KNOWN_APPLES); + legsMO = (MemoryContainer)this.getOutput(LEGS); + } + + @Override + public void calculateActivation() { + + } + + +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/GoToClosestApple.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/GoToClosestApple.java new file mode 100644 index 0000000..d87d1f9 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/behaviors/GoToClosestApple.java @@ -0,0 +1,140 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.behaviors; + +import java.awt.Point; +import java.awt.geom.Point2D; + +import org.json.JSONException; +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import static support.Constants.*; +import ws3dproxy.model.Thing; + +public class GoToClosestApple extends Codelet { + + private Memory closestAppleMO; + private Memory selfInfoMO; + private MemoryContainer legsMO; + private int creatureBasicSpeed; + private double reachDistance; + + public GoToClosestApple(int creatureBasicSpeed, int reachDistance) { + this.creatureBasicSpeed=creatureBasicSpeed; + this.reachDistance=reachDistance; + this.name = "GoToClosestApple"; + } + + @Override + public void accessMemoryObjects() { + closestAppleMO=(MemoryObject)this.getInput(CLOSEST_APPLE); + selfInfoMO=(MemoryObject)this.getInput(INNER); + legsMO=(MemoryContainer)this.getOutput(LEGS); + } + + @Override + public void proc() { + System.out.println("Executing proc gotoclosestapple"); + // Find distance between creature and closest apple + //If far, go towards it + //If close, stops + + Thing closestApple = (Thing) closestAppleMO.getI(); + Idea cis = (Idea) selfInfoMO.getI(); + + if(closestApple != null) + { + double appleX=0; + double appleY=0; + try { + appleX = closestApple.getCenterPosition().getX(); + appleY = closestApple.getCenterPosition().getY(); + + } catch (Exception e) { + e.printStackTrace(); + } + + double selfX=(double)cis.get("position.x").getValue(); + double selfY=(double)cis.get("position.y").getValue(); + + Point2D pApple = new Point(); + pApple.setLocation(appleX, appleY); + + Point2D pSelf = new Point(); + pSelf.setLocation(selfX, selfY); + + double distance = pSelf.distance(pApple); + //JSONObject message=new JSONObject(); + Idea message = Idea.createIdea(MESSAGE,"", Idea.guessType("Property",null,1.0,0.5)); + try { + if(distance>reachDistance){ //Go to it + message.add(Idea.createIdea(ACTION,GOTO, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("X",(int)appleX, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("Y",(int)appleY, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("SPEED",creatureBasicSpeed, Idea.guessType("Property",null,1.0,0.5))); + activation=1.0; + + }else{//Stop + message.add(Idea.createIdea(ACTION,GOTO, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("X",(int)appleX, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("Y",(int)appleY, Idea.guessType("Property",null,1.0,0.5))); + message.add(Idea.createIdea("SPEED",0, Idea.guessType("Property",null,1.0,0.5))); + activation=0.5; + } + legsMO.setI(toJson(message),activation,name); + } catch (JSONException e) { + e.printStackTrace(); + } + } + else { + activation=0.0; + legsMO.setI("",activation,name); + } + + }//end proc + + @Override + public void calculateActivation() { + + } + + String toJson(Idea i) { + String q = "\""; + String out = "{"; + String val; + int ii=0; + for (Idea il : i.getL()) { + if (il.getL().isEmpty()) { + if (il.isNumber()) val = il.getValue().toString(); + else val = q+il.getValue()+q; + } + else val = toJson(il); + if (ii == 0) out += q+il.getName()+q+":"+val; + else out += ","+q+il.getName()+q+":"+val; + ii++; + } + out += "}"; + return out; + } + +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/HandsActionCodelet.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/HandsActionCodelet.java new file mode 100644 index 0000000..b23b8ae --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/HandsActionCodelet.java @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.motor; + + +import org.json.JSONException; +import org.json.JSONObject; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.Random; +import java.util.logging.Logger; +import static support.Constants.*; +import ws3dproxy.model.Creature; + +/** + * Hands Action Codelet monitors working storage for instructions and acts on the World accordingly. + * + * @author klaus + * + */ + + +public class HandsActionCodelet extends Codelet{ + + private Memory handsMO; + private String previousHandsAction=""; + private Creature c; + private Random r = new Random(); + static Logger log = Logger.getLogger(HandsActionCodelet.class.getCanonicalName()); + + public HandsActionCodelet(Creature nc) { + c = nc; + this.name = "HandsActionCodelet"; + } + + @Override + public void accessMemoryObjects() { + handsMO=(MemoryObject)this.getInput(HANDS); + } + public void proc() { + System.out.println("Executing proc Hands"); + String command = (String) handsMO.getI(); + + if(!command.equals("") && (!command.equals(previousHandsAction))){ + JSONObject jsonAction; + try { + jsonAction = new JSONObject(command); + if(jsonAction.has(ACTION) && jsonAction.has(OBJECT)){ + String action=jsonAction.getString(ACTION); + String objectName=jsonAction.getString(OBJECT); + if(action.equals(PICKUP)){ + try { + c.putInSack(objectName); + } catch (Exception e) { + + } + log.info("Sending Put In Sack command to agent:****** "+objectName+"**********"); + } + if(action.equals(EATIT)){ + try { + c.eatIt(objectName); + } catch (Exception e) { + + } + System.out.println("Sending Eat command to agent:****** "+objectName+"**********"); + } + if(action.equals(BURY)){ + try { + c.hideIt(objectName); + } catch (Exception e) { + + } + log.info("Sending Bury command to agent:****** "+objectName+"**********"); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + + } +// System.out.println("OK_hands"); + previousHandsAction = (String) handsMO.getI(); + }//end proc + + @Override + public void calculateActivation() { + activation = 0.9d; + } + + +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/LegsActionCodelet.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/LegsActionCodelet.java new file mode 100644 index 0000000..9d8c769 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/motor/LegsActionCodelet.java @@ -0,0 +1,131 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.motor; + + +import org.json.JSONObject; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import java.util.Random; +import java.util.logging.Logger; +import org.json.JSONException; +import static support.Constants.*; +import ws3dproxy.model.Creature; + +/** + * Legs Action Codelet monitors working storage for instructions and acts on the World accordingly. + * + * @author klaus + * + */ + +public class LegsActionCodelet extends Codelet{ + + private Memory legsActionMO; + private double previousTargetx=0; + private double previousTargety=0; + private String previousLegsAction=""; + private Creature c; + double old_angle = 0; + int k=0; + static Logger log = Logger.getLogger(LegsActionCodelet.class.getCanonicalName()); + + public LegsActionCodelet(Creature nc) { + c = nc; + this.name = "LegsActionCodelet"; + } + + @Override + public void accessMemoryObjects() { + legsActionMO=(MemoryContainer)this.getInput(LEGS); + } + + @Override + public void proc() { + System.out.println("Executing proc Legs"); + + String comm = (String) legsActionMO.getI(); + if (comm == null) comm = ""; + Random r = new Random(); + + if(!comm.equals("") ){ + try { + JSONObject command=new JSONObject(comm); + if (command.has(ACTION)) { + int x=0,y=0; + String action=command.getString(ACTION); + if(action.equals(EXPLORE)){ + if (!comm.equals(previousLegsAction)) { + //if (!comm.equals(previousLegsAction)) + System.out.println("Sending Explore command to agent"); + try { + c.rotate(2); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + else if(action.equals(GOTO)){ + if (!comm.equals(previousLegsAction)) { + double speed=command.getDouble("SPEED"); + double targetx=command.getDouble("X"); + double targety=command.getDouble("Y"); + if (!comm.equals(previousLegsAction)) + System.out.println("Sending move command to agent "+ c.getName()+" : ["+targetx+","+targety+"]"); + try { + c.moveto(speed, targetx, targety); + } catch(Exception e) { + e.printStackTrace(); + } + previousTargetx=targetx; + previousTargety=targety; + } + + } else { + log.info("Sending stop command to agent"); + try { + c.moveto(0,0,0); + } catch(Exception e) { + e.printStackTrace(); + } + } + } + previousLegsAction=comm; + k++; + } catch (JSONException e) {e.printStackTrace();} + } + else { + previousLegsAction = comm; + log.info("Sending stop command to agent"); + try { + //c.moveto(0,0,0); + } catch(Exception e) { + e.printStackTrace(); + } + } + }//end proc + + @Override + public void calculateActivation() { + activation = 0.9d; + } +} diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/AppleDetector.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/AppleDetector.java new file mode 100644 index 0000000..dfefb79 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/AppleDetector.java @@ -0,0 +1,91 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.perception; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.KNOWN_APPLES; +import static support.Constants.VISION_MO; +import ws3dproxy.model.Thing; + +/** + * Detect apples in the vision field. + * This class detects a number of things related to apples, such as if there are any within reach, + * any on sight, if they are rotten, and so on. + * + * @author klaus + * + */ +public class AppleDetector extends Codelet { + + private Memory visionMO; + private Memory knownApplesMO; + + public AppleDetector(){ + this.name = "AppleDetector"; + } + + @Override + public void accessMemoryObjects() { + synchronized(this) { + this.visionMO=(MemoryObject)this.getInput(VISION_MO); + } + this.knownApplesMO=(MemoryObject)this.getOutput(KNOWN_APPLES); + } + + @Override + public void proc() { + System.out.println("Executing proc AppleDetector"); + CopyOnWriteArrayList vision; + List known; + synchronized (visionMO) { + //vision = Collections.synchronizedList((List) visionMO.getI()); + vision = new CopyOnWriteArrayList((List) visionMO.getI()); + known = Collections.synchronizedList((List) knownApplesMO.getI()); + //known = new CopyOnWriteArrayList((List) knownApplesMO.getI()); + synchronized(vision) { + for (Thing t : vision) { + boolean found = false; + synchronized(known) { + CopyOnWriteArrayList myknown = new CopyOnWriteArrayList<>(known); + for (Thing e : myknown) + if (t.getName().equals(e.getName())) { + found = true; + break; + } + if (found == false && t.getName().contains("PFood") && !t.getName().contains("NPFood")) known.add(t); + } + } + } + } + knownApplesMO.setI(known); + }// end proc + + @Override + public void calculateActivation() { + + } +}//end class + + diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/ClosestAppleDetector.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/ClosestAppleDetector.java new file mode 100644 index 0000000..dc51504 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/codelets/perception/ClosestAppleDetector.java @@ -0,0 +1,96 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.perception; + + + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.*; +import ws3dproxy.model.Thing; + +/** + * @author klaus + * + */ +public class ClosestAppleDetector extends Codelet { + + private Memory knownMO; + private Memory closestAppleMO; + private Memory innerSenseMO; + + private List known; + + public ClosestAppleDetector() { + this.name = "ClosestAppleDetector"; + } + + @Override + public void accessMemoryObjects() { + this.knownMO=(MemoryObject)this.getInput(KNOWN_APPLES); + this.innerSenseMO=(MemoryObject)this.getInput(INNER); + this.closestAppleMO=(MemoryObject)this.getOutput(CLOSEST_APPLE); + } + + @Override + public void proc() { + System.out.println("Executing proc ClosestAppleDetector"); + Thing closest_apple=null; + known = Collections.synchronizedList((List) knownMO.getI()); + Idea cis = (Idea) innerSenseMO.getI(); + synchronized(known) { + if(known.size() != 0){ + //Iterate over objects in vision, looking for the closest apple + CopyOnWriteArrayList myknown = new CopyOnWriteArrayList<>(known); + for (Thing t : myknown) { + String objectName=t.getName(); + if(objectName.contains("PFood") && !objectName.contains("NPFood")){ //Then, it is an apple + if(closest_apple == null){ + closest_apple = t; + } + else { + double Dnew = calculateDistance(t.getX1(), t.getY1(), (double)cis.get("position.x").getValue(), (double)cis.get("position.y").getValue()); + double Dclosest= calculateDistance(closest_apple.getX1(), closest_apple.getY1(), (double)cis.get("position.x").getValue(), (double)cis.get("position.y").getValue()); + if(Dnew lt = c.getThingsInVision(); + visionMO.setI(lt); + } + }//end proc() + + @Override + public void calculateActivation() { + + } + +}// class end + + + + + diff --git a/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/support/Constants.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/support/Constants.java new file mode 100644 index 0000000..4f03be0 --- /dev/null +++ b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/support/Constants.java @@ -0,0 +1,39 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package support; + +/** + * + * @author karenlima + */ +public class Constants { + public static final String SENSORY = "Sensory"; + public static final String PERCEPTION = "Perception"; + public static final String MOTOR = "Motor"; + public static final String BEHAVIORAL = "Behavioral"; + public static final String COMPETENCE = "Competence"; + public static final String WORKING = "Working"; + public static final String HANDS = "HANDS"; + public static final String LEGS = "LEGS"; + public static final String INNER = "INNER"; + public static final String OBJECT = "OBJECT"; + public static final String ACTION = "ACTION"; + public static final String PICKUP = "PICKUP"; + public static final String EATIT = "EATIT"; + public static final String GOTO = "GOTO"; + public static final String BURY = "BURY"; + public static final String EXPLORE = "EXPLORE"; + public static final String MESSAGE = "message"; + public static final String VISION_MO = "VISION_MO"; + public static final String THINGS_KNOWN_MO = "THINGS_IN_KNOWN_MO"; + public static final String THINGS_KNOWN_IDEA = "THINGS_IN_KNOWN_IDEA"; + public static final String THINGS_IN_VISION_MEMORY_GROUP = "THINGS_IN_VISION_MEMORY_GROUP"; + public static final String THINGS_KNOWN_MEMORY_GROUP = "THINGS_KNOWN_MEMORY_GROUP"; + public static final String SOAR_IO_MEMORY_GROUP = "SOAR_IO_MEMORY_GROUP"; + public static final String MOTOR_MEMORY_GROUP = "MOTOR_MEMORY_GROUP"; + public static final String KNOWN_APPLES = "KNOWN_APPLES"; + public static final String CLOSEST_APPLE = "CLOSEST_APPLE"; + +} diff --git a/src/main/java/support/ResourcesGenerator.java b/0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/support/ResourcesGenerator.java similarity index 100% rename from src/main/java/support/ResourcesGenerator.java rename to 0_ - DemoCSTCore/DemoCSTCoreProject/src/main/java/support/ResourcesGenerator.java diff --git a/0_ - DemoCSTCore/READ.ME b/0_ - DemoCSTCore/READ.ME new file mode 100644 index 0000000..e69de29 diff --git a/0_ - DemoHabits/.gitignore b/0_ - DemoHabits/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoHabits/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoMindViewer/DemoMindViewer/.gitignore b/0_ - DemoMindViewer/DemoMindViewer/.gitignore new file mode 100755 index 0000000..ed27e12 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/.gitignore @@ -0,0 +1,60 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoMindViewer/DemoMindViewer/LICENSE b/0_ - DemoMindViewer/DemoMindViewer/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/0_ - DemoMindViewer/DemoMindViewer/README.md b/0_ - DemoMindViewer/DemoMindViewer/README.md new file mode 100644 index 0000000..fc0e86e --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/README.md @@ -0,0 +1,2 @@ +# MindViewerTest +This is a demo project for showing the MindViewer capabilities diff --git a/0_ - DemoMindViewer/DemoMindViewer/build.gradle b/0_ - DemoMindViewer/DemoMindViewer/build.gradle new file mode 100644 index 0000000..598bd35 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/build.gradle @@ -0,0 +1,49 @@ +plugins { + id 'application' +} + +mainClassName = 'MindViewerTest.Main' + +repositories { + flatDir { + dirs 'libs' + dirs '../cst/build/libs' + dirs '../cst-desktop/build/libs' + } + jcenter() + mavenCentral() + maven { + url "https://github.com/rosjava/rosjava_mvn_repo/raw/master" + } + maven { + url = 'https://cst-group.github.io/cst-dependencies/maven-repo/' + } + maven { + url 'https://jitpack.io' + } +} + +dependencies { + implementation 'com.github.CST-Group:cst-desktop:36588ca' + implementation 'com.soartech:jsoar-core:5.1.1' + // implementation ':cst-desktop:1.0.4-full' +} + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archiveClassifier = 'full' + manifest { + attributes( + 'Main-Class': mainClassName + ) + } + from sourceSets.main.output + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } + } + exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' +} + + + diff --git a/0_ - DemoMindViewer/DemoMindViewer/gradle.properties b/0_ - DemoMindViewer/DemoMindViewer/gradle.properties new file mode 100644 index 0000000..a2ae62e --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/gradle.properties @@ -0,0 +1,3 @@ + +action.run.args=run +netbeans.hint.jdkPlatform=JDK_21 diff --git a/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.jar b/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.properties b/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..070cb70 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/0_ - DemoMindViewer/DemoMindViewer/gradlew b/0_ - DemoMindViewer/DemoMindViewer/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/0_ - DemoMindViewer/DemoMindViewer/gradlew.bat b/0_ - DemoMindViewer/DemoMindViewer/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/0_ - DemoMindViewer/DemoMindViewer/settings.gradle b/0_ - DemoMindViewer/DemoMindViewer/settings.gradle new file mode 100644 index 0000000..651161e --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'MindViewerTest' diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/CustomView.java b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/CustomView.java new file mode 100644 index 0000000..2daa052 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/CustomView.java @@ -0,0 +1,60 @@ +package MindViewerTest; + + +/** + * + * @author brgsil + */ +public class CustomView extends javax.swing.JFrame { + + /** + * Creates new form CustomView + */ + public CustomView() { + initComponents(); + } + + @SuppressWarnings("unchecked") + // + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Liberation Sans", 0, 20)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("Ascending"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(124, 124, 124) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(137, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(121, 121, 121) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(130, Short.MAX_VALUE)) + ); + + pack(); + }// + + public void updateInfo(boolean ascending) { + if (ascending) { + jLabel1.setText("Ascending"); + } else { + jLabel1.setText("Descending"); + } + } + + // Variables declaration - do not modify + private javax.swing.JLabel jLabel1; + // End of variables declaration +} diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/Main.java b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/Main.java new file mode 100644 index 0000000..ada7c32 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/Main.java @@ -0,0 +1,229 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package MindViewerTest; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.core.entities.Mind; +import br.unicamp.cst.io.rest.RESTServer; +import br.unicamp.cst.representation.idea.Idea; +import br.unicamp.cst.util.viewer.MindViewer; +import java.awt.geom.Point2D; +import java.util.Timer; +import java.util.TimerTask; + +/** + * + * @author rgudwin + */ +public class Main { + + Mind m; + Boolean enablePlanSubsytem = true; + + void updateMemoryObject(MemoryObject mo) { + Object o = mo.getI(); + if (o instanceof Double) { + double value = (double) mo.getI(); + mo.setI(value+0.01); + } + else if (o instanceof Point2D.Double) { + Point2D.Double p = (Point2D.Double) o; + p.x += 0.01; + p.y -= 0.01; + } + else if (o instanceof Idea) { + Idea id = (Idea) o; + Idea idea1 = id.get("idea2"); + if (idea1.getValue() instanceof Double) { + double value = (double) idea1.getValue(); + idea1.setValue(value+0.01); + } + Idea ideap = id.get("idea15.profunda"); + if (idea1.getValue() instanceof Double) { + double value = (double) ideap.getValue(); + ideap.setValue(value+0.01); + } + } + else mo.setI(o); + } + + void updateMemoryContainer(MemoryContainer mc) { + for (Memory mem : mc.getAllMemories()) { + if (mem.getClass().getCanonicalName().equalsIgnoreCase("br.unicamp.cst.core.entities.MemoryObject")) { + updateMemoryObject((MemoryObject)mem); + //System.out.println("Updating subnode"); + } + } + } + + void updateMind() { + //System.out.println("Updating Mind"); + for (Memory mem : m.getRawMemory().getAllMemoryObjects()) { + if (mem.getName().equalsIgnoreCase("PlanningMemory")) continue; + if (mem.getClass().getCanonicalName().equalsIgnoreCase("br.unicamp.cst.core.entities.MemoryObject")) { + updateMemoryObject((MemoryObject)mem); + } + if (mem.getClass().getCanonicalName().equalsIgnoreCase("br.unicamp.cst.core.entities.MemoryContainer")) { + updateMemoryContainer((MemoryContainer)mem); + } + } + + } + + public void StartTimer() { + Timer t = new Timer(); + Main.mainTimerTask tt = new Main.mainTimerTask(this); + t.scheduleAtFixedRate(tt, 0, 100); + } + + public void tick() { + if (m != null) { + updateMind(); + } else { + System.out.println("Mind is null"); + } + //System.out.println("update"); + } + + class mainTimerTask extends TimerTask { + + Main wov; + boolean enabled = true; + + public mainTimerTask(Main wovi) { + wov = wovi; + } + + public void run() { + if (enabled) { + wov.tick(); + } + } + + public void setEnabled(boolean value) { + enabled = value; + } + } + + + public Mind prepareMind() { + m = new Mind(); + m.createCodeletGroup("Sensory"); + m.createCodeletGroup("Perception"); + m.createCodeletGroup("Behavioral"); + m.createCodeletGroup("Motivational"); + m.createCodeletGroup("Motor"); + m.createMemoryGroup("StandardMemories"); + m.createMemoryGroup("Containers"); + + MemoryObject m1 = m.createMemoryObject("M1", 1.12); + m.registerMemory(m1,"StandardMemories"); + MemoryObject m2 = m.createMemoryObject("M2", 2.32); + m.registerMemory(m2,"StandardMemories"); + MemoryObject m3 = m.createMemoryObject("M3", 3.44); + m.registerMemory(m3,"StandardMemories"); + Point2D.Double p = new Point2D.Double(0,0); + MemoryObject m4 = m.createMemoryObject("M4", p); + m.registerMemory(m4,"StandardMemories"); + MemoryObject m5 = m.createMemoryObject("M5", 5.12); + m.registerMemory(m5,"StandardMemories"); + MemoryContainer m6 = m.createMemoryContainer("C1"); + m.registerMemory(m6,"Containers"); + MemoryContainer m7 = m.createMemoryContainer("C2"); + m.registerMemory(m7,"Containers"); + int mc1 = m7.setI(7.55, 0.23); + int mc2 = m6.setI(6.33, 0.22); + int mc3 = m6.setI(6.12, 0.13); + int mc4 = m6.add(m7); + Idea idea = new Idea("idea","","AbstractObject",1); + idea.add(new Idea("idea1",0.1D,"Property",1)); + idea.add(new Idea("idea2",0.2D,"Link",1)); + idea.add(new Idea("idea3",0.3D,"QualityDimension",1)); + idea.add(new Idea("idea4",0.4D,"Episode",1)); + idea.add(new Idea("idea5",0.5D,"Composite",1)); + idea.add(new Idea("idea6",0.6D,"Aggregate",1)); + idea.add(new Idea("idea7",0.7D,"Configuration",1)); + idea.add(new Idea("idea8",0.8D,"TimeStep",1)); + idea.add(new Idea("idea9",0.9D,"Property",2)); + idea.add(new Idea("idea10",1.0D,"AbstractObject",2)); + idea.add(new Idea("idea11",1.1D,"Episode",2)); + idea.add(new Idea("idea12",1.2D,"Property",0)); + idea.add(new Idea("idea13",1.3D,"AbstractObject",0)); + idea.add(new Idea("idea14",1.4D,"Episode",0)); + Idea idea15 = new Idea("idea15",1.5D,"Episode",0); + Idea profunda = new Idea("profunda",1.6D,"Episode",0); + Idea profunda2 = new Idea("profunda2",1.7D,"Episode",2); + profunda.add(profunda2); + idea15.add(profunda); + idea.add(idea15); + //idea.setCategory("Property"); + //idea.setScope(1); + m5.setI(idea); + //System.out.println("Memories: "+mc1+" "+mc2+" "+mc3+" "+mc4); + + Codelet c = new TestCodelet("Sensor1"); + c.addInput(m1); + c.addInput(m2); + c.addOutput(m3); + c.addOutput(m4); + c.addBroadcast(m5); + m.insertCodelet(c,"Sensory"); + Codelet c2 = new TestCodelet("Motor1"); + c2.addInput(m4); + c2.addInput(m5); + c2.addOutput(m6); + c2.addOutput(m3); + c2.addBroadcast(m5); + m.insertCodelet(c2,"Motor"); + + Codelet mot1 = new TestCodelet("Curiosity"); + mot1.addInput(m7); + mot1.addOutput(m5); + m.insertCodelet(mot1,"Motivational"); + Codelet mot2 = new TestCodelet("Fear"); + mot2.addInput(m3); + mot2.addOutput(m4); + try {mot2.setActivation(1.0);} catch(Exception e){} + m.insertCodelet(mot2,"Motivational"); + Codelet mot3 = new TestCodelet("Anger"); + mot3.addInput(m1); + mot3.addOutput(m2); + try {mot3.setActivation(0.5);} catch(Exception e){} + m.insertCodelet(mot3,"Motivational"); + + + if(enablePlanSubsytem) { + m.createCodeletGroup("Planning"); + Codelet testPlanningCodelet = new TestPlanningCodelet("JSoarCodelet"); + m.insertCodelet(testPlanningCodelet, "Planning"); + } + + m.start(); + return(m); + } + +private void createAndShowGUI(Mind m) { + MindViewer mv = new MindViewer(m,"MindViewer",m.getCodeletGroupList("Motor")); + mv.setVisible(true); + } + +public Main() { + Mind m = prepareMind(); + // The next line can be commented if you don't want the Desktop MindViewer + createAndShowGUI(m); + // The next line can be commented if you don't use the MindViewer Web + RESTServer rs = new RESTServer(m,5000,true); +} + + public static void main(String[] args) { + Main mainApp = new Main(); + mainApp.StartTimer(); + } + +} diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/NativeUtils.java b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/NativeUtils.java new file mode 100644 index 0000000..8232c9e --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/NativeUtils.java @@ -0,0 +1,222 @@ +package MindViewerTest; + +///This is how to use it +//import SoarBridge.NativeUtils; +// +//public class HelloJNI { +// static { +// try { +// NativeUtils.loadLibraryFromJar("/resources/libHelloJNI.so"); +// } catch (IOException e) { +// e.printStackTrace(); // This is probably not the best way to handle exception :-) +// } +// } +// +// public native void hello(); +//} + + + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; + +/** + * Simple library class for working with JNI (Java Native Interface) + * + * @see http://frommyplayground.com/how-to-load-native-jni-library-from-jar + * + * @author Adam Heirnich , http://www.adamh.cz + */ +public class NativeUtils { + + /** + * Private constructor - this class will never be instanced + */ + private NativeUtils() { + } + + public static void setLibraryPath(String path) { + Field fieldSysPath=null; + System.setProperty( "java.library.path", path ); + try { + fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" ); + } catch (Exception e) { + System.out.println("Exceção: "+e); + } + fieldSysPath.setAccessible( true ); + try { + fieldSysPath.set( null, null ); + } catch (Exception e) { + System.out.println("Exceção: "+e); + } + } + + public static void loadFileFromJar(String path) throws IOException { + + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prexif and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) + } + + // Check if the filename is okay + if (filename == null || prefix.length() < 3) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + System.out.println("Loading file from JAR: "+prefix+suffix); + // Prepare temporary file + //File temp = File.createTempFile(prefix, suffix); + File temp = new File(prefix+suffix); + temp.deleteOnExit(); + +// if (!temp.exists()) { +// throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); +// } + + // Prepare buffer for data copying + byte[] buffer = new byte[1024]; + int readBytes; + + // Open and check input stream + InputStream is = NativeUtils.class.getResourceAsStream(path); + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + // Open output stream and copy data between source file in JAR and the temporary file + OutputStream os = new FileOutputStream(temp); + try { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } finally { + // If read/write fails, close streams safely before throwing an exception + os.close(); + is.close(); + } + } + + /** + * Loads library from current JAR archive + * + * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting. + * Method uses String as filename because the pathname is "abstract", not system-dependent. + * + * @param filename The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext + * @throws IOException If temporary file creation or read/write operation fails + * @throws IllegalArgumentException If source file (param path) does not exist + * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters (restriction of {@see File#createTempFile(java.lang.String, java.lang.String)}). + */ + public static void loadLibraryFromJar(String path) throws IOException { + + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prexif and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) + } + + // Check if the filename is okay + if (filename == null || prefix.length() < 3) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + System.out.println("Loading Library: "+prefix+suffix); + // Prepare temporary file + //File temp = File.createTempFile(prefix, suffix); + File temp = new File(prefix+suffix); + temp.deleteOnExit(); + +// if (!temp.exists()) { +// throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); +// } + + // Prepare buffer for data copying + byte[] buffer = new byte[1024]; + int readBytes; + + // Open and check input stream + InputStream is = NativeUtils.class.getResourceAsStream(path); + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + // Open output stream and copy data between source file in JAR and the temporary file + OutputStream os = new FileOutputStream(temp); + try { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } finally { + // If read/write fails, close streams safely before throwing an exception + os.close(); + is.close(); + } + + // Finally, load the library + System.load(temp.getAbsolutePath()); + +// // Starts contributed code from Lofi to deal with files on the temporary folder in Windows +// final String libraryPrefix = prefix; +// final String lockSuffix = ".lock"; +// +// // create lock file +// final File lock = new File( temp.getAbsolutePath() + lockSuffix); +// lock.createNewFile(); +// lock.deleteOnExit(); +// +// // file filter for library file (without .lock files) +// FileFilter tmpDirFilter = +// new FileFilter() +// { +// public boolean accept(File pathname) +// { +// return pathname.getName().startsWith( libraryPrefix) && pathname.getName().endsWith( lockSuffix); +// } +// }; +// +// // get all library files from temp folder +// String tmpDirName = System.getProperty("java.io.tmpdir"); +// File tmpDir = new File(tmpDirName); +// File[] tmpFiles = tmpDir.listFiles(tmpDirFilter); +// +// // delete all files which don't have n accompanying lock file +// for (int i = 0; i < tmpFiles.length; i++) +// { +// // Create a file to represent the lock and test. +// File lockFile = new File( tmpFiles[i].getAbsolutePath() + lockSuffix); +// if (!lockFile.exists()) +// { +// System.out.println( "deleting: " + tmpFiles[i].getAbsolutePath()); +// tmpFiles[i].delete(); +// } +// } + } +} \ No newline at end of file diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestCodelet.java b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestCodelet.java new file mode 100644 index 0000000..a3c5a15 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestCodelet.java @@ -0,0 +1,62 @@ +/** + * + */ +package MindViewerTest; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException; +import br.unicamp.cst.util.viewer.Inspectable; + +/** + * + * @author gudwin + * + */ +public class TestCodelet extends Codelet implements Inspectable{ + + boolean ascending = true; + CustomView customView; + + public TestCodelet(String name) { + setName(name); + customView = new CustomView(); + } + + @Override + public void accessMemoryObjects() { + + } + + @Override + public void calculateActivation() { + double currentactivation = getActivation(); + if (ascending) { + try { + setActivation(getActivation()+0.1); + } catch (CodeletActivationBoundsException e) { + ascending = !ascending; + customView.updateInfo(ascending); + } + } + else { + try { + setActivation(getActivation()-0.1); + } catch (CodeletActivationBoundsException e) { + ascending = !ascending; + customView.updateInfo(ascending); + } + } + } + + @Override + public void proc() { + + } + + @Override + public void inspect() { + customView.setVisible(true); + + } + +} diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestPlanningCodelet.java b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestPlanningCodelet.java new file mode 100644 index 0000000..cfd4b24 --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/java/MindViewerTest/TestPlanningCodelet.java @@ -0,0 +1,64 @@ +/** + * + */ +package MindViewerTest; + +import br.unicamp.cst.bindings.soar.JSoarCodelet; +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException; +import br.unicamp.cst.representation.idea.Idea; +import br.unicamp.cst.util.viewer.Inspectable; +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author gudwin + * + */ +public class TestPlanningCodelet extends JSoarCodelet { + private static String soarRulesPath = "soarPlanning.soar"; + private static String soarFileRulesPath = "/soarRules/soarPlanning.soar"; + Idea mockInputLinkIdea; + Boolean first = true; + + public TestPlanningCodelet(String name) { + try { + NativeUtils.loadFileFromJar(soarFileRulesPath); + } catch (IOException ex) { + Logger.getLogger(TestPlanningCodelet.class.getName()).log(Level.SEVERE, null, ex); + } + setName(name); + initSoarPlugin("agent", new File(soarRulesPath), false); + createMockInpuLinkIdea(); + + } + + @Override + public void accessMemoryObjects() { + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + setInputLinkIdea(mockInputLinkIdea); + if (getDebugState() == 0) { + getJsoar().step(); + } + } + + private void createMockInpuLinkIdea() { + mockInputLinkIdea = new Idea("InputLink",null,"AbstractObject",1); + Idea creatureIdea = new Idea("CREATURE", null,"AbstractObject", 1); + creatureIdea.add(new Idea("NAME", "agent_1","Property", 1)); + mockInputLinkIdea.add(creatureIdea); + + } + +} diff --git a/0_ - DemoMindViewer/DemoMindViewer/src/main/resources/soarRules/soarPlanning.soar b/0_ - DemoMindViewer/DemoMindViewer/src/main/resources/soarRules/soarPlanning.soar new file mode 100644 index 0000000..c437acb --- /dev/null +++ b/0_ - DemoMindViewer/DemoMindViewer/src/main/resources/soarRules/soarPlanning.soar @@ -0,0 +1,41 @@ +################################ CONFIGURATION ################################ +watch 5 + + +################################### PROPOSE RULES ################################### + +sp {propose*init + (state ^superstate nil + -^name) +--> + ( ^operator + =) + ( ^name initSmem) +} + +sp {apply*init + (state ^operator.name initSmem) +--> + ( ^name initSmem) +} + +sp {propose*createOutput + (state ^name initSmem) +--> + ( ^operator + =) + ( ^name createOutput) +} + +sp {apply*createOutput + (state ^operator.name createOutput + ^io ) + ( ^input-link + ^output-link
    ) + ( ^CREATURE ) + ( ^NAME ) +--> + ( ^name initPlans) + (
      ^SoarPlan ) + ( ^Name ) + + (halt) +} diff --git a/0_ - DemoSoar/DemoSoarProject/.gitignore b/0_ - DemoSoar/DemoSoarProject/.gitignore new file mode 100755 index 0000000..15958fd --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/.gitignore @@ -0,0 +1,61 @@ +/dist/ +/out/ +/nbproject/private/ +.nb-gradle/ +inputlink.txt + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +/bin/ + +.classpath +.project +/logCache/ +/paramCache/ +.gradle/ +.settings/ + +# Miscellaneous +*.lock +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ +/build/ + +#Exception +!/lib/*.jar +!/gradle/wrapper/*.jar diff --git a/0_ - DemoSoar/DemoSoarProject/LICENSE b/0_ - DemoSoar/DemoSoarProject/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/0_ - DemoSoar/DemoSoarProject/build.gradle b/0_ - DemoSoar/DemoSoarProject/build.gradle new file mode 100644 index 0000000..83850f8 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/build.gradle @@ -0,0 +1,52 @@ + + + +apply plugin: 'application' +mainClassName = 'ExperimentMain' +version = '0.0.4' + +//sourceCompatibility = '1.8' +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +if (!hasProperty('mainClass')) { + ext.mainClass = 'ExperimentMain' +} + +repositories { + mavenCentral() + maven { + url "https://github.com/rosjava/rosjava_mvn_repo/raw/master" + } + maven { url 'https://jitpack.io' } + maven { + url 'https://cst-group.github.io/cst-dependencies/maven-repo/' + } +} + +dependencies { + implementation 'com.github.CST-Group:cst-desktop:36588ca' + implementation 'com.github.CST-Group:WS3DProxy:0.0.4' + implementation 'org.json:json:20180813' + testImplementation group: 'junit', name: 'junit', version: '4.10' +} + +run { + main = mainClassName + args = project.hasProperty('args') ? project.args.split(' ') : [] +} + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archiveClassifier = 'full' + manifest { + attributes( + 'Main-Class': mainClassName + ) + } + from sourceSets.main.output + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } + } + exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' +} \ No newline at end of file diff --git a/0_ - DemoSoar/DemoSoarProject/gradle.properties b/0_ - DemoSoar/DemoSoarProject/gradle.properties new file mode 100644 index 0000000..463e04d --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/gradle.properties @@ -0,0 +1,3 @@ +action.run.args=${javaExec.workingDir} ${javaExec.environment} run ${javaExec.jvmArgs} ${javaExec.args} +org.gradle.parallel=true +org.gradle.daemon=true diff --git a/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.jar b/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..457aad0 Binary files /dev/null and b/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.jar differ diff --git a/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.properties b/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e1adfb4 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/0_ - DemoSoar/DemoSoarProject/gradlew b/0_ - DemoSoar/DemoSoarProject/gradlew new file mode 100755 index 0000000..af6708f --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/0_ - DemoSoar/DemoSoarProject/gradlew.bat b/0_ - DemoSoar/DemoSoarProject/gradlew.bat new file mode 100644 index 0000000..0f8d593 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/0_ - DemoSoar/DemoSoarProject/settings.gradle b/0_ - DemoSoar/DemoSoarProject/settings.gradle new file mode 100644 index 0000000..d2d3bf4 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'DemoSoar' diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/AgentMindJSoar.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/AgentMindJSoar.java new file mode 100644 index 0000000..1671a2c --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/AgentMindJSoar.java @@ -0,0 +1,135 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + + +import br.unicamp.cst.bindings.soar.JSoarCodelet; +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.Mind; +import br.unicamp.cst.representation.idea.Idea; +import codelets.behaviors.ActionSelection; +import codelets.motor.HandsActionCodelet; +import codelets.motor.LegsActionCodelet; +import codelets.perception.SoarInputLinkGenerator; +import codelets.decision.SoarCodelet; +import codelets.sensors.Vision; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import static support.Constants.*; +import support.NativeUtils; +import ws3dproxy.model.Creature; +import ws3dproxy.model.Thing; + +/** + * + * @author karenlima + */ +public class AgentMindJSoar extends Mind { + + + public ArrayList behavioralCodelets = new ArrayList<>(); + + public JSoarCodelet jSoarCodelet = null; + public Idea inputLinkIdea; + public Idea outputLinkIdea; + + public AgentMindJSoar(Creature creature, String name) { + super(); + + inputLinkIdea = new Idea(INPUT_LINK_IDEA+creature.getName()); + outputLinkIdea = new Idea(OUTPUT_LINK_IDEA+creature.getName()); + + createCodeletGroup(SENSORY); + createCodeletGroup(PERCEPTION); + createCodeletGroup(PLANNING); + createCodeletGroup(BEHAVIORAL); + createCodeletGroup(MOTOR); + createMemoryGroup(SENSORY); + createMemoryGroup(PERCEPTION); + createMemoryGroup(PLANNING); + createMemoryGroup(BEHAVIORAL); + createMemoryGroup(MOTOR); + + // Declare Memory Objects + Memory visionMO; + Memory inputLinkMO; + Memory outputLinkMO; + Memory legsMO; + Memory handsMO; + + List vision_list = Collections.synchronizedList(new ArrayList<>()); + visionMO=createMemoryObject(VISION_MO,vision_list); + registerMemory(visionMO,SENSORY); + + inputLinkMO=createMemoryObject(INPUT_LINK_MO, inputLinkIdea); + registerMemory(inputLinkMO,PLANNING); + + outputLinkMO=createMemoryObject(OUTPUT_LINK_MO, outputLinkIdea); + registerMemory(outputLinkMO,BEHAVIORAL); + + legsMO=createMemoryContainer(LEGS); + + registerMemory(legsMO, MOTOR); + + handsMO=createMemoryObject(HANDS, ""); + registerMemory(handsMO,MOTOR); + + // Create Vision Codelet + Codelet visionCodelet = new Vision(creature); + visionCodelet.addOutput(visionMO); + insertCodelet(visionCodelet); + registerCodelet(visionCodelet,SENSORY); + + // Create Perception Codelet + Codelet perceptionCodelet = new SoarInputLinkGenerator(creature); + perceptionCodelet.addInput(visionMO); + perceptionCodelet.addOutput(inputLinkMO); + insertCodelet(perceptionCodelet); + registerCodelet(perceptionCodelet,PERCEPTION); + + // Create Planning Codelet + try { + NativeUtils.loadFileFromJar(SOAR_FILE_RULES_PATH); + } catch (IOException ex) { + Logger.getLogger(AgentMindJSoar.class.getName()).log(Level.SEVERE, null, ex); + } + JSoarCodelet soarCodelet = new SoarCodelet(creature.getName(), new File(SOAR_RULES_PATH), false); + soarCodelet.addInput(inputLinkMO); + soarCodelet.addOutput(outputLinkMO); + insertCodelet(soarCodelet); + registerCodelet(soarCodelet,PLANNING); + jSoarCodelet = soarCodelet; + + // Create Action Selection Codelet + Codelet actionSelection=new ActionSelection(creature, 600, 800); + actionSelection.addInput(outputLinkMO); + actionSelection.addOutput(legsMO); + actionSelection.addOutput(handsMO); + insertCodelet(actionSelection); + registerCodelet(actionSelection,BEHAVIORAL); + + // Create Motor Codelets + Codelet legs=new LegsActionCodelet(creature); + legs.addInput(legsMO); + insertCodelet(legs); + registerCodelet(legs,MOTOR); + + Codelet hands=new HandsActionCodelet(creature); + hands.addInput(handsMO); + insertCodelet(hands); + registerCodelet(hands,MOTOR); + + // sets a time step for running the codelets to avoid heating too much your machine + for (Codelet c : this.getCodeRack().getAllCodelets()) + c.setTimeStep(200); + + start(); + } +} diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/Environment.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/Environment.java new file mode 100644 index 0000000..df3d3bf --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/Environment.java @@ -0,0 +1,71 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import support.ResourcesGenerator; +import ws3dproxy.CommandExecException; +import ws3dproxy.WS3DProxy; +import ws3dproxy.model.Creature; +import ws3dproxy.model.World; +import ws3dproxy.util.Constants; +import ws3dproxy.util.Logger; + +/** + * + * @author rgudwin + */ +public final class Environment { + + public String robotID="r0"; + public Creature c = null; + private String growOption; + + public Environment(String growOption) { + this.growOption = growOption; + WS3DProxy proxy = new WS3DProxy(); + try { + World w = World.getInstance(); + w.reset(); + World.createFood(0, 350, 75); + World.createFood(0, 100, 220); + World.createFood(0, 250, 210); + c = proxy.createCreature(100,450,0,0); + c.start(); + if(!growOption.equals("")) { + grow(w,7); + } + + } catch (CommandExecException e) { + + } + System.out.println("Robot "+c.getName()+" is ready to go."); + } + + public synchronized void grow(World w, int time) { + try { + if (time <= 0) { + time = Constants.TIMEFRAME; + } + w.getDimensionAndDeliverySpot(); + ResourcesGenerator rg = new ResourcesGenerator(time, w.getEnvironmentWidth(), w.getEnvironmentHeight(), w.getDeliverySpot().getX(), w.getDeliverySpot().getY(), growOption); + rg.start(); + } catch (CommandExecException ex) { + Logger.logException(World.class.getName(), ex); + } + } +} diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/ExperimentMain.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/ExperimentMain.java new file mode 100644 index 0000000..515ebee --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/ExperimentMain.java @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +import br.unicamp.cst.util.viewer.MindViewer; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author rgudwin + */ +public class ExperimentMain { + public Logger logger = Logger.getLogger(ExperimentMain.class.getName()); + + public ExperimentMain(String growOption) { + Logger.getLogger("codelets").setLevel(Level.SEVERE); + // Create Environment + Environment env=new Environment(growOption); //Creates only a creature and some apples + String creatureName = env.c.getName(); + AgentMindJSoar aJsoar = new AgentMindJSoar(env.c, creatureName); + MindViewer mvAJsoar1 = new MindViewer(aJsoar,"MindViewer - Agent Soar " + creatureName, null); + mvAJsoar1.setVisible(true); + + } + + + /** + * @param args + */ + public static void main(String[] args) { + ExperimentMain em = new ExperimentMain("grow"); + } + +} diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/ActionSelection.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/ActionSelection.java new file mode 100644 index 0000000..d2eb5f3 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/ActionSelection.java @@ -0,0 +1,204 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.behaviors; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryContainer; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.jsoar.kernel.memory.Wme; +import org.jsoar.kernel.symbols.Identifier; +import org.jsoar.kernel.symbols.Symbol; +import org.json.JSONObject; +import support.Constants; +import static support.Constants.HANDS; +import static support.Constants.LEGS; +import ws3dproxy.model.Creature; + +/** + * + * @author karenlima + */ +public class ActionSelection extends Codelet { + + private Memory handsMO; + private MemoryContainer legsMO; + private Memory outputLinkIdeaMO; + private Idea outputLinkIdea; + Creature creature; + private int counter = 10; + private double[] pos; + + public int width; + public int height; + + public ActionSelection(Creature c, int w, int h) { + this.creature = c; + this.width = w; + this.height = h; + this.name = "ActionSelection"; + } + + @Override + public void accessMemoryObjects() { + outputLinkIdeaMO=(MemoryObject)this.getInput(Constants.OUTPUT_LINK_MO); + outputLinkIdea = (Idea) outputLinkIdeaMO.getI(); + + handsMO=(MemoryObject)this.getOutput(HANDS); + legsMO=(MemoryContainer)this.getOutput(LEGS); + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + if(outputLinkIdea != null){ + + List nextActions = getNextActions(outputLinkIdea); + if(nextActions == null || nextActions.isEmpty()) return; + for(Idea nextAction : nextActions) { + JSONObject message = new JSONObject(); + if("IMPASSE_INFO".equals(nextAction.getName())){ + showImpasseInfo(nextAction); + continue; + } + + if("INPUT_LINK".equals(nextAction.getName())){ + saveInputLink(nextAction); + continue; + } + + if("MOVE".equals(nextAction.getName())) { + if(nextAction.get("X") == null) { + pos = getRandomPosition(); + message.put("ACTION", "GOTO"); + message.put("X", pos[0]); + message.put("Y", pos[1]); + message.put("SPEED", 1); + } else { + double posX = (double) nextAction.get("X").getValue(); + double posY = (double) nextAction.get("Y").getValue(); + message.put("ACTION", "GOTO"); + message.put("X", posX); + message.put("Y", posY); + message.put("SPEED", 1); + } + legsMO.setI(message.toString(), 1.0, name); + } else { + if("GET".equals(nextAction.getName())) { + String objectName = (String) nextAction.get("Name").getValue(); + message.put("ACTION", "PICKUP"); + message.put("OBJECT", objectName); + } else if("EAT".equals(nextAction.getName())) { + String objectName = (String) nextAction.get("Name").getValue(); + message.put("ACTION", "EATIT"); + message.put("OBJECT", objectName); + } + handsMO.setI(message.toString()); + } + + } + } + } + + private List getNextActions(Idea outputLinkIdea) { + + List nextActions = new ArrayList<>(); + if(outputLinkIdea.get("MOVE") != null) { + nextActions.add(outputLinkIdea.get("MOVE")); + } + if(outputLinkIdea.get("GET") != null) { + nextActions.add(outputLinkIdea.get("GET")); + } + if(outputLinkIdea.get("DELIVER") != null) { + nextActions.add(outputLinkIdea.get("DELIVER")); + } + if(outputLinkIdea.get("HIDE") != null) { + nextActions.add(outputLinkIdea.get("HIDE")); + } + if(outputLinkIdea.get("EAT") != null) { + nextActions.add(outputLinkIdea.get("EAT")); + } + if(outputLinkIdea.get("IMPASSE_INFO") != null) { + nextActions.add(outputLinkIdea.get("IMPASSE_INFO")); + } + if(outputLinkIdea.get("INPUT_LINK") != null) { + nextActions.add(outputLinkIdea.get("INPUT_LINK")); + System.out.println("Detectou input link"); + } + if(outputLinkIdea.get("plan") != null) { + Idea actionZeroFromPlan = outputLinkIdea.get("plan").get("0"); + Idea actionZeroFromPlanName = actionZeroFromPlan.getL().get(0); + nextActions.add(actionZeroFromPlanName.getL().get(0)); + } + return nextActions; + } + + private double[] getRandomPosition() { + if(counter == 10){ + counter = 0; + Random r = new Random(); + double x = r.nextInt(width); + double y = r.nextInt(height); + pos = new double[]{x, y}; + } + counter++; + return pos; + } + + private static void showImpasseInfo(Idea impasseOutputLinkIdea) { + StringBuilder impasseInfo = new StringBuilder(); + exportIdeaGraph(impasseOutputLinkIdea, impasseInfo, 0); + System.out.println("Impasse happened. This are the impasse infos:\n" + impasseInfo.toString()); + } + + private static void saveInputLink(Idea impasseInputLinkIdea) { + StringBuilder inputLink = new StringBuilder(); + exportIdeaGraph(impasseInputLinkIdea, inputLink, 0); + try { + Files.write(Paths.get("inputlink.txt"), inputLink.toString().getBytes()); + } catch (IOException ex) { + Logger.getLogger(ActionSelection.class.getName()).log(Level.SEVERE, null, ex); + } + System.out.println("Input link is in file 'inputlink.txt'"); + } + + + public static void exportIdeaGraph(Idea idea, StringBuilder builder, int indentLevel) { + String indent = " ".repeat(indentLevel); + + // Se tiver subideias na lista, percorre cada uma + if (!idea.getL().isEmpty()) { + builder.append(indent).append("* ").append(idea.getName()).append("\n"); + for (Idea subIdea : idea.getL()) { + exportIdeaGraph(subIdea, builder, indentLevel + 1); + } + } else { + if (idea.getValue() instanceof Idea) { + exportIdeaGraph((Idea) idea.getValue(), builder, indentLevel); + } else { + builder.append(indent).append("- ").append(idea.getName()) + .append(": ").append(String.valueOf(idea.getValue())).append("\n"); + } + + } + + + } + + +} diff --git a/src/main/java/codelets/behaviors/EatClosestApple.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/EatClosestApple.java similarity index 91% rename from src/main/java/codelets/behaviors/EatClosestApple.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/EatClosestApple.java index f5a253f..472586a 100644 --- a/src/main/java/codelets/behaviors/EatClosestApple.java +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/EatClosestApple.java @@ -31,6 +31,7 @@ import br.unicamp.cst.representation.idea.Idea; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.*; import ws3dproxy.model.Thing; public class EatClosestApple extends Codelet { @@ -52,10 +53,10 @@ public EatClosestApple(int reachDistance) { @Override public void accessMemoryObjects() { - closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE"); - innerSenseMO=(MemoryObject)this.getInput("INNER"); - handsMO=(MemoryObject)this.getOutput("HANDS"); - knownMO = (MemoryObject)this.getOutput("KNOWN_APPLES"); + closestAppleMO=(MemoryObject)this.getInput(CLOSEST_APPLE); + innerSenseMO=(MemoryObject)this.getInput(INNER); + handsMO=(MemoryObject)this.getOutput(HANDS); + knownMO = (MemoryObject)this.getOutput(KNOWN_APPLES); } @Override diff --git a/src/main/java/codelets/behaviors/Forage.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/Forage.java similarity index 100% rename from src/main/java/codelets/behaviors/Forage.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/Forage.java diff --git a/src/main/java/codelets/behaviors/GoToClosestApple.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/GoToClosestApple.java similarity index 93% rename from src/main/java/codelets/behaviors/GoToClosestApple.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/GoToClosestApple.java index 91b4f84..f337558 100644 --- a/src/main/java/codelets/behaviors/GoToClosestApple.java +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/behaviors/GoToClosestApple.java @@ -28,6 +28,7 @@ import br.unicamp.cst.core.entities.MemoryContainer; import br.unicamp.cst.core.entities.MemoryObject; import br.unicamp.cst.representation.idea.Idea; +import static support.Constants.*; import ws3dproxy.model.Thing; public class GoToClosestApple extends Codelet { @@ -46,9 +47,9 @@ public GoToClosestApple(int creatureBasicSpeed, int reachDistance) { @Override public void accessMemoryObjects() { - closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE"); - selfInfoMO=(MemoryObject)this.getInput("INNER"); - legsMO=(MemoryContainer)this.getOutput("LEGS"); + closestAppleMO=(MemoryObject)this.getInput(CLOSEST_APPLE); + selfInfoMO=(MemoryObject)this.getInput(INNER); + legsMO=(MemoryContainer)this.getOutput(LEGS); } @Override diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/decision/SoarCodelet.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/decision/SoarCodelet.java new file mode 100644 index 0000000..f4e3a45 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/decision/SoarCodelet.java @@ -0,0 +1,60 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package codelets.decision; + +import br.unicamp.cst.bindings.soar.JSoarCodelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.io.File; +import support.Constants; + +/** + * + * @author karenlima + */ +public class SoarCodelet extends JSoarCodelet { + + private Memory inputLinkIdeaMO; + private Idea inputLinkIdea; + private Memory outputLinkIdeaMO; + private Idea outputLinkIdea; + + + public SoarCodelet(String agentName, File productionPath, Boolean startSOARDebugger) { + initSoarPlugin(agentName, productionPath, startSOARDebugger); + this.name = "SoarCodelet"; + } + + @Override + public void accessMemoryObjects() { + inputLinkIdeaMO=(MemoryObject)this.getInput(Constants.INPUT_LINK_MO); + inputLinkIdea = (Idea) inputLinkIdeaMO.getI(); + + outputLinkIdeaMO=(MemoryObject)this.getOutput(Constants.OUTPUT_LINK_MO); + outputLinkIdea = (Idea) outputLinkIdeaMO.getI(); + + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + if (inputLinkIdea.getL().isEmpty()){ + return; + } + setInputLinkIdea(inputLinkIdea); + if (getDebugState() == 0) { + getJsoar().step(); + } + + Idea soarOutputLink = getJsoar().getOutputLinkIdea(); + outputLinkIdea.setValue(soarOutputLink.getValue()); + outputLinkIdea.setL(soarOutputLink.getL()); + outputLinkIdeaMO.setI(outputLinkIdea); + } +} diff --git a/src/main/java/codelets/motor/HandsActionCodelet.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/motor/HandsActionCodelet.java similarity index 100% rename from src/main/java/codelets/motor/HandsActionCodelet.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/motor/HandsActionCodelet.java diff --git a/src/main/java/codelets/motor/LegsActionCodelet.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/motor/LegsActionCodelet.java similarity index 98% rename from src/main/java/codelets/motor/LegsActionCodelet.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/motor/LegsActionCodelet.java index b301879..efcbcb1 100644 --- a/src/main/java/codelets/motor/LegsActionCodelet.java +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/motor/LegsActionCodelet.java @@ -89,7 +89,7 @@ else if(action.equals("GOTO")){ double targetx=command.getDouble("X"); double targety=command.getDouble("Y"); if (!comm.equals(previousLegsAction)) - log.info("Sending move command to agent: ["+targetx+","+targety+"]"); + log.info("Sending move command to agent "+ c.getName()+" : ["+targetx+","+targety+"]"); try { c.moveto(speed, targetx, targety); } catch(Exception e) { diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/AppleDetector.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/AppleDetector.java new file mode 100644 index 0000000..752ba85 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/AppleDetector.java @@ -0,0 +1,92 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.perception; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.KNOWN_APPLES; +import static support.Constants.VISION_MO; +import ws3dproxy.model.Thing; + +/** + * Detect apples in the vision field. + * This class detects a number of things related to apples, such as if there are any within reach, + * any on sight, if they are rotten, and so on. + * + * @author klaus + * + */ +public class AppleDetector extends Codelet { + + private Memory visionMO; + private Memory knownApplesMO; + + public AppleDetector(){ + this.name = "AppleDetector"; + } + + @Override + public void accessMemoryObjects() { + synchronized(this) { + this.visionMO=(MemoryObject)this.getInput(VISION_MO); + } + this.knownApplesMO=(MemoryObject)this.getOutput(KNOWN_APPLES); + } + + @Override + public void proc() { + CopyOnWriteArrayList vision; + List known; + synchronized (visionMO) { + //vision = Collections.synchronizedList((List) visionMO.getI()); + vision = new CopyOnWriteArrayList((List) visionMO.getI()); + known = Collections.synchronizedList((List) knownApplesMO.getI()); + //known = new CopyOnWriteArrayList((List) knownApplesMO.getI()); + synchronized(vision) { + for (Thing t : vision) { + boolean found = false; + synchronized(known) { + CopyOnWriteArrayList myknown = new CopyOnWriteArrayList<>(known); + for (Thing e : myknown) + if (t.getName().equals(e.getName())) { + found = true; + break; + } + if (found == false && t.getName().contains("PFood") && !t.getName().contains("NPFood")) known.add(t); + } + + } + } + } + }// end proc + + @Override + public void calculateActivation() { + + } + + +}//end class + + diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/ClosestAppleDetector.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/ClosestAppleDetector.java new file mode 100644 index 0000000..30bfb40 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/perception/ClosestAppleDetector.java @@ -0,0 +1,99 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.perception; + + + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import br.unicamp.cst.representation.idea.Idea; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import static support.Constants.*; +import ws3dproxy.model.Thing; + +/** + * @author klaus + * + */ +public class ClosestAppleDetector extends Codelet { + + private Memory knownMO; + private Memory closestAppleMO; + private Memory innerSenseMO; + + private List known; + + public ClosestAppleDetector() { + this.name = "ClosestAppleDetector"; + } + + + @Override + public void accessMemoryObjects() { + this.knownMO=(MemoryObject)this.getInput(KNOWN_APPLES); + this.innerSenseMO=(MemoryObject)this.getInput(INNER); + this.closestAppleMO=(MemoryObject)this.getOutput(CLOSEST_APPLE); + } + @Override + public void proc() { + Thing closest_apple=null; + known = Collections.synchronizedList((List) knownMO.getI()); + Idea cis = (Idea) innerSenseMO.getI(); + synchronized(known) { + if(known.size() != 0){ + //Iterate over objects in vision, looking for the closest apple + CopyOnWriteArrayList myknown = new CopyOnWriteArrayList<>(known); + for (Thing t : myknown) { + String objectName=t.getName(); + if(objectName.contains("PFood") && !objectName.contains("NPFood")){ //Then, it is an apple + if(closest_apple == null){ + closest_apple = t; + } + else { + double Dnew = calculateDistance(t.getX1(), t.getY1(), (double)cis.get("position.x").getValue(), (double)cis.get("position.y").getValue()); + double Dclosest= calculateDistance(closest_apple.getX1(), closest_apple.getY1(), (double)cis.get("position.x").getValue(), (double)cis.get("position.y").getValue()); + if(Dnew vision; + + public SoarInputLinkGenerator(Creature c) { + this.c = c; + this.name = "SoarInputLinkGenerator"; + } + + @Override + public void accessMemoryObjects() { + synchronized(this) { + this.visionMO=(MemoryObject)this.getInput(Constants.VISION_MO); + } + inputLinkIdeaMO=(MemoryObject)this.getOutput(Constants.INPUT_LINK_MO); + inputLinkIdea = (Idea) inputLinkIdeaMO.getI(); + } + + @Override + public void calculateActivation() { + } + + @Override + public void proc() { + + synchronized (visionMO) { + vision = new CopyOnWriteArrayList((List) visionMO.getI()); + + prepareInputLink(); + inputLinkIdeaMO.setI(inputLinkIdea); + } + } + + private void prepareInputLink() { + synchronized (vision) { + inputLinkIdea.setL(new CopyOnWriteArrayList<>()); + Idea creatureIdea = new Idea("CREATURE"); + + Idea sensorIdea = new Idea("SENSOR"); + Idea visualIdea = new Idea("VISUAL"); + for (Thing t : vision) { + Idea entityIdea = new Idea("ENTITY"); + entityIdea.add(new Idea("DISTANCE", GetGeometricDistanceToCreature(t.getX1(),t.getY1(),t.getX2(),t.getY2(),c.getPosition().getX(),c.getPosition().getY()))); + entityIdea.add(new Idea("X", t.getX1())); + entityIdea.add(new Idea("Y", t.getY1())); + entityIdea.add(new Idea("X2", t.getX2())); + entityIdea.add(new Idea("Y2", t.getY2())); + entityIdea.add(new Idea("TYPE", getItemType(t.getCategory()))); + entityIdea.add(new Idea("NAME", t.getName())); + entityIdea.add(new Idea("COLOR",ws3dproxy.util.Constants.getColorName(t.getMaterial().getColor()))); + + visualIdea.add(entityIdea); + } + + sensorIdea.add(visualIdea); + + Idea fuelIdea = new Idea("FUEL"); + Idea fuelValueIdea = new Idea("VALUE", c.getFuel()); + fuelIdea.add(fuelValueIdea); + sensorIdea.add(fuelIdea); + creatureIdea.add(sensorIdea); + + Idea positionIdea = new Idea("POSITION"); + Idea creaturePositionXIdea = new Idea("X", c.getPosition().getX()); + Idea creaturePositionYIdea = new Idea("Y", c.getPosition().getY()); + positionIdea.add(creaturePositionXIdea); + positionIdea.add(creaturePositionYIdea); + creatureIdea.add(positionIdea); + + Idea parametersIdea = new Idea("PARAMETERS"); + Idea minFuelIdea = new Idea("MINFUEL", 400.0); + parametersIdea.add(minFuelIdea); + Calendar lCDateTime = Calendar.getInstance(); + Idea timestampIdea = new Idea("TIMESTAMP", lCDateTime.getTimeInMillis()); + parametersIdea.add(timestampIdea); + creatureIdea.add(parametersIdea); + inputLinkIdea.add(creatureIdea); + } + + } + + private String getItemType(int categoryType) { + String itemType = null; + switch (categoryType) { + case ws3dproxy.util.Constants.categoryBRICK: + itemType = "BRICK"; + break; + case ws3dproxy.util.Constants.categoryJEWEL: + itemType = "JEWEL"; + break; + case ws3dproxy.util.Constants.categoryFOOD: + case ws3dproxy.util.Constants.categoryNPFOOD: + case ws3dproxy.util.Constants.categoryPFOOD: + itemType = "FOOD"; + break; + case ws3dproxy.util.Constants.categoryCREATURE: + itemType = "CREATURE"; + break; + case ws3dproxy.util.Constants.categoryDeliverySPOT: + itemType = "DELIVERY"; + break; + } + return itemType; + } + + private double GetGeometricDistanceToCreature(double x1, double y1, double x2, double y2, double xCreature, double yCreature) { + float squared_dist = 0.0f; + double maxX = Math.max(x1, x2); + double minX = Math.min(x1, x2); + double maxY = Math.max(y1, y2); + double minY = Math.min(y1, y2); + + if(xCreature > maxX) + { + squared_dist += (xCreature - maxX)*(xCreature - maxX); + } + else if(xCreature < minX) + { + squared_dist += (minX - xCreature)*(minX - xCreature); + } + + if(yCreature > maxY) + { + squared_dist += (yCreature - maxY)*(yCreature - maxY); + } + else if(yCreature < minY) + { + squared_dist += (minY - yCreature)*(minY - yCreature); + } + + return Math.sqrt(squared_dist); + } +} diff --git a/src/main/java/codelets/sensors/InnerSense.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/sensors/InnerSense.java similarity index 100% rename from src/main/java/codelets/sensors/InnerSense.java rename to 0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/sensors/InnerSense.java diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/sensors/Vision.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/sensors/Vision.java new file mode 100644 index 0000000..47ae83d --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/codelets/sensors/Vision.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin + *****************************************************************************/ + +package codelets.sensors; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.entities.MemoryObject; +import java.util.List; +import static support.Constants.VISION_MO; +import ws3dproxy.model.Creature; +import ws3dproxy.model.Thing; + +/** + * Vision codelet is responsible for getting vision information + * from the environment. It returns all objects in the visual field + * an its properties. + * + * @author klaus + */ +//TODO How about implementing getvs 0 in Client? +public class Vision extends Codelet{ + + private Memory visionMO; + private Creature c; + + + public Vision(Creature nc) { + c = nc; + this.name = "Vision"; + } + + @Override + public void accessMemoryObjects() { + visionMO=(MemoryObject)this.getOutput(VISION_MO); + } + + @Override + public void proc() { + c.updateState(); + synchronized (visionMO) { + List lt = c.getThingsInVision(); + visionMO.setI(lt); + } + + }//end proc() + + @Override + public void calculateActivation() { + + } + + + +}// class end + + + + + diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/support/Constants.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/Constants.java new file mode 100644 index 0000000..9a6b8e6 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/Constants.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package support; + +/** + * + * @author karenlima + */ +public class Constants { + public static final String SENSORY = "Sensory"; + public static final String PERCEPTION = "Perception"; + public static final String PLANNING = "Planning"; + public static final String MOTOR = "Motor"; + public static final String BEHAVIORAL = "Behavioral"; + public static final String COMPETENCE = "Competence"; + public static final String WORKING = "Working"; + public static final String HANDS = "HANDS"; + public static final String LEGS = "LEGS"; + public static final String INNER = "INNER"; + public static final String VISION_MO = "VISION_MO"; + public static final String THINGS_KNOWN_MO = "THINGS_IN_KNOWN_MO"; + public static final String THINGS_KNOWN_IDEA = "THINGS_IN_KNOWN_IDEA"; + public static final String INPUT_LINK_MO = "INPUT_LINK_MO"; + public static final String INPUT_LINK_IDEA = "INPUT_LINK_IDEA"; + public static final String OUTPUT_LINK_MO = "OUTPUT_LINK_MO"; + public static final String OUTPUT_LINK_IDEA = "OUTPUT_LINK_IDEA"; + public static final String THINGS_IN_VISION_MEMORY_GROUP = "THINGS_IN_VISION_MEMORY_GROUP"; + public static final String THINGS_KNOWN_MEMORY_GROUP = "THINGS_KNOWN_MEMORY_GROUP"; + public static final String SOAR_IO_MEMORY_GROUP = "SOAR_IO_MEMORY_GROUP"; + public static final String MOTOR_MEMORY_GROUP = "MOTOR_MEMORY_GROUP"; + public static final String SOAR_RULES_PATH = "soar-rules.soar"; + public static final String SOAR_FILE_RULES_PATH = "/rules/soar-rules.soar"; + public static final String KNOWN_APPLES = "KNOWN_APPLES"; + public static final String CLOSEST_APPLE = "CLOSEST_APPLE"; + +} diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/support/NativeUtils.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/NativeUtils.java new file mode 100644 index 0000000..4a6a577 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/NativeUtils.java @@ -0,0 +1,222 @@ +package support; + +///This is how to use it +//import SoarBridge.NativeUtils; +// +//public class HelloJNI { +// static { +// try { +// NativeUtils.loadLibraryFromJar("/resources/libHelloJNI.so"); +// } catch (IOException e) { +// e.printStackTrace(); // This is probably not the best way to handle exception :-) +// } +// } +// +// public native void hello(); +//} + + + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; + +/** + * Simple library class for working with JNI (Java Native Interface) + * + * @see http://frommyplayground.com/how-to-load-native-jni-library-from-jar + * + * @author Adam Heirnich , http://www.adamh.cz + */ +public class NativeUtils { + + /** + * Private constructor - this class will never be instanced + */ + private NativeUtils() { + } + + public static void setLibraryPath(String path) { + Field fieldSysPath=null; + System.setProperty( "java.library.path", path ); + try { + fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" ); + } catch (Exception e) { + System.out.println("Exceção: "+e); + } + fieldSysPath.setAccessible( true ); + try { + fieldSysPath.set( null, null ); + } catch (Exception e) { + System.out.println("Exceção: "+e); + } + } + + public static void loadFileFromJar(String path) throws IOException { + + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prexif and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) + } + + // Check if the filename is okay + if (filename == null || prefix.length() < 3) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + System.out.println("Loading file from JAR: "+prefix+suffix); + // Prepare temporary file + //File temp = File.createTempFile(prefix, suffix); + File temp = new File(prefix+suffix); + temp.deleteOnExit(); + +// if (!temp.exists()) { +// throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); +// } + + // Prepare buffer for data copying + byte[] buffer = new byte[1024]; + int readBytes; + + // Open and check input stream + InputStream is = NativeUtils.class.getResourceAsStream(path); + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + // Open output stream and copy data between source file in JAR and the temporary file + OutputStream os = new FileOutputStream(temp); + try { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } finally { + // If read/write fails, close streams safely before throwing an exception + os.close(); + is.close(); + } + } + + /** + * Loads library from current JAR archive + * + * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting. + * Method uses String as filename because the pathname is "abstract", not system-dependent. + * + * @param filename The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext + * @throws IOException If temporary file creation or read/write operation fails + * @throws IllegalArgumentException If source file (param path) does not exist + * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters (restriction of {@see File#createTempFile(java.lang.String, java.lang.String)}). + */ + public static void loadLibraryFromJar(String path) throws IOException { + + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prexif and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) + } + + // Check if the filename is okay + if (filename == null || prefix.length() < 3) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + System.out.println("Loading Library: "+prefix+suffix); + // Prepare temporary file + //File temp = File.createTempFile(prefix, suffix); + File temp = new File(prefix+suffix); + temp.deleteOnExit(); + +// if (!temp.exists()) { +// throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); +// } + + // Prepare buffer for data copying + byte[] buffer = new byte[1024]; + int readBytes; + + // Open and check input stream + InputStream is = NativeUtils.class.getResourceAsStream(path); + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + // Open output stream and copy data between source file in JAR and the temporary file + OutputStream os = new FileOutputStream(temp); + try { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } finally { + // If read/write fails, close streams safely before throwing an exception + os.close(); + is.close(); + } + + // Finally, load the library + System.load(temp.getAbsolutePath()); + +// // Starts contributed code from Lofi to deal with files on the temporary folder in Windows +// final String libraryPrefix = prefix; +// final String lockSuffix = ".lock"; +// +// // create lock file +// final File lock = new File( temp.getAbsolutePath() + lockSuffix); +// lock.createNewFile(); +// lock.deleteOnExit(); +// +// // file filter for library file (without .lock files) +// FileFilter tmpDirFilter = +// new FileFilter() +// { +// public boolean accept(File pathname) +// { +// return pathname.getName().startsWith( libraryPrefix) && pathname.getName().endsWith( lockSuffix); +// } +// }; +// +// // get all library files from temp folder +// String tmpDirName = System.getProperty("java.io.tmpdir"); +// File tmpDir = new File(tmpDirName); +// File[] tmpFiles = tmpDir.listFiles(tmpDirFilter); +// +// // delete all files which don't have n accompanying lock file +// for (int i = 0; i < tmpFiles.length; i++) +// { +// // Create a file to represent the lock and test. +// File lockFile = new File( tmpFiles[i].getAbsolutePath() + lockSuffix); +// if (!lockFile.exists()) +// { +// System.out.println( "deleting: " + tmpFiles[i].getAbsolutePath()); +// tmpFiles[i].delete(); +// } +// } + } +} \ No newline at end of file diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/java/support/ResourcesGenerator.java b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/ResourcesGenerator.java new file mode 100644 index 0000000..0048d50 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/java/support/ResourcesGenerator.java @@ -0,0 +1,208 @@ +/***************************************************************************** + * Copyright 2007-2015 DCA-FEEC-UNICAMP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * Patricia Rocha de Toro, Elisa Calhau de Castro, Ricardo Ribeiro Gudwin + *****************************************************************************/ +package support; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import ws3dproxy.CommandExecException; +import ws3dproxy.model.Thing; +import ws3dproxy.model.World; +import ws3dproxy.model.WorldPoint; +import ws3dproxy.util.Constants; +import ws3dproxy.util.Logger; + +/** + * + * @author eccastro + */ +public class ResourcesGenerator extends Thread { + + private int timeInMinutes; + private List allThings = new ArrayList(); + private double width; + private double height; + private WorldPoint dsLocation; + private String growOption; + + public ResourcesGenerator(int timeframe, double envWidth, double envHeight, double xDS, double yDS, String growOption) { + super("ResourcesGenerator"); + if (timeframe == 0) timeInMinutes = Constants.TIMEFRAME; + else timeInMinutes = timeframe; + width = envWidth; + height = envHeight; + dsLocation = new WorldPoint(xDS,yDS); //delivery spot + this.growOption = growOption; + + } + + public void run() { + while (true) { + try { + switch(growOption) { + case "grow": + for (int jewelType = 0; jewelType < 6; jewelType++) { + generateJewel(jewelType); + } + generateFood(0); + break; + case "grow-food": + generateFood(0); + break; + case "grow-jewel": + for (int jewelType = 0; jewelType < 6; jewelType++) { + generateJewel(jewelType); + } + break; + default: + break; + } + //System.out.println(".......ResourcesGenerator cycle running........."); + + //generate food + //perishable + + //non-perishable + //generateFood(1); + ///generate jewels + //System.out.println("..............ResourcesGenerator SLEEPING........"); + //Thread.sleep(timeInMinutes * 60000); + Thread.sleep(timeInMinutes * 60000); + + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(-1); + } + + } + + } + + /** + * Knuth's algorithm to generate random Poisson distributed numbers + * @param lambda average rate of success in a Poisson distribution + * @return random number + */ + public static int getPoissonRandomNumber(double lambda) { + int k = 1; + double p = 1.0; + Random rd = new Random(); + + do { + k += 1; + p *= rd.nextDouble(); + } while (p > Math.exp((double) -lambda)); + return k - 1; + } + + private boolean checkAvailability(double cX, double cY) { + //discard the location of the DeliverySpot: + if((dsLocation.getX() == cX) && (dsLocation.getY() == cY)){ + return false; + } + + for (Thing each : allThings) { + if (each.secAreaContain(cX, cY)) { + return false; + } + + } + return true; + } + + private void generateFood(int type) { + try { + allThings = World.getWorldEntities(); + int number = 1; + Random rdX = new Random(); + Random rdY = new Random(); + double cX, cY; + String pointListStr = "" ; + + switch (type) { + //perishable + case 0: + number = getPoissonRandomNumber(Constants.pFoodLAMBDA); + break; + case 1: + //non-perishable + number = getPoissonRandomNumber(Constants.npFoodLAMBDA); + break; + } + for (int i = 0; i < number; i++) { + do { + cX = rdX.nextDouble() * width; + cY = rdY.nextDouble() * height; + + } while (!checkAvailability(cX, cY)); + + pointListStr = pointListStr+" "+cX+" "+cY; + } + World.createFoodInBatch(type, number, pointListStr); + } catch (CommandExecException ex) { + Logger.logException(ResourcesGenerator.class.getName(), ex); + } + + } + + private void generateJewel(int type) { + try { + allThings = World.getWorldEntities(); + int number = 1; + Random rdX = new Random(); + Random rdY = new Random(); + double cX, cY; + String pointListStr = "" ; + + switch (type) { + case 0: + number = getPoissonRandomNumber(Constants.redLAMBDA); + break; + case 1: + number = getPoissonRandomNumber(Constants.greenLAMBDA); + break; + case 2: + number = getPoissonRandomNumber(Constants.blueLAMBDA); + break; + case 3: + number = getPoissonRandomNumber(Constants.yellowLAMBDA); + break; + case 4: + number = getPoissonRandomNumber(Constants.magentaLAMBDA); + break; + case 5: + number = getPoissonRandomNumber(Constants.whiteLAMBDA); + break; + } + for (int i = 0; i < number; i++) { + do { + cX = rdX.nextDouble() * width; + cY = rdY.nextDouble() * height; + + } while (!checkAvailability(cX, cY)); + + pointListStr = pointListStr+" "+cX+" "+cY; + } + World.createJewelsInBatch(type, number, pointListStr); + } catch (CommandExecException ex) { + Logger.logException(ResourcesGenerator.class.getName(), ex); + } + + } +} diff --git a/0_ - DemoSoar/DemoSoarProject/src/main/resources/rules/soar-rules.soar b/0_ - DemoSoar/DemoSoarProject/src/main/resources/rules/soar-rules.soar new file mode 100644 index 0000000..ad1e264 --- /dev/null +++ b/0_ - DemoSoar/DemoSoarProject/src/main/resources/rules/soar-rules.soar @@ -0,0 +1,475 @@ +################################ CONFIGURATION ################################ +watch 5 +learn --off +epmem --set learning off +#smem --off +#log --level error + +################################### WANDER ################################### +# This operator will make the agent to walk ahead at the enviroment +# Propose*wander: +sp {propose*wander + (state ^io.input-link ) +--> + ( ^operator +) + ( ^name wander)} + +# Apply*wander: +# If the wander operator is selected, then generate an output command to it +sp {apply*wander + (state ^operator + ^io ) + ( ^output-link
        ) + ( ^name wander) +--> + (
          ^MOVE ) + ( ^Vel 0) + ( ^VelR 2) + ( ^VelL 0) +} + +############################## MOVE FOOD ##################################### +# This operator will make the agent go straight to the food + +# Propose*move*food: +sp {propose*move*food + (state ^io.input-link ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^POSITION ) + ( ^X ) + ( ^Y ) + ( ^TYPE FOOD) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^PARAMETERS.MINFUEL ) +--> + ( ^operator +) + ( ^name moveFood) + ( ^parameter ) + ( ^distance (sqrt (+ (* (- ) (- )) (* (- ) (- ))))) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^parameterFuel )} + +# Apply*move*food: +# If the move operator is selected, then generate an output command to it +sp {apply*move*food + (state ^operator + ^io ) + ( ^input-link ) + ( ^output-link
            ) + ( ^name moveFood) + ( ^parameter ) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^NAME ) +--> + (
              ^MOVE ) + ( ^Vel 1) + ( ^VelR 1) + ( ^VelL 1) + ( ^X ) + ( ^Y ) + #(halt) +} + +############################### EAT FOOD ##################################### +# This operator will make the agent eat the food + +# Propose*eat*food: +sp {propose*eat*food + (state ^io.input-link ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL.ENTITY ) + ( ^TYPE FOOD) + ( ^DISTANCE < 30) + ( ^NAME ) + ( ^SENSOR.VISUAL.ENTITY.NAME ) +--> + ( ^operator +) + ( ^name eatFood) + ( ^parameter ) + ( ^NAME ) + ( ^DISTANCE )} + +# Apply*eat*food: +# If the move operator is selected, then generate an output command to it +sp {apply*eat*food + (state ^operator + ^io ) + ( ^input-link ) + ( ^output-link
                ) + ( ^name eatFood) + ( ^parameter.NAME ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^NAME ) + - (
                  ^EAT ) +--> + (
                    ^EAT ) + ( ^Name ) + #(halt) +} + +############################# MOVE JEWEL ##################################### +# This operator will make the agent go straight to the jewel + +# Propose*move*jewel: +sp {propose*move*jewel + (state ^io.input-link ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^POSITION ) + ( ^X ) + ( ^Y ) + ( ^TYPE JEWEL) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^COLOR ) +--> + ( ^operator +) + ( ^name moveJewel) + ( ^parameter ) + ( ^distance (sqrt (+ (* (- ) (- )) (* (- ) (- ))))) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^COLOR )} + +# Apply*move*jewel: +# If the move operator is selected, then generate an output command to it +sp {apply*move*jewel + (state ^operator + ^io ) + ( ^input-link ) + ( ^output-link
                      ) + ( ^name moveJewel) + ( ^parameter ) + ( ^X ) + ( ^Y ) + ( ^NAME ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^NAME ) +--> + (
                        ^MOVE ) + ( ^Vel 1) + ( ^VelR 1) + ( ^VelL 1) + ( ^X ) + ( ^Y ) + #(halt) +} + +############################## GET JEWEL ##################################### +# This operator will make the agent get the jewel + +# Propose*get*jewel: +sp {propose*get*jewel + (state ^io.input-link ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL.ENTITY ) + ( ^TYPE JEWEL) + ( ^DISTANCE < 30) + ( ^NAME ) + ( ^SENSOR.VISUAL.ENTITY.NAME ) +--> + ( ^operator +) + ( ^name getJewel) + ( ^parameter ) + ( ^NAME ) + ( ^DISTANCE )} + +# Apply*get*jewel: +# If the move operator is selected, then generate an output command to it +sp {apply*get*jewel + (state ^operator + ^io ) + ( ^input-link ) + ( ^output-link
                          ) + ( ^name getJewel) + ( ^parameter.NAME ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL ) + ( ^ENTITY ) + ( ^NAME ) + - (
                            ^GET ) # Colocado por Ricardo +--> + (
                              ^GET ) + ( ^Name ) + #(halt) +} + +############################# AVOID BRICK #################################### +# This operator will make the agent avoid the brick +# Propose*avoid*brick: +sp {propose*avoidBrick + (state ^io.input-link ) + ( ^CREATURE ) + ( ^SENSOR.VISUAL.ENTITY ) + ( ^TYPE BRICK) + ( ^DISTANCE <= 61) +--> + ( ^operator +) + ( ^name avoidBrick) + ( ^parameter )} + + +# Apply*avoidBrick: +# If the move operator is selected, then generate an output command to it +sp {apply*avoidBrick + (state ^operator + ^io ) + ( ^name avoidBrick) + ( ^parameter ) + ( ^output-link
                                ) +--> + (
                                  ^MOVE ) + ( ^Vel 0) + ( ^VelR (* 55 (/ ))) + ( ^VelL 0)} + +################## OPERATORS PREFERENCES AND IMPASSE SOLVE ################### + +#JEWEL + +# Move Jewel or Move Food vs Get Jewel - getJewel wins +sp {pref*moveJewel*getJewel +(state ^operator + + +) +( ^name getJewel) +( ^name << moveJewel moveFood >>) +--> +( ^operator > ) +(write |moveJewel/moveFood vs getJewel - getJewel wins| (crlf) )} + +# Get Jewel vs Avoid Brick - getJewel wins +sp {pref*getJewel*avoidBrick +(state ^operator + + +) +( ^name getJewel) +( ^name avoidBrick) +--> +( ^operator > ) + (write |getJewel vs avoidBrick - getJewel wins| (crlf) )} + +# Move Jewel vs Move Jewel - closer distance wins +sp {pref*moveJewel*moveJewel*less*distance +(state ^operator + + +) +( ^name moveJewel) +( ^name moveJewel) +( ^parameter.distance ) +( ^parameter.distance < ) +--> +( ^operator > ) +(write |moveJewel vs moveJewel | | smaller then | (crlf) )} + +# Move Jewel vs Move Jewel - equal distances are the same +sp {pref*moveJewel*moveJewel*equals +(state ^operator + + +) +( ^name moveJewel) +( ^name moveJewel) +( ^parameter.distance ) +( ^parameter.distance == ) +--> +( ^operator = ) +(write |moveJewel vs moveJewel | | equals to | (crlf) )} + +# Get Jewel vs Get Jewel Preferences +sp {pref*getJewel*getJewel +(state ^operator + + +) +( ^name getJewel) +( ^name getJewel) +( ^parameter.distance ) +( ^parameter.distance < ) +--> +( ^operator > ) +(write |getJewel vs getJewel | | less than | (crlf) )} + +# Get Jewel vs Get Jewel Preferences +sp {pref*getJewel*getJewel-equals +(state ^operator + + +) +( ^name getJewel) +( ^name getJewel) +( ^parameter.distance ) +( ^parameter.distance == ) +--> +( ^operator = ) +(write |getJewel vs getJewel | | less than | (crlf) )} + + +# FOOD + +# Move Food vs Eat Food +sp {pref*moveFood*eatFood +(state ^operator + + +) +( ^name eatFood) +( ^name << moveFood moveJewel >>) +--> +( ^operator > ) +(write |eatFood vs move{Food/Jewel} - eatFood wins | (crlf) )} + +# Eat Food vs Avoid Brick +sp {pref*eatFood*avoidBrick +(state ^operator + + +) +( ^name eatFood) +( ^name avoidBrick) +--> +( ^operator > ) +(write |eatFood vs avoidBrick - eatFood wins| (crlf))} + +# Move Food vs Move Food Preferences +sp {pref*moveFood*moveFood +(state ^operator + + +) +( ^name moveFood) +( ^name moveFood) +( ^parameter.distance ) +( ^parameter.distance < ) +--> +( ^operator > ) +(write |moveFood vs moveFood | | less than | (crlf))} + +# Move Food vs Move Food Preferences +sp {pref*moveFood*moveFood-equals +(state ^operator + + +) +( ^name moveFood) +( ^name moveFood) +( ^parameter.distance ) +( ^parameter.distance == ) +--> +( ^operator = ) +(write |moveFood vs moveFood | | equals to | (crlf) )} + +# Eat Food vs Eat Food Preferences +sp {pref*eatFood*eatFood-less +(state ^operator + + +) +( ^name eatFood) +( ^name eatFood) +( ^parameter.distance ) +( ^parameter.distance < ) +--> +( ^operator > ) +(write |eatFood vs eatFood | | less than | (crlf))} + +# Eat Food vs Eat Food Preferences +sp {pref*eatFood*eatFood-equals +(state ^operator + + +) +( ^name eatFood) +( ^name eatFood) +( ^parameter.distance ) +( ^parameter.distance == ) +--> +( ^operator = ) +(write |eatFood vs eatFood | | equals to | (crlf))} + +# FOOD vs JEWEL + +# Move Food vs Move Jewel Preferences - Move Food Wins +sp {pref*moveFood*moveJewel*moveFoodWins +(state ^operator + + +) +( ^name moveFood) +( ^parameterFuel ) +( ^name moveJewel) +( ^io.input-link ) +( ^CREATURE.SENSOR.FUEL ) +( ^VALUE < ) +--> +( ^operator > ) +(write |moveFood vs moveJewel | | less than | (crlf) )} + +# Move Food vs Move Jewel Preferences - Move Jewel Wins +sp {pref*moveFood*moveJewel*moveJewelWins +(state ^operator + + +) +( ^io.input-link ) +( ^name moveFood) +( ^parameterFuel ) +( ^name moveJewel) +( ^CREATURE.SENSOR.FUEL ) +( ^VALUE > ) +--> +( ^operator > ) +(write |moveFood vs moveJewel | | higher than | (crlf) )} + +# Move Food vs Move Jewel Preferences - Move Jewel Wins +sp {pref*moveFood*moveJewel*tie +(state ^operator + + +) +( ^io.input-link ) +( ^name moveFood) +( ^parameterFuel ) +( ^name moveJewel) +( ^CREATURE.SENSOR.FUEL ) +( ^VALUE <= ) +--> +( ^operator = ) +(write |moveFood vs moveJewel | | higher than | (crlf) )} + +#BRICK + +# Avoid Brick vs Avoid Brick Preferences +sp {pref*avoidBrick*avoidBrick*without*move*jewel-less +(state ^operator + + +) +( ^name avoidBrick) +( ^name avoidBrick) +( ^parameter ) +( ^parameter < ) +--> +( ^operator > ) +(write |avoidBrick vs avoidBrick | | less than | ) (crlf)} + +# Avoid Brick vs Avoid Brick Preferences +sp {pref*avoidBrick*avoidBrick*without*move*jewel-equals +(state ^operator + + +) +( ^name avoidBrick) +( ^name avoidBrick) +( ^parameter ) +( ^parameter == ) +--> +( ^operator = ) +(write |avoidBrick vs avoidBrick | | equals to | (crlf))} + + +# WANDER + +# Wander Preferences +sp {pref*wander +(state ^operator +) +( ^name wander) +--> +( ^operator <)} + +# HALT + +sp {halt*condition + (state ^io.output-link
                                    ) + (
                                      ^ ) + --> + (write |The command: | | was issued! |) + (interrupt) +} \ No newline at end of file diff --git a/0_ - DemoSoar/READ.ME b/0_ - DemoSoar/READ.ME new file mode 100644 index 0000000..e69de29 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 7c52d76..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'DemoCST' diff --git a/src/main/java/AgentMind.java b/src/main/java/AgentMind.java deleted file mode 100644 index 9f1379a..0000000 --- a/src/main/java/AgentMind.java +++ /dev/null @@ -1,173 +0,0 @@ -/***************************************************************************** - * Copyright 2007-2015 DCA-FEEC-UNICAMP - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin - *****************************************************************************/ - -import br.unicamp.cst.core.entities.Codelet; -import br.unicamp.cst.core.entities.Memory; -import br.unicamp.cst.core.entities.Mind; -import br.unicamp.cst.representation.idea.Idea; -import codelets.behaviors.EatClosestApple; -import codelets.behaviors.Forage; -import codelets.behaviors.GoToClosestApple; -import codelets.motor.HandsActionCodelet; -import codelets.motor.LegsActionCodelet; -import codelets.perception.AppleDetector; -import codelets.perception.ClosestAppleDetector; -import codelets.sensors.InnerSense; -import codelets.sensors.Vision; -import java.awt.Polygon; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import ws3dproxy.model.Thing; -/** - * - * @author rgudwin - */ -public class AgentMind extends Mind { - - private static int creatureBasicSpeed=3; - private static int reachDistance=50; - public ArrayList behavioralCodelets = new ArrayList(); - - public AgentMind(Environment env) { - super(); - - // Create CodeletGroups and MemoryGroups for organizing Codelets and Memories - createCodeletGroup("Sensory"); - createCodeletGroup("Motor"); - createCodeletGroup("Perception"); - createCodeletGroup("Behavioral"); - createMemoryGroup("Sensory"); - createMemoryGroup("Motor"); - createMemoryGroup("Working"); - - // Declare Memory Objects - Memory legsMO; // This Memory is going to be a MemoryContainer - Memory handsMO; - Memory visionMO; - Memory innerSenseMO; - Memory closestAppleMO; - Memory knownApplesMO; - - //Initialize Memory Objects - legsMO=createMemoryContainer("LEGS"); - registerMemory(legsMO,"Motor"); - handsMO=createMemoryObject("HANDS", ""); - registerMemory(handsMO,"Motor"); - List vision_list = Collections.synchronizedList(new ArrayList()); - visionMO=createMemoryObject("VISION",vision_list); - registerMemory(visionMO,"Sensory"); - //CreatureInnerSense cis = new CreatureInnerSense(); - Idea cis = Idea.createIdea("cis","", Idea.guessType("AbstractObject",null,1.0,0.5)); - cis.add(Idea.createIdea("cis.pitch", 0D, Idea.guessType("Property", null,1.0,0.5))); - cis.add(Idea.createIdea("cis.fuel", 0D, Idea.guessType("Property", null,1.0,0.5))); - Idea position = Idea.createIdea("cis.position","", Idea.guessType("Property",null,1.0,0.5)); - position.add(Idea.createIdea("cis.position.x",0D,Idea.guessType("QualityDimension",null,1.0,0.5))); - position.add(Idea.createIdea("cis.position.y",0D,Idea.guessType("QualityDimension",null,1.0,0.5))); - cis.add(position); - Idea fov = Idea.createIdea("cis.FOV","", Idea.guessType("Property", null,1.0,0.5)); - Idea bounds = Idea.createIdea("cis.FOV.bounds","", Idea.guessType("Property", null,1.0,0.5)); - bounds.add(Idea.createIdea("cis.FOV.bounds.x",null, Idea.guessType("Property", null,1.0,0.5))); - bounds.add(Idea.createIdea("cis.FOV.bounds.y",null, Idea.guessType("Property", null,1.0,0.5))); - bounds.add(Idea.createIdea("cis.FOV.bounds.height",null, Idea.guessType("Property", null,1.0,0.5))); - bounds.add(Idea.createIdea("cis.FOV.bounds.width",null, Idea.guessType("Property", null,1.0,0.5))); - fov.add(bounds); - fov.add(Idea.createIdea("cis.FOV.npoints",0, Idea.guessType("Property", null,1.0,0.5))); - fov.add(Idea.createIdea("cis.FOV.points","", Idea.guessType("Property", null,1.0,0.5))); - cis.add(fov); - innerSenseMO=createMemoryObject("INNER", cis); - registerMemory(innerSenseMO,"Sensory"); - Thing closestApple = null; - closestAppleMO=createMemoryObject("CLOSEST_APPLE", closestApple); - registerMemory(closestAppleMO,"Working"); - List knownApples = Collections.synchronizedList(new ArrayList()); - knownApplesMO=createMemoryObject("KNOWN_APPLES", knownApples); - registerMemory(knownApplesMO,"Working"); - - // Create Sensor Codelets - Codelet vision=new Vision(env.c); - vision.addOutput(visionMO); - insertCodelet(vision); //Creates a vision sensor - registerCodelet(vision,"Sensory"); - - Codelet innerSense=new InnerSense(env.c); - innerSense.addOutput(innerSenseMO); - insertCodelet(innerSense); //A sensor for the inner state of the creature - registerCodelet(innerSense,"Sensory"); - - // Create Actuator Codelets - Codelet legs=new LegsActionCodelet(env.c); - legs.addInput(legsMO); - insertCodelet(legs); - registerCodelet(legs,"Motor"); - - Codelet hands=new HandsActionCodelet(env.c); - hands.addInput(handsMO); - insertCodelet(hands); - registerCodelet(hands,"Motor"); - - // Create Perception Codelets - Codelet ad = new AppleDetector(); - ad.addInput(visionMO); - ad.addOutput(knownApplesMO); - insertCodelet(ad); - registerCodelet(ad,"Perception"); - - Codelet closestAppleDetector = new ClosestAppleDetector(); - closestAppleDetector.addInput(knownApplesMO); - closestAppleDetector.addInput(innerSenseMO); - closestAppleDetector.addOutput(closestAppleMO); - insertCodelet(closestAppleDetector); - registerCodelet(closestAppleDetector,"Perception"); - - // Create Behavior Codelets - Codelet goToClosestApple = new GoToClosestApple(creatureBasicSpeed,reachDistance); - goToClosestApple.addInput(closestAppleMO); - goToClosestApple.addInput(innerSenseMO); - goToClosestApple.addOutput(legsMO); - insertCodelet(goToClosestApple); - registerCodelet(goToClosestApple,"Behavioral"); - - behavioralCodelets.add(goToClosestApple); - - Codelet eatApple=new EatClosestApple(reachDistance); - eatApple.addInput(closestAppleMO); - eatApple.addInput(innerSenseMO); - eatApple.addOutput(handsMO); - eatApple.addOutput(knownApplesMO); - insertCodelet(eatApple); - registerCodelet(eatApple,"Behavioral"); - behavioralCodelets.add(eatApple); - - Codelet forage=new Forage(); - forage.addInput(knownApplesMO); - forage.addOutput(legsMO); - insertCodelet(forage); - registerCodelet(forage,"Behavioral"); - behavioralCodelets.add(forage); - - // sets a time step for running the codelets to avoid heating too much your machine - for (Codelet c : this.getCodeRack().getAllCodelets()) - c.setTimeStep(200); - - // Start Cognitive Cycle - start(); - } - -}