View unanswered posts | View active topics It is currently Thu Aug 21, 2014 2:36 pm






Reply to topic  [ 10 posts ] 
FTC Functions Guide - Version 1 
Author Message
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post FTC Functions Guide - Version 1
Hi Everyone!

I created a functions list for the FTC competition when programming with ROBOTC. This document will hopefully explain some of the new functions found in ROBOTC for the competition.

Download it here as a PDF: http://www.education.rec.ri.cmu.edu/content/events/ftc/robotc/sub_pages/docs/FTC_Functions_Guide.pdf

Any comments or requests are welcomed!

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Sep 26, 2008 12:26 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: FTC Functions Guide - Version 1
I noticed a couple of issues:

1) The description of the TJoystick structure is missing the TeamColor field. Note that joystickdriver.c does document the values for TeamColor. I suggest adding some #define or enum values for teamColorRed and teamColorBlue.

2) The description of the TJoystick structure does not say what the possible values of UserMode are. Note that joystickdriver.c does not currently document the values for UserMode. I suggest adding some #define or enum values for userModeAuto, userModeDriver.

3) Likewise, I would suggest adding an enum or set of defines for the tophat positions:
#define topHatIdle -1
#define topHatNorth 0
#define topHatNorthEast 1
#define topHatEast 2
....

4) I'm not real keen on the functions joy1Btn() and joy2Btn(). It seems inconsistant to have getJoystickSettings() take a TJoystick parameter but joy1Btn() and joy2Btn() always use a specific instance of TJoystick which is pretty much hidden from the user. Either hide the instance of TJoystick the way that joy1Btn() and joy2Btn() do for all fields of the TJoystick structure or have all of the functions take a parameter. Doing it half one way and half the other will be confusing and error prone.

One alternative would be to provide a macro that looked like this:

#define joyStickButton(buttons, n) ((buttons) & (1 << (n-1)))

The user code would look like this:

if (joyStickButton(joystick.joy1_Buttons, 2))
.....

Or, you could do what we've been doing which is to define a set of values like so:

#define Button1 0x01
#define Button2 0x02
#define Button3 0x04
....

Then the user code looks like this:

if (joystick.joy1_Buttons & Button2)
.....

5) I'm a little confused about the plan for this year's competition template. For the showcase tournament the competition template worked great. We just needed to provide the Initialization() function and the Autonomous() and HumanControl() tasks. I liked the simplicity that the main() in the template would start and stop the team's tasks as needed so that the team did not have to (and in fact could not) screw up the state transitions. Is there a reason you aren't using the same model now?

6) For this example:
while(nMotorRunState[motorD] != runStateIdle){} //wait for motor to become idle
//Above Line: Do nothing until motorD gets to the targeted position.
Wouldn't it be better practice to insert a small wait into the body of the while to release unneeded CPU cycles for background tasks?

7) I know that the FTC Motor Controller supports additional functionality such as the difference between running at a constant power v/s running at a constant speed. It would be nice to have those differences explained in this guide.

8) You might also want to document how to use the HiTechnic Touch Multiplexer. We ended up writing our own accessor functions to interpret the raw sensor values.

Jeff

_________________
Jeff McBride
Benson Robotics Club


Fri Sep 26, 2008 2:25 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post Re: FTC Functions Guide - Version 1
Jeff McBride wrote:
1) The description of the TJoystick structure is missing the TeamColor field. Note that joystickdriver.c does document the values for TeamColor. I suggest adding some #define or enum values for teamColorRed and teamColorBlue.


Unfortunately this feature was removed by FIRST and National Instruments. ROBOTC still supports it, but there's no way to toggle the variable in any version of the Field Management System or Controller Station. It's useless, so I left it out of the documentation.

Jeff McBride wrote:
2) The description of the TJoystick structure does not say what the possible values of UserMode are. Note that joystickdriver.c does not currently document the values for UserMode. I suggest adding some #define or enum values for userModeAuto, userModeDriver.


Not a bad suggestion. I can update to explain which value is true and which value is false. I'm not sure an enum is required, however, since it is a Boolean value.

Jeff McBride wrote:
3) Likewise, I would suggest adding an enum or set of defines for the tophat positions:
#define topHatIdle -1
#define topHatNorth 0
#define topHatNorthEast 1
#define topHatEast 2
....


We'll leave this up to the user, but it's not a bad suggestion.


Jeff McBride wrote:
4) I'm not real keen on the functions joy1Btn() and joy2Btn(). It seems inconsistant to have getJoystickSettings() take a TJoystick parameter but joy1Btn() and joy2Btn() always use a specific instance of TJoystick which is pretty much hidden from the user. Either hide the instance of TJoystick the way that joy1Btn() and joy2Btn() do for all fields of the TJoystick structure or have all of the functions take a parameter. Doing it half one way and half the other will be confusing and error prone.


Our testing showed that using joy1Btn(btn) and joy2Btn(btn) was well understood by teams. I'd be up for changing it, but we'd have to leave the legacy version in place to avoid breaking teams already developed code. I agree with the inconsistency of the structure, but these are macro/functions and not variables.

Jeff McBride wrote:
5) I'm a little confused about the plan for this year's competition template. For the showcase tournament the competition template worked great. We just needed to provide the Initialization() function and the Autonomous() and HumanControl() tasks. I liked the simplicity that the main() in the template would start and stop the team's tasks as needed so that the team did not have to (and in fact could not) screw up the state transitions. Is there a reason you aren't using the same model now?


To make programming easier for teams, all three software languages switched to a "two-program architecture". By keeping the auto/teleop code separate, you do lose the ability to transfer variables between the programs, but it makes programming much easier for new programmers. The old style template could still be used, but it seems like everyone is promoting the two-program style. I'll try and make something up to illustrate how this works.

Jeff McBride wrote:
6) For this example:
while(nMotorRunState[motorD] != runStateIdle){} //wait for motor to become idle
//Above Line: Do nothing until motorD gets to the targeted position.
Wouldn't it be better practice to insert a small wait into the body of the while to release unneeded CPU cycles for background tasks?


Yes. I'll update this in version 2.

Jeff McBride wrote:
7) I know that the FTC Motor Controller supports additional functionality such as the difference between running at a constant power v/s running at a constant speed. It would be nice to have those differences explained in this guide.


Agreed. This is more of a motors/sensor setup explanation though, which may be a separate guide. The PID capabilities have been simplified to a checkbox under the motors tab.

Jeff McBride wrote:
8) You might also want to document how to use the HiTechnic Touch Multiplexer. We ended up writing our own accessor functions to interpret the raw sensor values.


It's coming soon...

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Mon Sep 29, 2008 4:58 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: FTC Functions Guide - Version 1
hi,
why are those functions not available for common nxt programmers?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Mon Sep 29, 2008 5:09 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: FTC Functions Guide - Version 1
Because they relate to hardware that is currently only available to FTC teams. The general public will be able to buy the motor and servo controllers and so on in January.

_________________
Jeff McBride
Benson Robotics Club


Mon Sep 29, 2008 6:56 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: FTC Functions Guide - Version 1
hi there,
I've just founded a "FTC Beteigeuze Team".
Can I buy this stuff now? and where? ;-)

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Sep 30, 2008 4:54 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post Re: FTC Functions Guide - Version 1
Congrats on your new team, Ford... :bigthumb:

The kits are only available to teams that register with the FIRST Organization - http://www.usfirst.org/community/FTC/co ... spx?id=750

The "retail" kit will be available sometime in early 2009, available at:
http://www.legoeducation.com/store/deta ... 586&bhcp=1

These functions are available in all versions of ROBOTC for Mindstorms, you just have to set your platform type to FTC.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Tue Sep 30, 2008 12:28 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: FTC Functions Guide - Version 1
are there any restrictions of the FTC platform compared to the nxt platform?
Or is the FTC platform a complete overall superset of the nxt platform?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Sep 30, 2008 2:52 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: FTC Functions Guide - Version 1
The FTC platform is a superset of the NXT platform. Even if you do not have any of the Tetrix hardware, there are things you can do with RobotC set to the FTC platform. For example, if you have a USB game controller such as this one:
http://www.logitech.com/index.cfm/gaming/pc_gaming/gamepads/devices/288&cl=us,en

A USB game controller will allow you to add remote control capabilities to your robot. RobotC includes a tool that reads the joystick and button settings from one or even two game controllers and packages them up as bluetooth messages for the NXT.

_________________
Jeff McBride
Benson Robotics Club


Tue Sep 30, 2008 4:00 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: FTC Functions Guide - Version 1
sounds nice :)
thx for the info!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Sep 30, 2008 4:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.