jagomart
digital resources
picture1_Hp Behaviors


 145x       Filetype PDF       File size 0.39 MB       Source: s3.amazonaws.com


File: Hp Behaviors
robotc reference behaviors a behavior is anything your robot does turning on a single motor is a behavior moving forward is a behavior tracking a line is a behavior navigating ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
                                                                                                                                                     ROBOTC
                               Reference
                               Behaviors
                               A behavior is anything your robot does: turning on a single motor is a behavior, moving 
                               forward is a behavior, tracking a line is a behavior, navigating a maze is a behavior. There are 
                               three main types of behaviors that we are concerned with: basic behaviors, simple behaviors, 
                               and complex behaviors.
                               Basic Behaviors
                               Example: Turn on Motor Port 3 at half power
                               At the most basic level, everything in a program 
                               must be broken down into tiny behaviors that 
                               your robot can understand and perform directly. 
                               In ROBOTC, these are behaviors the size of 
                               single statements, like turning on a single 
                               motor, or resetting a timer.
                               Simple Behaviors
                               Example: Move forward for 2 seconds
                               Simple behaviors are small, bite-size behaviors 
                               that allow your robot to perform a simple, yet 
                               significant task, like moving forward for a certain amount of time. These are perhaps 
                               the most useful behaviors to think about, because they are big enough that you can describe 
                               useful actions with them, but small enough that you can program them easily from basic 
                               ROBOTC commands.
                               Complex Behaviors
                               Example: Follow a defined path through an entire maze
                               These are behaviors at the highest levels, such as navigating an entire maze. Though 
                               they may seem complicated, one nice property of complex behaviors is that they are always 
                               composed of smaller behaviors. If you observe a complex behavior, you can always break it 
                               down into smaller and smaller behaviors until you eventually reach something you recognize.
                                     task main()
                                     {
                                        motor[leftMotor] = 63;                                  Basic              Simple             Complex 
                                        motor[rightMotor] = 63;                                 behavior           behavior           behavior
                                        wait1Msec(2000);                                        This code          This code          This code makes 
                                                                                                turns the left     makes the          the robot move 
                                                                                                motor on at        robot go           around a corner.
                                        motor[leftMotor] = -63;                                 half power.        forward for 
                                                                                                                   2 seconds at 
                                        motor[rightMotor] = 63;                                                    half power.
                                        wait1Msec(400);
                                        motor[leftMotor] = 63;
                                        motor[rightMotor] = 63;
                                        wait1Msec(2000);
                                     } 
                                                                     ®
                      ©  Carnegie Mellon Robotics Academy  /  For use with VEX  Robotics Systems                                                  Behaviors • 1
                                                                                                                                                      ROBOTC
                               Reference
                               Behaviors
                               Composition and Analysis
                               Perhaps the most important idea in behaviors is that they can be built up or broken down 
                               into other behaviors. Complex behaviors, like going through a maze, can always be broken 
                               down into smaller, simpler behaviors. These in turn can be broken down further and further 
                               until you reach simple or basic behaviors that you recognize and can program.
                               By looking back at the path of behaviors you broke down, you can also see how the smaller 
                               behaviors should be programmed so that they combine back together, and produce the 
                               larger behavior. In this way, analyzing a complex behavior maps out the pieces that need 
                               to be programmed, then allows you to program them, and put them together to build the 
                               final product.
                                Large behavior                Smaller behaviors                        ROBOTC-ready behaviors
                                     F                             Go forward for
                                      o
                                       l
                                        l
                                        o
                                         w
                                           
                                           t
                                            h
                                             e
                                               
                                               p
                                                a
                                                 t
                                     t           h                 2 seconds                             1. Turn on left motor
                                      o
                                        
                                       r
                                        e
                                         a
                                          c
                                           h
                                             
                                             t
                                              h
                                               e
                                                 
                                                g
                                                 o
                                                  a
                                                   l                                                     2. Turn on right motor
                                   Go forward 2 seconds          T
                                   T                              urn on left motor
                                    urn left 90º                 T
                                   Go forward 2 seconds           urn on right motor                     3. Wait 2 seconds
                                                                 W
                                   T                              ait 2 seconds
                                    urn right 90º                T
                                                                  urn of
                                  Go forward 2 seconds          T     f left motor                       4. Turn off left motor
                                                                  urn of
                                  T                                   f right motor
                                   urn right 90º
                                  Go forward 2 seconds                                                   5. Turn off right motor
                                                                   Turn left 90º
                                                                  Reverse left motor                     6. Reverse left motor
                                                                  T
                                                                   urn on right motor                    7. Turn on right motor
                                                                 W
                               Step by step                      T ait 0.4 seconds
                                                                  urn of
                               1. Start with a large-            T     f left motor                      8. Wait 0.4 seconds
                                                                  urn of
                                  scale behavior that                 f right motor
                                  solves the problem.              Go forward for                        9. Turn off left motor
                               2. Break it down into               2 seconds                             10. Turn off right motor
                                  smaller pieces. Then 
                                  break the smaller              T
                                  pieces down as well.           Turn on left motor                      11. Turn on left motor
                                                                  urn on right motor
                                                                 W
                               3. Repeat until you                ait 2 seconds                          12. Turn on right motor
                                  have behaviors that 
                                  are small enough                                                       13. Wait 2 seconds
                                  for ROBOTC to 
                                  understand.                                                                          ...
                               Sometimes it can be hard to tell whether a behavior is “simple” or “complex”. Some programs 
                               are so complex they need multiple layers of simple behaviors before they reach the basic ones!
                               “Basic,” “Simple,” and “Complex” are categories of behaviors which are meant to help 
                               you think about the structure of programs. They are points of reference in the world of 
                               behaviors. Use these distinctions to help you, but don’t worry if your “complex” behavior 
                               suddenly becomes a “simple” part of your next program... just pick the point of reference 
                               that’s most useful for what you need.
                                                                     ®
                      ©  Carnegie Mellon Robotics Academy  /  For use with VEX  Robotics Systems                                                   Behaviors • 2
                                                                                                                              ROBOTC
                          Reference
                          Behaviors with Natural Language
                          Behavior Based Programming with the ROBOTC Natural Language
                          The ROBOTC Natural Language is designed to lower the barrier of entry into syntax-based 
                          programming by combining multiple basic behaviors into single commands. In other words, 
                          programmers can write their programs at the “simple behavior” level, without worrying about each 
                          basic behavior. The names of these new commands are also designed to be more intuitive and 
                          easier to remember. 
                          The sample code below causes the robot to perform the same exact complex behavior as before 
                          (turn around a corner), but is several lines shorter and can be understood more easily.
                                task main()                                  Many additional commands 
                                {                                            are available in the Natural 
                                  robotType(recbot);                         Language than what appear 
                                                                             in this sample code. Common 
                                  forward(63);                               behaviors such as line tracking, 
                                                                             moving straight, waiting for 
                                  wait(2.0);                                 particular sensor values, 
                                                                             remote control and others are 
                                  pointTurn(right, 63);                      available. For more information, 
                                  wait(0.4);                                 reference the ROBOTC Natural 
                                                                             Language document or the 
                                  forward(63);                               built-in ROBOTC Help.
                                  wait(2.0);
                                } 
                          In ROBOTC, the Natural Language can be enabled by selecting it as the Robot > Platform Type.
                                                          ®
                  ©  Carnegie Mellon Robotics Academy  /  For use with VEX  Robotics Systems                                Behaviors • 3
The words contained in this file might help you see if this file matches what you are looking for:

...Robotc reference behaviors a behavior is anything your robot does turning on single motor moving forward tracking line navigating maze there are three main types of that we concerned with basic simple and complex example turn port at half power the most level everything in program must be broken down into tiny can understand perform directly these size statements like or resetting timer move for seconds small bite allow to yet significant task certain amount time perhaps useful think about because they big enough you describe actions them but easily from commands follow defined path through an entire highest levels such as though may seem complicated one nice property always composed smaller if observe break it until eventually reach something recognize waitmsec this code makes turns left go around corner carnegie mellon robotics academy use vex systems composition analysis important idea built up other going simpler further by looking back broke also see how should programmed so combi...

no reviews yet
Please Login to review.