Go to Post Thanks, that clears things up a lot, and should probably have been obvious. - Branden Ghena [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-10-2009, 11:46
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
[FTC]: Robot C

Ok so last year i programmed in NXT-G and it was ok i got our team to win SC, but this year we want to do more complicated stuff we want to use Robot C, i know the basics but the Tele Op functions still esacpe me any help??
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #2   Spotlight this post!  
Unread 13-10-2009, 19:03
ttldomination's Avatar
ttldomination ttldomination is offline
Sunny
no team
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Roanoke, TX
Posts: 2,066
ttldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond repute
Re: [FTC]: Robot C

Try this link: http://www.robotc.net/teachingmindstorms/index.html

You'll find the the reserved words page is especially helpful.

Have Fun.
__________________
1261: 2007-2012
1648: 2013-2014
5283: 2015
Reply With Quote
  #3   Spotlight this post!  
Unread 13-10-2009, 21:21
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Robot C

I assume your question is in regards to using JoystickDriver.c for FTC?
Some more FTC specific ROBOTC links are:

http://www.education.rec.ri.cmu.edu/...botc/index.htm

http://www.education.rec.ri.cmu.edu/...tarted_tetrix/
Reply With Quote
  #4   Spotlight this post!  
Unread 02-11-2009, 13:51
blhenze blhenze is offline
Bernie H
FRC #2333 (Sapulpa Chieftain Robotics)
Team Role: Teacher
 
Join Date: Oct 2007
Rookie Year: 2008
Location: Sapulpa, OK
Posts: 19
blhenze is an unknown quantity at this point
Re: [FTC]: Robot C

I've had a couple of students attempt to use the RobotC testbed. Everything works great with just the motor. However, when we try to use the servo (Testbed 2) neither the motor or servo work. Any Suggestions?
Reply With Quote
  #5   Spotlight this post!  
Unread 02-11-2009, 16:14
vexman2222's Avatar
vexman2222 vexman2222 is offline
Registered User
AKA: Jakob BRaun
FTC #3385
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: MN, US
Posts: 5
vexman2222 is an unknown quantity at this point
Re: [FTC]: Robot C

I might be able to answer both of your questions

for a basic 2 motor 2 joystick teleOp drive:

joystick.joy1_y1 = motor[motorD]

joystick.joy1_y2 = motor[motorE]


assuming that you have the motors configured with defult names.

For button control you will use if statements:

if(joystick.joy1_buttons == )

{
motor[motorD] = 100;
motor[motorE] = 100;
}

I am still a little rusty from last year these might not work....
__________________
Prior Lake robotics is hosting the 2nd annual MN FTC snow drift competition on March 6th
Reply With Quote
  #6   Spotlight this post!  
Unread 02-11-2009, 21:12
jamie_1930's Avatar
jamie_1930 jamie_1930 is offline
Registered User
FRC #2228 (Cougartech)
Team Role: Student
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Rush-Henrietta
Posts: 371
jamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to beholdjamie_1930 is a splendid one to behold
Re: [FTC]: Robot C

Quote:
Originally Posted by vexman2222 View Post
I might be able to answer both of your questions

for a basic 2 motor 2 joystick teleOp drive:

joystick.joy1_y1 = motor[motorD]

joystick.joy1_y2 = motor[motorE]


assuming that you have the motors configured with defult names.

For button control you will use if statements:

if(joystick.joy1_buttons == )

{
motor[motorD] = 100;
motor[motorE] = 100;
}

I am still a little rusty from last year these might not work....
From what we've been doing the condition for your if statements should look like this

if(joy1Btn(1) == 1)
{
code here
}

this will make it so execute code when button 1 on joystick 1 is pressed.
Reply With Quote
  #7   Spotlight this post!  
Unread 04-11-2009, 11:18
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by jamie_1930 View Post
From what we've been doing the condition for your if statements should look like this

if(joy1Btn(1) == 1)
{
code here
}

this will make it so execute code when button 1 on joystick 1 is pressed.
so basically if a created a little automous program to run when i press a button would it work?
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #8   Spotlight this post!  
Unread 06-11-2009, 12:52
grampashades grampashades is offline
Registered User
FTC #0121
 
Join Date: Jan 2007
Rookie Year: 2004
Location: URI
Posts: 4
grampashades will become famous soon enough
Re: [FTC]: Robot C

Quote:
Originally Posted by jamie_1930 View Post
From what we've been doing the condition for your if statements should look like this

if(joy1Btn(1) == 1)
{
code here
}

this will make it so execute code when button 1 on joystick 1 is pressed.
First you guys want:

motor[motorE] = joystick.joy1_y2;

With C programming you set the thing on the left to the value on the right. The other way around shouldn't work. *Unless Robot C built it into the compiler to accept it both ways.

Also as a note to save you guys a lot of frustration later. I would suggets you put in a "dead zone" that stops you from powering the motors with too little voltage.


if ( ( joystick.joy1_y2 < -10) || ( joystick.joy1_y2 > 10))
{
motor[motorE] = joystick.joy1_y2;
}
else
{
motor[motorE] = 0;
}

your motors will thank you.

Second I've found throughout my tetsing that it is much better to program the buttons as such:


if(joy1Btn(1) )
{
code for what you want to happen here
}
else
{
code to make that stop happening
}

While there is not techinical difference in this case....for whatever reason the software gods seem to prefer it without the "==1"

finally, while techinically yes...you could put autonomous code into the "code here" section but you could also run into some serious problems...unless you keep all of your logic sound. You can easliy start getting in trouble when you try things like this.
Reply With Quote
  #9   Spotlight this post!  
Unread 09-11-2009, 10:25
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by grampashades View Post
First you guys want:

motor[motorE] = joystick.joy1_y2;

With C programming you set the thing on the left to the value on the right. The other way around shouldn't work. *Unless Robot C built it into the compiler to accept it both ways.

Also as a note to save you guys a lot of frustration later. I would suggets you put in a "dead zone" that stops you from powering the motors with too little voltage.


if ( ( joystick.joy1_y2 < -10) || ( joystick.joy1_y2 > 10))
{
motor[motorE] = joystick.joy1_y2;
}
else
{
motor[motorE] = 0;
}

your motors will thank you.

Second I've found throughout my tetsing that it is much better to program the buttons as such:


if(joy1Btn(1) )
{
code for what you want to happen here
}
else
{
code to make that stop happening
}

While there is not techinical difference in this case....for whatever reason the software gods seem to prefer it without the "==1"

finally, while techinically yes...you could put autonomous code into the "code here" section but you could also run into some serious problems...unless you keep all of your logic sound. You can easliy start getting in trouble when you try things like this.
That is beastly awsome, i'm going to test this with our robot when i get our 2nd motor controller.

LAWL I installed Windows 7 on our robotics laptop and all the software still works because it was compatible with Vista.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #10   Spotlight this post!  
Unread 10-11-2009, 09:36
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Robot C

That is generally good advice, but I'm going to go ahead and share some extra insight. Remember that the joystick analog sticks have a range of -127 to 128, but your DC motors only have a range of -100 to 100. While you can directly pass the analog stick value to the motor & ROBOTC will not error, you are losing about 20% of the actual range of the analog stick which will not give you the good fine-grained control your robot is capable of.

The basic solution is to apply a linear scale such as: motor_output = joystick_input / max_joystick_value * max_motor_value.

However, we can do even better if we use a parabolic curve so that we have fine control at low speeds for a larger portion of the analog stick's range and then ramp up the scaling for the extremities of the analog stick's range. Below is a function which will do just that (as well as apply a deadzone):

Code:
//scaling function
int scaleForMotor(int joyVal) {

  //constants
  const int DEADZONE = 5;
  const int MAX_MOTOR_VAL = 100;
  const float MAX_JOY_VAL = 127.0;

  //check for deadzone
  if(abs(joyVal) < DEADZONE) {
    return 0;
  }

  //calculate scaled value
  int sign = joyVal / abs(joyVal); // 1 or -1
  float ratio = ((joyVal * joyVal) / (MAX_JOY_VAL * MAX_JOY_VAL));
  int scaledVal = (sign * MAX_MOTOR_VAL) * ratio;

  return scaledVal;
}
I have no issues sharing this to help other teams get going, but please attempt to understand what it is doing if you choose to copy it into your code. Feel free to adjust the constants to set your own deadzone or max motor output.
Just place the function in your code above the main task and call it like below:

Code:
//scales input from joystick 1 left analog stick's y-axis
motor[someMotor] = scaleForMotor(joystick.joy1_y1);  
//scales input from joystick 1 right analog stick's y-axis
motor[someOtherMotor] = scaleForMotor(joystick.joy1_y2);
Best of luck,
l0jec
Reply With Quote
  #11   Spotlight this post!  
Unread 10-11-2009, 10:39
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

Quote:
Originally Posted by l0jec View Post
That is generally good advice, but I'm going to go ahead and share some extra insight. Remember that the joystick analog sticks have a range of -127 to 128, but your DC motors only have a range of -100 to 100. While you can directly pass the analog stick value to the motor & ROBOTC will not error, you are losing about 20% of the actual range of the analog stick which will not give you the good fine-grained control your robot is capable of.

The basic solution is to apply a linear scale such as: motor_output = joystick_input / max_joystick_value * max_motor_value.

However, we can do even better if we use a parabolic curve so that we have fine control at low speeds for a larger portion of the analog stick's range and then ramp up the scaling for the extremities of the analog stick's range. Below is a function which will do just that (as well as apply a deadzone):

Code:
//scaling function
int scaleForMotor(int joyVal) {

  //constants
  const int DEADZONE = 5;
  const int MAX_MOTOR_VAL = 100;
  const float MAX_JOY_VAL = 127.0;

  //check for deadzone
  if(abs(joyVal) < DEADZONE) {
    return 0;
  }

  //calculate scaled value
  int sign = joyVal / abs(joyVal); // 1 or -1
  float ratio = ((joyVal * joyVal) / (MAX_JOY_VAL * MAX_JOY_VAL));
  int scaledVal = (sign * MAX_MOTOR_VAL) * ratio;

  return scaledVal;
}
I have no issues sharing this to help other teams get going, but please attempt to understand what it is doing if you choose to copy it into your code. Feel free to adjust the constants to set your own deadzone or max motor output.
Just place the function in your code above the main task and call it like below:

Code:
//scales input from joystick 1 left analog stick's y-axis
motor[someMotor] = scaleForMotor(joystick.joy1_y1);  
//scales input from joystick 1 right analog stick's y-axis
motor[someOtherMotor] = scaleForMotor(joystick.joy1_y2);
Best of luck,
l0jec
That also looks very good, i understand what you were saying with the Parabolic Curve. THANK YOU!!!
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #12   Spotlight this post!  
Unread 10-11-2009, 10:41
BernieH BernieH is offline
Registered User
FTC #3677
 
Join Date: Nov 2009
Location: Sapulpa,High School
Posts: 1
BernieH is an unknown quantity at this point
Re: [FTC]: Robot C

Our Team is new to FTC and RobotC. We are trying to build programs that will allow us to use the joysticks with our robot. Would anyone be willing to share a complete program (rather than program segments that don't explain where the code goes) that would allow joystick 1 to control motorD and Joystick 2 to control motorE?

You can email me off line at bhenze@sapulpaps.org

Thanks
Reply With Quote
  #13   Spotlight this post!  
Unread 10-11-2009, 10:50
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Robot C

here you go
Make sure your RobotC is set to NXT and TETRIX mode and also go to motor and sensors setup and configure you motors to how you have them set up.



#include "joystickdriver.c"

task main ()
{
{
getJoystickSettings(joystick);
motor[motorD] = joystick.joy1_y1;
motor[motorE] = joystick.joy1_y2;
}
}
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #14   Spotlight this post!  
Unread 10-11-2009, 12:34
l0jec l0jec is offline
Registered User
no team
 
Join Date: Oct 2009
Rookie Year: 2004
Location: St. Louis, MO
Posts: 52
l0jec has a spectacular aura aboutl0jec has a spectacular aura about
Re: [FTC]: Robot C

Quote:
Originally Posted by John_1102 View Post

#include "joystickdriver.c"

task main ()
{
while(true){
getJoystickSettings(joystick);
motor[motorD] = joystick.joy1_y1;
motor[motorE] = joystick.joy1_y2;
}
}
Don't forget to loop!
Reply With Quote
  #15   Spotlight this post!  
Unread 10-11-2009, 20:21
alphadog0309's Avatar
alphadog0309 alphadog0309 is offline
Registered User
AKA: Karan Hiremath
FTC #0110 (MFS Foxes)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Moorestown, New Jersey
Posts: 41
alphadog0309 will become famous soon enoughalphadog0309 will become famous soon enough
Re: [FTC]: Robot C

i dont know why but i was told and ive seen it done only this way in robotc but it think its supposed to be

if(joy1Btn(1) !=0)
{
action
}

don't know why i just do it like that...
Reply With Quote
Reply


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
[FTC]: Power Surge Robot Nitro-Guy FIRST Tech Challenge 7 21-05-2009 10:30
[FTC]: FTC Futures Forum at FTC World Championship gdo FIRST Tech Challenge 0 08-04-2009 18:46
[FTC]: FTC]: FTC Champ Tournament - Ontario (Scoring Breakdown) Mr. Lim FIRST Tech Challenge 2 03-03-2008 11:54
pic: FTC #3 robot design Techno-Turkey Extra Discussion 5 06-02-2008 08:07
[FTC]: [FTC]: Ontario Provincial FTC Start/End Times cbhl FIRST Tech Challenge 8 16-12-2007 13:37


All times are GMT -5. The time now is 13:05.

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