![]() |
[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??
|
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. |
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/ |
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?
|
Re: [FTC]: Robot C
I might be able to answer both of your questions:rolleyes:
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 == :ahh: ) { motor[motorD] = 100; motor[motorE] = 100; } I am still a little rusty from last year these might not work....:D |
Re: [FTC]: Robot C
Quote:
if(joy1Btn(1) == 1) { code here } this will make it so execute code when button 1 on joystick 1 is pressed. |
Re: [FTC]: Robot C
Quote:
|
Re: [FTC]: Robot C
Quote:
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. |
Re: [FTC]: Robot C
Quote:
LAWL I installed Windows 7 on our robotics laptop and all the software still works because it was compatible with Vista. |
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 functionJust 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-axisl0jec |
Re: [FTC]: Robot C
Quote:
|
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 |
Re: [FTC]: Robot C
here you go :D
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; } } |
Re: [FTC]: Robot C
Quote:
|
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... |
Re: [FTC]: Robot C
Quote:
|
Re: [FTC]: Robot C
Quote:
{ code for what you want to happen here } else { code to make that stop happening } this is still as efficiant i tried it today. |
Re: [FTC]: Robot C
Quote:
You need to understand that a boolean true/false in ROBOTC is the same as 1 or 0 where 'true' is the same as '1' and 'false' is the same as '0'. Therefore the follow statements are all logically equivalent: Code:
if(value == true)So as long as the value variable in our example here is already a boolean, there is no need to explicitly check it for truth. That is there is no need to explicitly test if true is equal to true of if false is equal to false... just pass the boolean itself to the if() statement like: Code:
if(value)Well because those functions return a boolean. That means when you call the function you get back either a true or a false and there is no need to see if that is not equal to 0. Just test against the returned boolean like: Code:
if(joy1Btn(1))Hope this clears us some of the fog. ;) |
Re: [FTC]: Robot C
ahh i see... yeah that makes sense... i guess my brain is just wired in some screwed up way haha
|
Re: [FTC]: Robot C
Quote:
|
| All times are GMT -5. The time now is 13:05. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi