Author |
Message |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Another Drive Code Question
Before I post this, I just want to say thanks to everyone that has helped out so far. Just so you know, the team that I joined did not have anyone that could program, and thus I decided that I would try it for them. So thank you for the help, I wouldn't been able to get this thing going without you. I have a few issues with my drive code during teleop. 1.) In order to stop the left side drive from going either forward or backwards (it do go both ways depending on the joystick), I have to bring the joystick back to the center and press down on the joystick. However, the code should recognize that the joystick value is between -15 and 15 and stop the robot from moving. (If I wrote the code correctly) 2.) The right side of the drive only recognizes forward movement. But it stops when the joystick is returned to it's central position. The shoulder and NXT motor work perfectly. Any help is greatly appreciated. Thanks so much! Tim
|
Sun Jan 23, 2011 11:41 am |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Another Drive Code Question
Ok, Not sure why when I make the code this it works: I thought this was telling it the same thing. If it's between -15 and 15 stop, if not follow the value of the joystick.
|
Sun Jan 23, 2011 12:04 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Another Drive Code Question
So now that I have all of the tele-op code working at it's most basic form for one of our robots, I have a question to do with this code.
How can I make the drive (left and right motors) be more of an exponential power curve? I has hoping that the first code would do it... by:
Joystick Value * Joystick Value / Variable (figured out the variable by simple math) and then assigning a number based on if the joystick was pushed forward or backwards.
|
Mon Jan 24, 2011 2:06 pm |
|
 |
alanlevezu
Rookie
Joined: Wed Feb 24, 2010 11:43 pm Posts: 34
|
 Re: Another Drive Code Question
Actually, I'm not sure I see where you set the value of the motor to zero if it's within the deadband? I would have thought you'd want something like: To make it more "exponential" you can experiment with math on the return value. We've tried a lot of different things and have yet to come up with a solution that all the drivers like!
|
Mon Jan 24, 2011 4:37 pm |
|
 |
dellestj
Rookie
Joined: Mon Jan 03, 2011 10:52 pm Posts: 22
|
 Re: Another Drive Code Question
Alan, You are completely right. I do in fact have that in my code already, I just never put up the finished portion of it. However, I find that if I want to make it an exponential equation (i.e. x^2/161.72) I run into it moving forward even when we want it to move backwards (because the square of a negative is positive). I guess my question is would this work: I think this would give it the appropriate exponential curve that I want with still having it have the appropriate sign. I'll try it, especially since it looks a lot better than my first try at it.
|
Mon Jan 24, 2011 4:59 pm |
|
 |
alanlevezu
Rookie
Joined: Wed Feb 24, 2010 11:43 pm Posts: 34
|
 Re: Another Drive Code Question
yes, that will work... but you might want to use the sgn() function... it returns a 1, 0, or -1 depending on the sign of the number... thus you could also use:
|
Tue Jan 25, 2011 5:04 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Another Drive Code Question
I'm afraid the "^" operator does not raise a number to a particular power. It's the "exclusive or" operator. Consider the code below: This produces the following result:  Not quite what you thought, I'm sure. Keep that in mind  More info on the XOR operator: [ LINK]. - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Wed Jan 26, 2011 3:28 am |
|
 |
alanlevezu
Rookie
Joined: Wed Feb 24, 2010 11:43 pm Posts: 34
|
 Re: Another Drive Code Question
oops... didn't realize that! Thanks Xander! Is there a raisetopower() type function somewhere then? (Also, in the RobotC helpfile documentation is the comment for the exp() function saying it's XOR or raise to power?)
|
Wed Jan 26, 2011 12:45 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Another Drive Code Question
No, there is not but it should be easy to implement yourself  As for the help file, I have no idea. - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Wed Jan 26, 2011 4:09 pm |
|
|