Go to Post There is more to our team than my hair, you know. :P - thefro526 [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 Rating: Thread Rating: 4 votes, 4.75 average. Display Modes
  #31   Spotlight this post!  
Unread 22-02-2007, 22:00
meatmanek meatmanek is offline
Programmer/physicist/mathematician
FRC #0868 (TechHounds)
Team Role: Programmer
 
Join Date: Mar 2004
Rookie Year: 2004
Location: Carmel, Indiana
Posts: 142
meatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to behold
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by buddy.smith View Post
I'd love to restructure the First code...I really don't like their coding style, but 6 weeks isn't enough time for that, so making the robot work was priority #1
--buddy
Amen to that.
__________________
Real programmers use vim.
  #32   Spotlight this post!  
Unread 22-02-2007, 22:00
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
FRC #0868
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Noblesville, IN
Posts: 1,408
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
Re: Programming tricks (and former trade secrets)

this year we used 2 SVN servers to keep track of all of our code, and changes. One was for the inexperienced programmers, so that they could learn, and the other was for the final versions of the code (code that would always compile, instead of having to track down all the convention mistakes and what not). Helped so that more than 1 person could work on the code at once, and allowed for much faster programming.
Also, for 868's state machine, we had multiple people write their own version, so that we could easily take the best of them. (points to meatmanek for winning out)
__________________
Be Healthy. Never Stop Learning. Say It Like It Is. Own It.

Like our values? Flexware Innovation is looking for Automation Engineers. Check us out!
  #33   Spotlight this post!  
Unread 22-02-2007, 22:08
meatmanek meatmanek is offline
Programmer/physicist/mathematician
FRC #0868 (TechHounds)
Team Role: Programmer
 
Join Date: Mar 2004
Rookie Year: 2004
Location: Carmel, Indiana
Posts: 142
meatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to behold
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by efoote868 View Post
(points to meatmanek for winning out)
It's amazing how excessively commenting your code (read: Just about every line that isn't a duplicate of a previous line) can bring about the appearance of quality.
__________________
Real programmers use vim.
  #34   Spotlight this post!  
Unread 23-02-2007, 20:43
JimGRobot JimGRobot is offline
Registered User
AKA: Jim
FRC #1388 (Eagle Robotics)
Team Role: Mentor
 
Join Date: Nov 2006
Rookie Year: 2005
Location: Arroyo Grande, CA
Posts: 29
JimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really nice
Re: Programming tricks (and former trade secrets)

Great thread, there are many good ideas out there.

We talked about the remote PROG button ourselves, but never implemented it.

One thing we did for the drivers was create an "Auto Trim" button for the joysticks. You use the regular trim adjust to get them close, then push the button. This saves the current joystick positions and subtracts those values from all future readings. This is built into a joystick "class" that is part of a code library that will be released to the world this spring.

We have an automatic scoring button, as others have mentioned, and separate buttons for all of the arm preset positions. We used a potentiometer for arm position feedback, and it works well.

One other cool thing is a micro-switch on the tube gripper to automatically close the jaws with a tube is present. This makes tube pickup very quick and easy.

We wired a bunch of momentary switches across a string of resistors connected to a single joystick input on the OI, instead of using 10 digital input bits. I will be making some PC boards over summer so others can do this very easily. The code does a little math to convert the input value into a switch number; this is built into another library class.

I guess that's all for now...
Jim
  #35   Spotlight this post!  
Unread 23-02-2007, 22:02
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Programming tricks (and former trade secrets)

Do you think you could talk more about the auto-trim button. We're having a lot of trouble keeping our joysticks in the right trim position. Or is it a closely guarded secret
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #36   Spotlight this post!  
Unread 24-02-2007, 00:56
JimGRobot JimGRobot is offline
Registered User
AKA: Jim
FRC #1388 (Eagle Robotics)
Team Role: Mentor
 
Join Date: Nov 2006
Rookie Year: 2005
Location: Arroyo Grande, CA
Posts: 29
JimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really nice
Re: Programming tricks (and former trade secrets)

Thanks for the note, no, this one is a loosely guarded secret...

We do some strange things with the scaling of our joysticks, but the principle is the same regardless of how you do it.

Start by creating a static global variable for each joystick axis, like:

char p1_x_offset = 0;
char p1_y_offset = 0;

Any place that you normally use the raw joystick value, use the joystick value minus the offset value, like:

pwm01 = (p1_y - p1_y_offset); //used to be p1_y only

Set the offset value to the joystick value when a button is pressed:

if ( button_pressed )
p1_y_offset = p1_y;

I think you get the idea. You are better off working with integer variables to avoid overflows, and handle limit checking, then converting back to char for writing to the pwm output.

Another thing to consider is adding a button to clear the offset. If you use this method to remove a large error, remember that the offset correction will not be present when the robot is reset, and the thing might take off.

In our implementation we limit the offset value to about 6 counts...

Let me know if you have other questions.

Jim
  #37   Spotlight this post!  
Unread 24-02-2007, 01:18
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Programming tricks (and former trade secrets)

I'm still having a little trouble understanding this. Say when your joystick is centered it gives a value of 130. If you set that to your offset and then move your joystick to 200. Wouldn't that only send you forward at a speed of 70? And then when your joystick is somewhere near 127 you would be going in reverse?

Thanks
-David
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us

Last edited by dpick1055 : 24-02-2007 at 01:22.
  #38   Spotlight this post!  
Unread 24-02-2007, 01:31
JimGRobot JimGRobot is offline
Registered User
AKA: Jim
FRC #1388 (Eagle Robotics)
Team Role: Mentor
 
Join Date: Nov 2006
Rookie Year: 2005
Location: Arroyo Grande, CA
Posts: 29
JimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really nice
Re: Programming tricks (and former trade secrets)

Sorry for the confusion, what I posted earlier only works if you scale your joysticks around zero by subtracting 127 from the joystick reading, and adding 127 back in before writing to the pwm.

So, here is a tweak to my earlier post. Instead of setting the offset to the joystick value, set it to the joystick value minus 127:

p1_y_offset = p1_y - 127;

If the joystick value is 130, and you press the auto trim button, the offset will be 3. When this value is subtracted from 130, you get the null value of 127. When the joystick value is 200, you get 197, and 100 you get 97.

If the offset value is too big, it will limit the range of the joystick value. Suppose you auto trim when the joystick value is 77, the offset is -50. When the raw value of the joystick is 254, the corrected value would only be 204, and if the raw value was less than 50, the corrected value would already be limited at zero.

Play around with this a little. The principle involved is to capture the difference between the joystick's actual value when trimmed, and what you want it to be when trimmed, and apply that difference to future readings.

Jim
  #39   Spotlight this post!  
Unread 24-02-2007, 01:35
dpick1055's Avatar
dpick1055 dpick1055 is offline
David Pick
FRC #1739 (Chicago Knights)
Team Role: Alumni
 
Join Date: May 2005
Rookie Year: 2004
Location: Chicago
Posts: 75
dpick1055 is on a distinguished road
Send a message via AIM to dpick1055
Re: Programming tricks (and former trade secrets)

Oh haha now I get it. I actually scaled our joystick values too so I could use a squaring function for driving. Thanks for the help, this is definitely something our drivers will appreciate.
__________________
Always remember to take your powered wheels off the ground when first testing code. Otherwise you'll end up with holes in the wall like us
  #40   Spotlight this post!  
Unread 24-02-2007, 03:32
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Programming tricks (and former trade secrets)

I started in the summer but I got in working during the build season. When I started I didn't even know the difference between C and C++. Through extensive research I was able to create a kind of "master" dashboard using Visual C++ 2005. It was designed to decrease the debugging time. I also had to develop the support code on the RC to work with this application through the program port.

You can watch any 10 int values simultaneously in a list form. Just choose form two drop down lists, one picks the type of variable(pwms, analogs, D In, D out, joysticks axes, etc.) and the other one is for choosing the number, ex. pwm05, and one can watch any preprogrammed value in real time. No need to reflash just to watch a different pwm!

It also has 16 extras that can be assigned to any variable like this, e_01 = variable(reprogramming is required but its much faster that modifying multiple printfs). Call up E1 from the GUI drop down list and you get a real time stream. The RC only sends 21 bytes over the serial port every loop, yet it provides the GUI with 10 int values.

The GUI can also graph the first 2 columns, allowing one to watch the relationship between the joystick input and the pwm output as it run through his/her algorithms, for example.

Also contains a camera simulator that shows the green tracking box and red cross hair target based on the camera T packet.

Though I haven't gotten around to it yet, I am working on an "fake" OI simulator that will allow me to control the robot from the computer

It was used somewhat for debugging but the robots were never really done...

Last edited by 6600gt : 24-02-2007 at 03:35.
  #41   Spotlight this post!  
Unread 24-02-2007, 06:50
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Programming tricks (and former trade secrets)

Things not implemented in team 2230's robot code:
We wanted to make a very simplified control system with the gyro in order to make the robot move from the drivers prespective. I.E: You need your robot to go left from your position. You turn the joystick to the left, the robot will turn left untill it reaches it's angle and will continue in that direction as long as the joystick is held in that direction. New joystick direction? The robot will stop and turn to the new direction and continue.
Of course, that was not implemented, because we lost our gyro a single day after we received it(about 2 weeks before the shipping of the robot instead of 4).

Things implemented

- Automated arm levels. Every push of the joystick's wheel in the certian direction will raise the arm of the robot to the direction and certain level we defined(1st level, the chute, 2nd level etc...).
- Automated platform lowering and manual raising. The platforms for the robots are automaticly lowered. With a special saftey press-code on the joystick, only after the driver is sure he wants to lower his platforms in the place he is he will lower it. At the end of the game, after the saftey inspectors go over the robot making sure the raising of the platforms won't damage anything, the platforms are raised slowly and manualy.
-Automatic jack system. With the help of the trusty acclerometer, we've been able to make sure all jacks attempt to level eachother while progressing to the height while trying to keep all motors at thier max speed in order to maintain stabilty.

Things hoping to be implmented
- A complete autonomous mode. In the "practice" day, we'll try to get values from the arena and define the certain values we need to make an autonomous mode that will use the values of the position the robot starts, the number of lights it should look for and which way to go in order to set the robot in the direction of the defined number of lights.

That's pretty much it.
  #42   Spotlight this post!  
Unread 24-02-2007, 15:48
Jake M Jake M is offline
void* Jake;
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Missouri
Posts: 118
Jake M has a spectacular aura aboutJake M has a spectacular aura about
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by JimGRobot View Post
Great thread, there are many good ideas out there.

We talked about the remote PROG button ourselves, but never implemented it.

One thing we did for the drivers was create an "Auto Trim" button for the joysticks. You use the regular trim adjust to get them close, then push the button. This saves the current joystick positions and subtracts those values from all future readings. This is built into a joystick "class" that is part of a code library that will be released to the world this spring.

We have an automatic scoring button, as others have mentioned, and separate buttons for all of the arm preset positions. We used a potentiometer for arm position feedback, and it works well.

One other cool thing is a micro-switch on the tube gripper to automatically close the jaws with a tube is present. This makes tube pickup very quick and easy.

We wired a bunch of momentary switches across a string of resistors connected to a single joystick input on the OI, instead of using 10 digital input bits. I will be making some PC boards over summer so others can do this very easily. The code does a little math to convert the input value into a switch number; this is built into another library class.

I guess that's all for now...
Jim
Speaking of trim, I was considering how to make a circuit that would give some kind of feedback (LED perhaps) when the voltage off of the joystick pots themselves corresponds to about 127 (about 1.82 volts, if I remember correctly) That way you could know how good your trim is, without even needing to use dashboard, or printfs. I was going to use the two weeks before competiton, and after shipping to do this. Then we learned that we had to ship the OI Board along with the robot, and all of our other joysticks are faulty in some way or another.
__________________
Code:
void function(void)
 {
  function();
 }
  #43   Spotlight this post!  
Unread 24-02-2007, 16:12
Cuog's Avatar
Cuog Cuog is offline
Registered Linux User: 390661
AKA: Alex
FRC #0422
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2004
Location: Richmond, Virginia
Posts: 852
Cuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond reputeCuog has a reputation beyond repute
Send a message via AIM to Cuog
Re: Programming tricks (and former trade secrets)

You can use the LEDs on the OI and have them turn on when the joystick input is where you want it.(for info on this look at the bottom of default_routine() in the default code
__________________
KK4KQO
http://voltair.us
Too many projects, too little time.
  #44   Spotlight this post!  
Unread 24-02-2007, 16:26
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by JimGRobot View Post
If the joystick value is 130, and you press the auto trim button, the offset will be 3. When this value is subtracted from 130, you get the null value of 127. When the joystick value is 200, you get 197, and 100 you get 97.
Be very careful with this. By doing this you're effectively overriding a safety feature built into the OI by IFI. That feature sets the OI outputs to 127 when the joystick is unplugged. If you have your "auto trim" set to subtract 10 (or whatever), then when a stick gets unplugged your robot will start driving.
  #45   Spotlight this post!  
Unread 24-02-2007, 17:07
Jake M Jake M is offline
void* Jake;
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Missouri
Posts: 118
Jake M has a spectacular aura aboutJake M has a spectacular aura about
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by Cuog View Post
You can use the LEDs on the OI and have them turn on when the joystick input is where you want it.(for info on this look at the bottom of default_routine() in the default code
Very true, but my whole reasoning for making such a circuit is not simply to let us see when the joysticks are trimmed or aren't, it's to let us do so without using up other OI features (such as the LEDs) which we could use for other feedback, concerning the actual driving of the robot. We can only acesss 8 of them, through the joystick ports and we could easily find 8 other uses for an LED.
__________________
Code:
void function(void)
 {
  function();
 }
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
Former FIRST student and mentor dies in a tragic rocket attack in Iraq today. Munkaboo General Forum 48 19-04-2005 12:21
Off-season competetions and former teams Venkatesh Off-Season Events 5 10-12-2004 17:23
Harry Potter and the Chamber of Secrets Ryan Dognaux Chit-Chat 33 01-12-2002 19:57
scouting tips and tricks Rick Scouting 1 08-01-2002 00:52


All times are GMT -5. The time now is 18:06.

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