CMRoboBits Wiki
No edit summary
 
Line 3: Line 3:
 
Also included in the default code are an example Behavior (CMRoboBits/robot/Behaviors/TestBehavior/) and Vision (CMRoboBits/robot/Behaviors/2011/) modules. The example behavior shows how to make the robot walk and move it's head, and to retrieve Vision Objects generated by the Vision Module. The example vision processor shows how to use the load and use the color thresholds from CMurfs to classify each pixel in the camera image as one of a handful of colors useful for RoboCup robots. It also shows an example of displaying a SegmentedImage and Shapes in the [[Running Log Files#Using_the_Visualizer|Visualizer]] and creating a new Vision Object.
 
Also included in the default code are an example Behavior (CMRoboBits/robot/Behaviors/TestBehavior/) and Vision (CMRoboBits/robot/Behaviors/2011/) modules. The example behavior shows how to make the robot walk and move it's head, and to retrieve Vision Objects generated by the Vision Module. The example vision processor shows how to use the load and use the color thresholds from CMurfs to classify each pixel in the camera image as one of a handful of colors useful for RoboCup robots. It also shows an example of displaying a SegmentedImage and Shapes in the [[Running Log Files#Using_the_Visualizer|Visualizer]] and creating a new Vision Object.
 
==Creating New Behaviors==
 
==Creating New Behaviors==
To start with, try modifying TestBehavior to perform your desired behaviors. Eventually, though, you'll want to have several behaviors available on the robot.
 
   
 
BehaviorsCreator is located in /tools/BehaviorsCreator. This tool creates a header and a .cpp for a new behavior based on a set of states of your choice.
 
BehaviorsCreator is located in /tools/BehaviorsCreator. This tool creates a header and a .cpp for a new behavior based on a set of states of your choice.
  +
*Before using it you should have a write down a list of states that completly cover all the possible situations of the robot during a given action.
+
Before using it you should figure out a list of states that completly cover all the possible situations of the robot during a given action.
As with other tools you first need to build it ('''build.sh'''). To execute it type '''run.sh''' and then follow the instructions of the program.
+
As with other tools you first need to build it by typing '''./build.sh'''. To execute it type '''./run.sh''' and then follow the instructions of the program.
  +
*The first question is the name of your behavior
  +
*The second question asks you to enter all the behavior's states, each on its own line. Leave a blank line to finish entering states.
 
*The third and last question refers to the state in which you want the robot to start.
 
*The third and last question refers to the state in which you want the robot to start.
Then you will have to copy the behaviors files (.h and .cpp) to a folder of your choice inside the cmurfs architecture (preferably inside the Behaviors folder).
+
Then you will have to copy the behaviors files (.h and .cpp) to a folder of your choice inside the cmurfs architecture in the robot folder (preferably inside the Behaviors folder).
   
You can either call this new behavior from another behavior, or add it to /robot/Behaviors/Configurable/BehaviorsConfigurable.cpp to allow it to be selected using the config files.
+
You can either call this new behavior from another behavior, or add it to /robot/Behaviors/Configurable/BehaviorsConfigurable.cpp to allow it to be selected using the config files. Add a #include line at the top with your behavior's header file, and add an if() statement in the BehaviorsConfigurable constructor to check if your behavior should be loaded. It should look like:
  +
else if (strcasecmp(name.c_str(), "<behavior name>") == 0) {
  +
behaviors = new RoboCup2011::<behavior name>(configFile, log);
  +
}
  +
Then you can tell CMurfs to use your behavior by modifying config/configurable.txt on the robot.

Latest revision as of 04:45, 15 November 2011

The default code is essentially an empty cogntive framework for you to use how you wish. Depending on the project you select, you can opt to fill in the framework wtih certain of the modules from the full CMurfs framework to allow you to focus on your chosen area of investigation. Ask Ryan if you have any questions about this.

Also included in the default code are an example Behavior (CMRoboBits/robot/Behaviors/TestBehavior/) and Vision (CMRoboBits/robot/Behaviors/2011/) modules. The example behavior shows how to make the robot walk and move it's head, and to retrieve Vision Objects generated by the Vision Module. The example vision processor shows how to use the load and use the color thresholds from CMurfs to classify each pixel in the camera image as one of a handful of colors useful for RoboCup robots. It also shows an example of displaying a SegmentedImage and Shapes in the Visualizer and creating a new Vision Object.

Creating New Behaviors[]

BehaviorsCreator is located in /tools/BehaviorsCreator. This tool creates a header and a .cpp for a new behavior based on a set of states of your choice.

Before using it you should figure out a list of states that completly cover all the possible situations of the robot during a given action. As with other tools you first need to build it by typing ./build.sh. To execute it type ./run.sh and then follow the instructions of the program.

  • The first question is the name of your behavior
  • The second question asks you to enter all the behavior's states, each on its own line. Leave a blank line to finish entering states.
  • The third and last question refers to the state in which you want the robot to start.

Then you will have to copy the behaviors files (.h and .cpp) to a folder of your choice inside the cmurfs architecture in the robot folder (preferably inside the Behaviors folder).

You can either call this new behavior from another behavior, or add it to /robot/Behaviors/Configurable/BehaviorsConfigurable.cpp to allow it to be selected using the config files. Add a #include line at the top with your behavior's header file, and add an if() statement in the BehaviorsConfigurable constructor to check if your behavior should be loaded. It should look like:

else if (strcasecmp(name.c_str(), "<behavior name>") == 0) {
    behaviors = new RoboCup2011::<behavior name>(configFile, log);
}

Then you can tell CMurfs to use your behavior by modifying config/configurable.txt on the robot.