Technology/Engineering/Robotics
978-448-6362
Groton-Dunstable Regional High School Groton, MA
You can define a range of random numbers for the V5 to generate with the following command:
rand()% (180); //A random number between 0 and 180 will be generated
To create a range that starts at a number greater than 0, simply add your minimum value:
rand()% (180)+90; //A random number will be generated between 90 and 270 (0+90 and 180+90)
One of the things you need to do in this project is to create code that would move the robot differently if it senses that it is stuck. The challenge is how to make the robot know it’s stuck. Or, to provide actions/behaviors that it can do to further randomize its movements that would have a similar effect to actually “knowing” it’s stuck. There are many ways you can do this. Checking values that would likely change periodically, but aren’t changing, could initiate a different set of actions. Below is one way of thinking about using multiple conditions for various movements and limiting how long the robot will attempt to complete any single action before changing its movements. It is not complete, nor is it my “recommended” method necessarily. It’s just to get you thinking.