Go to Post Mentors are the guardrails: Show the students how to do what they need to do, Step back and let the students do what they need to do, Nudge them back on course when they need a nudge, Insist, when necessary, that no one tries to juggle the chainsaws - gblake [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-01-2008, 23:10
jratcliff jratcliff is offline
Registered User
no team
 
Join Date: Jan 2008
Location: Lake Saint Louis, Missouri, USA
Posts: 10
jratcliff will become famous soon enoughjratcliff will become famous soon enough
Help, I'm a world class computer programming genius yet I'm totally lost.

Hey guys, I'm looking for help in getting started on things here. My son is a Freshman in high school and is beginning first robotics this year. His team doesn't really have any programming expertise to speak of and it looks like I have been drafted to help out.

I have been drafted because I am an expert professional computer programmer. I have been programming computers in assembly language, C and C++ for about 30 years. One of the first computers I programmed was an Altair, where you had to actually program the computer by setting each instruction in binary via a set of switches and pressing a button. Output was a set of LED lights.

So, color me surprised when in 2008 I find that high school kids are still programming low-level embedded systems as 'beginner projects'.

I have written a couple of best selling computer games for Electronic Arts, shipped games on numerous platforms and microprocessors, and more recently was the lead engine programmer for the massively multi player online game 'Planetside' for Sony Online Entertainment.

So, of course, I am posting a message in this forum, generally to a bunch of teenagers, asking, please, for some help.

Now, surely I don't need any help programming, that I know all about. What I want to know, is where in the heck is the documentation for the very, very, hardware specific features of programming these kits for the FRC competition?

This week I purchased a VEX Robotics kit and my son, Alex, put the whole thing together. Today we installed MPLAB and experimented with compiling and running some sample code.

This raised a huge number of questions. When you read the sample code provided it is filled with 'comments' that make references to obscure acronyms which I cannot find documented anywhere.

I currently have the MPLAB compiler, assembler, and linker. I can compile, link, and debug code both on the simulator and the robot controller itself. I have the MPLAB C documentation which, for the record, is quite excellent. I purchased this week a number of books about programming PIC microcontrollers and I am familiarizing myself with them.

Still, I have a number of questions. As I read source code, documentaiton, and messages here on the forum it appears to presume a massive amount of knowledge about acroynyms that I can't find documented anywhere. When beginners post questions on the forum they are generally referred to reference material on the C programming language. That's all well and good, but where is the reference material on the arcane oddities of getting the transmitter/receiver to talk to the microchip and the microchip to control inputs, outputs, and motors?

Let me give you a specific example. In the sample source code provided with the VEX as a 'learning tool' for new programmers you can find the following section of code:

/*
Example: The following would generate a 40KHz PWM with a 50% duty cycle
on the CCP2 pin (PWM OUT 1):
*/

/**
Setup_Who_Controls_Pwms(USER,USER,MASTER,MASTER,MA STER,MASTER,MASTER,MASTER);
CCP2CON = 0x3C;
PR2 = 0xF9;
CCPR2L = 0x7F;
T2CON = 0;
T2CONbits.TMR2ON = 1;
Setup_PWM_Output_Type(USER_CCP,IFI_PWM,IFI_PWM,IFI _PWM);
**/


This is, of course, remarkably non-useful to the new programmer. It raises a long series of important questions. In addition to wondering what the heck a 'PWM' is, and what it's good for, we have a lot of other questions.

(1) Where is the source code to the logic that runs when 'MASTER' is set to true? Is this, perhaps, in firmware and we don't have the source?
(2) What is 'CCP2CON' and why are we setting it to 0x3C? (No documentation)
(3) What is 'PR2' and why are we setting it to 0xF9?
(4) What is CCPR2L and why are we setting it to '0x7F'?
(5) What is 'TTCON' and why are we setting it to 0?
(6) What is 'T2CONbits.TMR2ON' and why are we setting it to zero?

Apparently, even in sample code for teenage programmers new to the FRC competition we are to assume they know what 'PWM', 'TTON', "CCPR2', and 'PR2' mean!???

Where is the missing piece of documentation in all of this?

I do have some very specific questions:

(1) Can I run the same code I compile and link with my VEX controller on the teams FRC controller?
(2) Kevin, of kevin.org, provides some amazing looking sample framework code. Can I run this on a VEX or is it for FRC only? Is there enough in Kevin's framework to run a basic robot on a frame, or does it still require a lot of code?
(3) Where can I find documentation about all of the device specific acronyms, what they mean, and how are they used?

For example, where is an explanation of (A) how to read all of the incoming signals from the remote control and (B) send output signals to all of the motors? Are these the same or different between the FRC controller and the VEX controller?

I feel like, after having read enormous amounts of documentation, reviewed a lot of source code, and gone over numerous reference books on how to program the PIC microcontroller, I still don't know how to make a motor turn when somebody moves a joystick button on the controller.

Just what am I missing??

Thanks,

John and Alex
  #2   Spotlight this post!  
Unread 12-01-2008, 23:31
robogeek753's Avatar
robogeek753 robogeek753 is offline
Droid Master
AKA: Bradley
FRC #0753 (The High Desert Droids)
Team Role: Leadership
 
Join Date: Jan 2007
Rookie Year: 2004
Location: Bend Oregon
Posts: 61
robogeek753 is an unknown quantity at this point
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

While I have never programmed a VEX Robot, I may be able to help a little bit.

0.) PWM is simply a output, usually to a motor's Victor speed controller.

To the rest of them, they look pretty VEX specific to me, I've never seen them on a FRC Robot (though I was looking at code someone else wrote, may be different at lower levels). Thus, to answer another question, you will probably have one heck of a time switching you code from VEX to FRC. (Look at the EasyC program and you have to change the entire format for FRC vs. VEX). p1_y indicates the joystick programmed into the first joystick port on our OI's Y axis value, this may help in setting up an FRC robot moving a bit.

Again, all the code I've looked at was written by someone else, so I don't know if they did any special setup to make it work so nice the way it did; but I am glad to offer any knowledge I can.

P.S. Welcome to the FRC and/or FTC!

P.P.S. If the code is confusing, try EasyC. Your team should have a free license for it, and it is actually a relatively powerful program (still trying to figure out how to use the text editor though...)
__________________
Really, simpler is better; really, I swear
WHY DON'T YOU BELIEVE ME???

Last edited by robogeek753 : 12-01-2008 at 23:35.
  #3   Spotlight this post!  
Unread 12-01-2008, 23:33
Nathans Nathans is offline
Registered User
AKA: Nathan
FRC #0004 (Element)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Los Angeles
Posts: 17
Nathans is an unknown quantity at this point
Send a message via AIM to Nathans
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

I've never personally programmed Vex, but I'm told that it's pretty much the same as the FRC controller, so they might be interchangeable.

As for documentation, Kevin Watson includes pretty extensive readmes with all of the code he writes (the C18 3.0+ beta not yet included), as well as pretty extensive documentation for C18 and the RC. All of this can be found on his code repository (kevin.org/frc).

If you have specific questions about his code, he patrols these forums pretty frequently. You can either wait for a response here (I wouldn't be surprised if he did), post in one of his threads or email him. One way or another, I'm sure you'll get an answer.

As for how close the default code gets you to a working robot, you can get basic drive code in a couple of lines, e.g.

Code:
pwm01 = p1_y
pwm02 = ~p2_y
This assumes that your motors are hooked up to pwm outs 1 and 2, your joysticks are plugged into ports 1 and 2, and that whichever motor needs to be flipped due to position is in pwm out 2. Hopefully Kevin's documentation or programmers better at this than me can shed some mroe light on this for you.
  #4   Spotlight this post!  
Unread 12-01-2008, 23:36
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Excellent post - I was where you are now, 3 years ago.

You may find this document at IFI Robotics interesting Control System Overview.

Over at Microchip you will find detailed (!) programming reference materials for the PIC PIC18F8722 resources.

If you don't want to climb the detailed learning curve of itsy-bitsy details, I suggest looking at Easy/C (there is a 30-day eval) and the accompanying WPILIB library.
  #5   Spotlight this post!  
Unread 12-01-2008, 23:44
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Also, the "default code" that comes from IFI contains a few lines of code that copy values from the joystick ports (connected to the Operator Interface) to the PWM outputs. PWM outputs are wired to Victor speed controllers, and these to the motors.

In user_routines.c is the "Default_Routine()" function where most people do their programming. The following lines copy joystick values to the PWM outputs. 127 is the 'neutral' or 'stop' value for the Victor speed controllers ... sending the PWM a 0 value would operate the attached motor at full speed, sending 254 would operated at full speed in the opposite direction.

Code:
  p1_x = 255 - p1_y;
  p1_y = 255 - pwm05;

  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
In ifi_aliases.h you find the definitions for the p1_x, p1_y, etc, etc defined-constants:

Code:
#define p1_y        rxdata.oi_analog01
#define p2_y        rxdata.oi_analog02
#define p3_y        rxdata.oi_analog03
#define p4_y        rxdata.oi_analog04
#define p1_x        rxdata.oi_analog05
#define p2_x        rxdata.oi_analog06
#define p3_x        rxdata.oi_analog07
#define p4_x        rxdata.oi_analog08
#define p1_wheel    rxdata.oi_analog09
#define p2_wheel    rxdata.oi_analog10
#define p3_wheel    rxdata.oi_analog11
#define p4_wheel    rxdata.oi_analog12
#define p1_aux      rxdata.oi_analog13
#define p2_aux      rxdata.oi_analog14
#define p3_aux      rxdata.oi_analog15
#define p4_aux      rxdata.oi_analog16
  #6   Spotlight this post!  
Unread 12-01-2008, 23:54
jratcliff jratcliff is offline
Registered User
no team
 
Join Date: Jan 2008
Location: Lake Saint Louis, Missouri, USA
Posts: 10
jratcliff will become famous soon enoughjratcliff will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Thanks for the replies. The main reason I am using the VEX is so that I can experiment programming a fully running robot at home while the high-school team still has a big pile of parts on the floor.

Yes, Kevin's framework looks quite impressive!

My questions are this:

(1) Will Kevin's code run on a VEX robot? (I can answer this myself in the morning just by compiling and running it of course.)

(2) Does his default framework have, out of the box, everything you need to drive a basic frame robot around or do you have to write all of that yourself?

As I said in my first message programming, C, or MPLAB, are not the issue. I'm just trying to understand, in code, how you get from point-A to point-B to make the robot respond to inputs and outputs across the board. I found a big missing hole in the sample code provided on the VEX so I quickly got stuck there.

I will read the documentation that is included in the links.

Thanks,

John & Alex

Last edited by jratcliff : 13-01-2008 at 00:00.
  #7   Spotlight this post!  
Unread 13-01-2008, 00:09
Otaku's Avatar
Otaku Otaku is offline
Where'd my wrench go?
AKA: Michael Baker
FRC #0675 (Tech High Phantom Robotics)
Team Role: College Student
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Underneath my car
Posts: 509
Otaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond reputeOtaku has a reputation beyond repute
Send a message via AIM to Otaku Send a message via MSN to Otaku
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Quote:
Originally Posted by jratcliff View Post
Thanks for the replies. The main reason I am using the VEX is so that I can experiment programming a fully running robot at home while the high-school team still has a big pile of parts on the floor.
Always a good idea. You don't want to find out that the code doesn't work a few days before ship. That's never good.

I would say more, but my interests are in turning knobs and filing stuff =p sorry.

[offtopic]If you're the J. Ratcliff, programmer I happen to be thinking of:

My dad happens to still have his copies of 668 Attack Sub and SSN-21 Seawolf as backups on his PC, and I have MW2 in my small games collection (as well as all the other MW games, I freakin' love mechs)

[/offtopic]

(Oh, and if you hear that the team needs help with mechanical stuff, encourage somebody to register and send me a PM, I'll help them out if they want, this goes for anybody btw)
__________________

"The [Otaku] is a simple creature." "Indeed. I cease to function when removed from a mill."
  #8   Spotlight this post!  
Unread 13-01-2008, 01:14
jratcliff jratcliff is offline
Registered User
no team
 
Join Date: Jan 2008
Location: Lake Saint Louis, Missouri, USA
Posts: 10
jratcliff will become famous soon enoughjratcliff will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Quote:
Originally Posted by Otaku View Post
[offtopic]If you're the J. Ratcliff, programmer I happen to be thinking of:

My dad happens to still have his copies of 668 Attack Sub and SSN-21 Seawolf as backups on his PC, and I have MW2 in my small games collection (as well as all the other MW games, I freakin' love mechs)

[/offtopic]
Yep, that's me. Sorry to the Easy C fans but I'm definitely thrilled with MPLAB and will be using it as my primary development platform. I'm really looking forward to having fun with this in years to come. However, in the short term, our team needs to get something up and running quickly and I have no external resources to draw upon other than this forum. I'll try to contact some people in the area who have past experience next week.

To carry the conversation here further, I might ask this. Soon enough I'm going to get the code working to control the motors and such yet I imagine that the programming for robots is a bit more sophisticated than simply 'move joystick send output to motor'? How sophisticated does the code get to deal simply with motion control on the robot? I saw reference to Kevin's code regarding 'encoders', which I can imagine has uses for motion control.

What kinds of techniques and algorithms are used purely to make the 'driving around' aspect of a robot more sophisticated?

Also, I do have a programming website. (http://www.codesuppository.blogspot.com/)

It has no FRC code on it (yet) but I will be making all of my development open-source as I become more familiar with the process.

John
  #9   Spotlight this post!  
Unread 13-01-2008, 01:36
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,574
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

First, about open sourcing your code. Kevin Watson has asked that his code not be redistributed, so be mindful of that.

For control algorithms, etc, the most important one to understand is PID control, though practically speaking most FRC mechanisms only need P or PD control. These whitepapers should prove helpful for that.

The (not-so) brief summary for PID control is that it works like your cruise control works. You pick a set point (cruising speed). The PIC compares this setpoint to feedback it gets from the real world (speedometer). If they don't agree, the PIC applies a control signal in the appropriate direction to correct. In a cruise control, if your actual speed is too slow, it hits the gas. Too fast, it lets off the gas. The algorithm simply multiplies the error by a constant gain and sets the output to this, and you have Proportional control. The remaining terms don't apply directly to cruise control, buuuut... If you were climbing a mountain/left the tire chains on/were dragging a boat anchor, then your car would consistently have an error, since you have to apply SOME gas to over come this, and when you hit your set point, you're applying 0 gas. So you integrate the error as time goes on, multiply by a gain, and add this to your P term. The longer you're missing your set point, the bigger this term, and the more you correct. Integral control. Finally, there's Derivative control. You monitor how fast the error is changing, multiply by a gain, and add. The purpose here is to slow down a rapidly correcting system so that it doesn't overshoot its target.

And all that is covered in more detail with better examples in those white papers. Encoders are opto-electrical devices that you can use to determine the position or speed of a shaft, so you can use them for the feedback. You can also use potentiometers, inductive or ultrasound sensors, photo-resistors, or whatever else is appropriate for what you're interested in controlling.

Finally, to end my last long winded post of the night, I'd highly recommend reading up on state-machines as mentioned in this presentation. It's a highly useful technique for autonomous programming. Especially with the hybrid mode this year.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #10   Spotlight this post!  
Unread 13-01-2008, 02:02
dtengineering's Avatar
dtengineering dtengineering is offline
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,823
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

I'd add more, but the important parts have already been covered... all within about two hours. Congratulations CD posters on doing an excellent job to help someone new to the field once again.

And if it is any comfort, it took me (programming since C64 days) a while to come up to speed, and our programming mentor (a professional software jockey) a couple weeks to make the switch from computers to robots. One of the great things about FIRST is that there is a lot for us old guys to learn, too!

Once you get the I/O figured out, there is a massive overlap in the skill set. Sounds like your on track to become an excllent mentor for this team!

Jason
  #11   Spotlight this post!  
Unread 13-01-2008, 15:57
Mauri Laitinen Mauri Laitinen is offline
Registered User
FRC #0115 (MVRT)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2004
Location: Cupertino, CA
Posts: 1
Mauri Laitinen is an unknown quantity at this point
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

I faced the same difficulty a few years ago when I started mentoring my daughter's team. I found that picking up a copy of "Programming and Customizing PICmicro Microcontrollers" by Myke Predko explained the odd acronyms and machine-specific identifiers.

While a lot of the book concentrates on basic architecture, you'll probably be more interested in the sections on timers and interrupts, including CCP. It beats trying to figure things out from datasheets. I picked up my copy at a Borders bookstore.

I'd also suggest looking at the MPLAB C18 User's Guide (available on microchip.com) especially the section on "ISO Divergences." It also discusses interrupt handling.

As everyone else has said, Kevin Watson's code is pretty much the definitive model for programming the robot controller.

The other place to help get up to speed is the white paper section of Chief Delphi and some of the kickoff seminars on the FIRST website.

Good luck.
  #12   Spotlight this post!  
Unread 14-01-2008, 09:37
Lafleur Lafleur is offline
Registered User
AKA: Tom Lafleur
FRC #0812
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2006
Location: San Diego
Posts: 34
Lafleur will become famous soon enoughLafleur will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

This is a good reference to the odd PIC things along with the current datasheet on the 18F8722 that you can download from Microchip...

Quote:
Applying PIC18 Microcontrollers: Architecture, Programming, and Interfacing using C and Assembly by Dr Barry B. Brey from DeVry University..

Takes you from knowing nothing to full development in Microchip "C". Very well organize and full of complete examples on I/O and Interrupts.

Recommend for both new and older programmers...

ISBN: 0-13-088546-0, over 500 pages and a bit pricey at $112

authors page: http://members.ee.net/brey/p10.htm

Last edited by Lafleur : 14-01-2008 at 15:27.
  #13   Spotlight this post!  
Unread 13-01-2008, 02:27
jratcliff jratcliff is offline
Registered User
no team
 
Join Date: Jan 2008
Location: Lake Saint Louis, Missouri, USA
Posts: 10
jratcliff will become famous soon enoughjratcliff will become famous soon enough
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Quote:
Originally Posted by Kevin Sevcik View Post
First, about open sourcing your code. Kevin Watson has asked that his code not be redistributed, so be mindful of that.

For control algorithms, etc, the most important one to understand is PID control, though practically speaking most FRC mechanisms only need P or PD control. These whitepapers should prove helpful for that.

The (not-so) brief summary for PID control is that it works like your cruise control works. You pick a set point (cruising speed). The PIC compares this setpoint to feedback it gets from the real world (speedometer). If they don't agree, the PIC applies a control signal in the appropriate direction to correct. In a cruise control, if your actual speed is too slow, it hits the gas. Too fast, it lets off the gas. The algorithm simply multiplies the error by a constant gain and sets the output to this, and you have Proportional control. The remaining terms don't apply directly to cruise control, buuuut... If you were climbing a mountain/left the tire chains on/were dragging a boat anchor, then your car would consistently have an error, since you have to apply SOME gas to over come this, and when you hit your set point, you're applying 0 gas. So you integrate the error as time goes on, multiply by a gain, and add this to your P term. The longer you're missing your set point, the bigger this term, and the more you correct. Integral control. Finally, there's Derivative control. You monitor how fast the error is changing, multiply by a gain, and add. The purpose here is to slow down a rapidly correcting system so that it doesn't overshoot its target.

And all that is covered in more detail with better examples in those white papers. Encoders are opto-electrical devices that you can use to determine the position or speed of a shaft, so you can use them for the feedback. You can also use potentiometers, inductive or ultrasound sensors, photo-resistors, or whatever else is appropriate for what you're interested in controlling.

Finally, to end my last long winded post of the night, I'd highly recommend reading up on state-machines as mentioned in this presentation. It's a highly useful technique for autonomous programming. Especially with the hybrid mode this year.
Thanks for an incredibly helpful post! Most of what I would post on my website would likely fit my main theme as 'snippets'. I define a snippet as a single self contained piece of source code with no external dependencies which 'does something useful'. I still have snippets I wrote 25 years ago that I keep in my bag of tricks today.

It sounds like I have about six weeks of documentation to read at this point with only four weeks left to completion!! It's clear to me now that FIRST does not really expect any robotics teams to build a robot from ground zero in six weeks; the learning curve simply to read documentation is quite steep even for a professional in the industry much less a high school student.

I have to say that this is all very intimidating for a brand new team that is just getting off of the ground. It doesn't help when PBS is filming the entire thing the whole time!

Kevin, you don't have to convince me about state machines. AI programming is my absolute favorite code to work on in computer games. I use a combination of state machines with memory to create AI's that avoid 'brain lock'. The other thing I really care about when writing AI's is to have them always dealing with lots of problems simultaneously in parallel.

I use a combination of state machines, memory, modular systems, and interrupts to create AI's that behave in a very natural way. I typically break systems out into various components (path finding, vision processing, emotional state, goal oriented behavior, etc.) and run all of these systems simultaneously in parallel feeding back to an interrupt driven state machine which runs via a scripting language on a virtual machine. A state machine, coupled with memories to avoid 'brain lock' allows a system to be extremely reactive and adaptive to its environment.

However, as my friend John Miles (http://www.thegleam.com/ke5fx/) likes to remind me, I need to learn to walk first before I start getting too far ahead of myself. By the way, if you don't know who John Miles is, he is an engineer worth knowing...

I do have one question in response to some of the answers I have received in this thread.

Why does it make any difference if I'm programming for a VEX or FRC controller? They both effectively have the same PIC micro-controller and execute the same basic logic.

I mean, worst case scenario I link to a different script, what does it matter which controller I run the C code on?

Thanks,

John

Last edited by jratcliff : 13-01-2008 at 02:29.
  #14   Spotlight this post!  
Unread 13-01-2008, 03:20
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,574
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

John,

First, I'll apologize now for lying in my last post about it being my last long winded post of the night....

To answer your last question first, in the broadest sense, it doesn't matter too very much if you're programming on Vex or FRC. The fundamental structure of the code is rather similar. Superficially, the inputs to the Vex controller are more limited and only consist of those few PWM_in# variables that tell you the position of the radio controller's sticks. These are equivalent to the p#_x, p#_y, etc on the FRC. The Vex controller doesn't have any equivalent of p#_sw_top, etc. Similarly, the vex's pwm## variables are equivalent to the same on the FRC. The FRC also has the relay#_fwd/rev variables that don't have vex equivalents. Digital IOs, analog inputs, and the serial ports are all mostly equivalent. The lack of physical space on the Vex brain meant IFI had to multiplex the analog inputs with the digital IOs, but this is not the case on the FRC controller.

Finally, because the FRC system plugs into a computer controlled field, the FRC controller receives bits instructing it to enter Disabled mode or Autonomous mode. Both as as they imply. In Disabled, your receive valid input from the operator console, but all outputs of the robot are disabled by the master processor, save the digital and analog IOs. In Autonomous, outputs are enabled, but the robot is intended to be on its own, so all inputs received from the operator console are invalid. The final operating mode is Teleop, which is the default if not in the other two modes. Inputs and outputs are both valid in this mode.

Now, here's the good news. Those massive tomes about the PIC microprocessors? You honestly barely need to read them. Nearly all of the onboard peripherals on the user PIC are either taken up by IFI or routed to pins on the exterior of the robot controller the are buffered or otherwise rendered useless for most advanced functions. If you're really determined, you mostly need to read up on three things. Interrupts, Timers, and CCPs. In that order, preferably. If you're really pressed for time, Kevin Watson has a LOT of functionality already coded up and in highly bug-tested form. If you're feeling more adventurous, I would look into Kevin's C18 3.10 version code or the restructured C18 2.4 code mentioned in this thread. This simple bit of restructuring makes the program flow much more intuitive and easier to follow.

That said, a large percentage of robots out there get by with little more than the "joystick 1 makes this motor go, button 3 makes this light blink" kind of code you mentioned earlier. After getting that far, I'd make it your primary goal to get some encoders on your robot's wheels/drive motors and attempt to implement a PID control on your drive speed. Robot drivetrains are notoriously poorly balanced and it can be easy to spot teams without PID control, as the robot will make a very graceful, large diameter arc whilst attempting to drive straight across the field. If you get that far, implementing a useful autonomous mode is fairly easy. You can use the encoder to measure the distance your robot has traveled use that to transition a state-machine design to get your robot driving down the field and making a left turn or whatever it seems appropriate to do.

So, like I said, you don't strictly need all the extra knowledge in those tomes. It CAN come in handy, of course. We used such esoteric knowledge one year to count the pulses on an encoder at rates much higher than it would be feasible to count them using interrupts. But by and large, you mostly need the info in all the IFI guides and manuals and the lack of time to make using Kevin Watson's code seem like a great idea.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #15   Spotlight this post!  
Unread 14-01-2008, 10:13
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Help, I'm a world class computer programming genius yet I'm totally lost.

Quote:
Originally Posted by jratcliff View Post
It sounds like I have about six weeks of documentation to read at this point with only four weeks left to completion!! It's clear to me now that FIRST does not really expect any robotics teams to build a robot from ground zero in six weeks; the learning curve simply to read documentation is quite steep even for a professional in the industry much less a high school student.
It is daunting for a new team, but it's also important not to lose focus. IFI and Kevin Watson have both provided code that essentially distills programming the robot into having to supply a handful of functions, with a fairly well-defined set of input and output variables. If you start simple and build your way up, it's pretty easy to get at least a basic robot implemented (our first year with the new C system, 2004, we managed to assemble a full controller with PID controls, shaft encoders, and a realtime clock, and that was with one mentor (myself) with decent programming experience and three students who had only done visual BASIC programming).

The other thing to remember is that there are a lot of good resources out there for new teams to use. You're visiting one of the better ones (ChiefDelphi). Look at the whitepapers. Read the forums. Ask questions. We're here to help you out. There are few problems you can run into where someone here can't help you out, and quickly.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AHHH! I'm a lost newbie! I need help! lkdjm Programming 8 28-01-2006 08:41
i'm in the charleston area, and i'm looking to help out a team near here... dickymon General Forum 2 05-08-2002 16:40
OK...so I'm totally out of the loop... Markfuscius 3D Animation and Competition 8 03-02-2002 02:39


All times are GMT -5. The time now is 02:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi