Programming help

Now that team 2092’s regional compettition is over we are to program the two robots we have to be able to go through a section of the school without touching the walls and it has to run automynously. We will be using easyc for this and would like help on how to do this.

The team is divided into two teams and unlucky for my team we dont have the programer. The other side does. Since I am highly inexperience with programming I would appreciate any and all help given to me.

I need to know how to write the program and if at all possible I would like a template for the program that I could just tweak to match our robot.

The robot uses two wheel drive. The rear wheels are traction while the front wheels are omnidirectional.

Though we are using the robot from the competition we are taking off the forklift so the only thing we are driving around is the base.

If you need anymore info to help me I’ll be more than happy to give it. If you would prefer to email me or IM me about this to explain things…

My Yahoo ID is lightofdragon17@yahoo.com
My gmail ID is 1337.etoile@gmail.com
My hotmail ID is etoile.1337@hotmail.com
My AIM ID is saikozettaibogyo@aol.com

Do you have any sort of feedback from the robot? Like two encoders?

Do you have any sensors to work with? You will need a way to find the walls to avoid, or open areas to drive towards.

If starting from scratch I would probably use an ultrasonic sensor like this:http://www.maxbotix.com/ either 1 on a servo to sweep the area, or 2 pointed at the walls.

If the walls and floor are different colors, you might want to try a prior year’s camera. However I think the software would be more complex.

Maybe if you don’t have The Programmer and so need a Mechanical solution (unfair, they don’t let you touch the walls!) you could just run a rope through your robot and stretch it tightly down the hallway? (Just kidding).

I agree about the Maxbotix ultrasonic sensors. They output various types of signals, but the easiest to use is the analog output which you connect to Analog Inputs on the robot controller. You will have to solder a PWM cable to the Maxbotix sensor board.

One easy thing to start with is a very simple EasyC program, that reads joystick inputs into a variable, and then copies the variable to the PWM outputs for the Victors. You ought to be able to get your robot drivable with the joystick in less than a dozen lines of code.

Next, mount two Maxbotix sensors to the front corners of your robot and aim them outwards towards the wall. Connect the PWM cables (you soldered previously) to two Analog inputs. Change your EasyC program to read the inputs and Print them so you know they are working, and what values you get at various distances from the wall.

Now it’s a “simple” matter of trying to have the robot steer to keep the analog input readings fairly equal. You will have to experiment with this, but to start with I suggest subtracting the left sensor value from the right sensor value to get the “error”. Use a signed variable, so that the error value can be positive or negative depending on which sensor has the higher value.

Now add this error variable to one PWM output value, and subtract it from the other. This will cause the robot to swerve - if you get the directions right, and steer in a very wiggly path down the hallway.

I recommend using the joystick fwd/rev motion to control speed, and to leave the steering joystick axis alone.

This should get you started.

I realize this is probably very unhelpful, but when I began learning how to program this year I found that easy c was extreamly unhelpful in programming an actual robot. I only found it useful when programming a vex bot from a kit. Maybe download a c compiler and a text editor and download the code that helps you get started provided by first robotics?

I realize most of what I just said is probably hard for anyone new to do. Definately would be for me.

Start in the getting started section of the help file. This will teach you enough to be able to program the robot to do most of the common tasks, like driver/operator controls, and a basic autonomous modes. Quite a few rookie teams were able to dead reckon their way around the field in autonomous this year. There is as also some sample code in the easyC forum below this one.

well, There is something called COPYCAT code.What happens is the code is executed with the trig of joystick 2. Joystick 1 will be used for driving as usual. What it does is it records the exact movements of the robot while that trigis pressed. so after doing the recording reset the robot and run the autonomus mode.

There is no Time limit to the copycat code,as you explained that the bot has to go through a door. So what you can do it put the robot in the starting position and driver the robot as you would usually do in the teleoperated mode and mke it go throught the doors. after you done recording, bring the robot back to its starting position, and start your auto.

How would the controller save the variables after reset? You would either have to type all the recorded distances and angles into the code by hand, or else you would have to use EEPROM, a bit difficult for a rookie team using EasyC.

As a suggestion, you should try hooking up a gyro and geartooth sensors. I have been very impressed with how well EasyC reads these sensors and gives you usable data. You could then write a drive function and a turn function, and use these, along with angles and distances, to run a successful autonomous mode.

As a side note: is there any way to use EEPROM with EasyC? That would be really useful.

well, sorry, i meant the copy cat code works in C.you have to code it like you said. Its a very complex code. me and my other partner worked hard on it.but as you said its hard for a rookie team to do it. so i think they are better off with GTS and gyro sensor with easy C.Becuase we tried to run GTS
on C and we couldnt run it.we thought there is a some problem in the sensor. Therefore we did not use is, instead we ended u using the copy cat code,which actually worked well for us. we were able to cross 2 lines with the delay of 5 secnds.

You can use an ultrasonic ranging sensor, like the one recommended above, or an infrared proximity sensor (I recommend the Sharp GP line, available from a number of retailers if you google “sharp infrared sensor”).

The easiest solution is to put one sensor looking to the left, one sensor looking to the right, and one looking dead ahead. Alternatively, put one sensor looking forward and to the left, and the other forward and to the right (both on 45 degree angles). You could also put a single sensor on a servo and scan back and forth, but this is a bit more complicated.

Now all you have to do is write code to turn right when an obstacle is to the left, turn left when an obstacle is to the right.

If there’s an obstacle in front of you, you can turn either way, or reverse (up to you!).

You can make this as simple or as advanced as you want. It could be as easy as what I described, or as hard as making a closed-loop control function to always keep you a certain distance away from the wall.

thanks for the suggestions!

what do you guys think about using a limit switch?

The problem with a mechanical limit switch is that it requires the switch to be depressed to change state, and that requires touching the walls. I would like to third?fourth? the suggestion of the maxbotix ultrasonic sensors. A proximity/range sensor is the one of the only ways, if not the only way to avoid walls.

Yes, I would highly recommend the Sharp IR proximity sensors. I have found them to be much more reliable than the Maxbotix ultrasonics (though they would probably work just fine too.) Then I would write a program (assuming you are using three sensors as outlined above) to keep your robot centered in the hall using the two side sensors. (You can also check yourself, because I’m assuming the halls are about the same width, uniformly. By reading in your two sensors, you can easily determine if there are alternate ways to go other than straight.)

Next, I would use some GTS (the KOP ONE was great… remember the second one is broken out of the box, and requires surface-mount soldering to fix (which our AWESOME mentor Mr. Allsop was able to do !!)) to keep track of your approximate distance. That way, if you had a course of attack, you could say “go forward approximately 28.3 feet, and at that point, start looking for turns”. This way it’s more difficult for the bot to get caught up somewhere it doesn’t know where it is.

CMUcam2 could work WONDERS in this application. With just 5 or 6 easyC code blocks, you could get your camera driving your bot around using color tags. If you had the ability to post colored sheets of paper in the halls to give the bot signals to turn, that would be awesome! If not, you could EASILY find identifiable colors to use as triggers for your bot.

Just let us know what you want to do, and we’d be happy to help you out. You can always PM me for assistance, or even call! I’d be happy to help!!!

Jacob

I have to research the copy cat code and find out as much as I can about it. >_> my teacher wants me to learn about it even though I told him it is not something that a person at my level of programming can do. At any rate could someone please explain how it works to me?

my email is uchihaboi12@hotmail.com