///////////////////////////////////////////////////////////////////////////////////////////////////////// Autonomous Mode Code Template//// This file contains a template for simplified creation of an autonomous program for an Tetrix robot// competition.//// You need to customize two functions with code unique to your specific robot.///////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////// initializeRobot//// Prior to the start of autonomous mode, you may want to perform some initialization on your robot.// Things that might be performed during initialization include:// 1. Move motors and servos to a preset position.// 2. Some sensor types take a short while to reach stable values during which time it is best that// robot is not moving. For example, gyro sensor needs a few seconds to obtain the background// "bias" value.//// In many cases, you may not have to add any code to this function and it will remain "empty".///////////////////////////////////////////////////////////////////////////////////////////////////////

void initializeRobot(){ // Place code here to sinitialize servos to starting positions. // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.

return;}

///////////////////////////////////////////////////////////////////////////////////////////////////////// Main Task//// The following is the main code for the autonomous robot operation. Customize as appropriate for// your specific robot.//// The types of things you might do during the autonomous phase (for the 2008-9 FTC competition)// are://// 1. Have the robot follow a line on the game field until it reaches one of the puck storage// areas.// 2. Load pucks into the robot from the storage bin.// 3. Stop the robot and wait for autonomous phase to end.//// This simple template does nothing except play a periodic tone every few seconds.//// At the end of the autonomous period, the FMS will autonmatically abort (stop) execution of the program.///////////////////////////////////////////////////////////////////////////////////////////////////////

Also I am wondering if doing the tasks in 4 stages is the appropriate way to do this.

Wed Dec 04, 2013 3:52 pm

BurningLights

Professor

Joined: Sat Aug 31, 2013 9:15 amPosts: 256

Re: What is wrong with my program?

Right off the bat, I can see a few unusual things about your code. First of all, you do not want to put all of your autonomous code in an infinite loop. That will just make your entire program repeat itself until the autonomous period ends. Simply put an empty while (true){} loop at the end of your code to keep the program from ending until the FCS aborts it. Second of all, you have an excess of brackets. Brackets are used to enclose code within loops, if statements, and other such control structures. You do not need to put every separate chunk of code inside brackets. It's not an error if you do so, but it's unnecessary.

Now, from looking at your code, it appears that the first thing the robot does is turn for five seconds if the IR beacon is straight ahead or to the right of the sensor and stays still if it is to the left of the sensor. I'm not sure if this is the behavior you wanted, but if it's not, then that's where your troubles start. So, if you tell us what your robot is supposed to be doing, we might be able to help you work through it and determine the code you need to make it do that.

Thank you with the infinite loop problem, I was wondering why that was happening.We have a 4 omni-wheel "slidebot", so the first sequence is moving right if the ir is right of the program, then stop when it is left (because of the placement of the sensor). Then it drops a block and moves back. Then it moves right until the touch sensor is hit. The it moves forward and onto the ramp. My problem starts at the IR because it doesn't sense anything. We are using a hitechnic IR seeker 1200. For some reason the sensor won't pick up a signal. Did I mess up the sensor setup, miss a driver, or what?

Thu Dec 05, 2013 11:12 am

BurningLights

Professor

Joined: Sat Aug 31, 2013 9:15 amPosts: 256

Re: What is wrong with my program?

t70rulz wrote:

My problem starts at the IR because it doesn't sense anything. We are using a hitechnic IR seeker 1200. For some reason the sensor won't pick up a signal. Did I mess up the sensor setup, miss a driver, or what?

No you haven't missed anything, you've just come up against the physical limits of the sensor. If the beacon is at a very steep angle relative to the sensor, the sensor will not be able to detect it. One thing you could do to fix this is to keep sliding to the right until it detects the IR beacon to the left of the sensor. So, something like:

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum