
Can anyone help with scripting? I need to be able to have the speed of the G-Bot be ramped up and down rather than full on/off or there is a serious risk it will topple.
Right now I have the sabertooth control set up as in the attached photo. I have joystick 1 of the joystick control controlling it but I only get full on or off or full clockwise or counterclockwise rotation. Also, the joystick is 90 degrees off what I'd like( '3 o'clock' = forward, '9 o'clock' = reverse, '12 o'clock' = clockwise in place, '6 o'clock' = counterclockwise in place - but I can live with that for now if I have too).
I've been reading and watching tutorials and it seems like the movement scripting control is designed to do this but the input lines are different between the movement script control and the sabertooth control(stop, forward, reverse, left right versus 'left forward', 'right forward', 'left turn left', 'right turn left', 'left turn right', 'right turn right', 'left reverse', 'right reverse') and I have no idea how to write a script command to appropriately include a variable to do what I'm trying to do (OMG, that high school curse had come true! It comes down to algebra! doesn't it? Oh noooo!)
Can anyone take mercy on us and our Halloween plans and suggest some script to try and tell me which lines should go where?
PLEASE, PLEASE, PLEASE?
Thank you, Gwen
@Richard, you haven't seen some of my scripts! Some are very bloated and clunky. I'll often rewrite them with simpler methods after I first write them and take a look at what's written (I kind of auto pilot when writing scripts). Just look at my PingRoam examples and even the topic where I posted my methods of improving it
Awesome guys! Thanks. I'll be working on this tonight and tomorrow. I'l post when I get it working.
Gwen, there is also a folder included in your ARC installation called "EXAMPLES".
Load ARC
Press the OPEN button from the project tab under FILE
Press the EXAMPLES button
Select either EZ-Script Examples or EZ-Script Function Syntax
EZ-Script Function Syntax: This is a folder with examples of every EZ-Script function. For example, if you search for the word repeat in this folder, you will find an example that shows how to use repeat
EZ-Script Examples: This is a folder with examples on how to write code to perform some things. As well as demonstrating some syntax, this folder is more "functional" examples than syntax examples.
Additionally, the EZ-Script Examples Lesson will be of use to you. Here is the link: https://synthiam.com/Tutorials/Lesson/22
Ok, I've been experimenting with trying to get my sabertooth to ramp up and down in speed with linited success. Here is the code I came up with that makes my robot slowly accelerat forward:
And here is the code that makes my robot slowly accelerate in reverse:
when I insert these sets of code into the movement script in the appropriate 'Forward' and Reverse' boxes, the robot gently accelerates forward and reverse when using the respective onscreen control buttons. but its difficult to control this way.
When I have the joystick control the movement script, the acceleration is nice but there is no way to decelerate. I have to reverse direction which if done from full speed is herky, jerky. There is no way to ramp down. and there is no stop when the joystick is in the middle. It stays on in either direction. The only thing i could think of was to enter a stop command in the stop line of the movement script control
That sure stops the robot. Stops dead from any speed when the joystick hits the middle... Not good.
I figure this is solvable but am pretty sure this would be complicated and way beyond my primitive scripting abilities at this point.
Any suggestions are welcome...
You could use scripting and take the joystick Y axis variable to determine the speed.
You'll need to do some calculations, and possibly throw an IF in there to avoid a sudden stop, something like;
However this would lose the ability to suddenly stop it if there is a problem, you would need to add an emergency stop command somewhere.
Also, you can greatly reduce the lines of code for ramping with a simple counter and repeat.
This
Becomes something like
@Rich is on the case! I was just starting to noodle through this. I think you also want to set some global varuables so each script knows what the last was doing. Ie, if you are ramping up forward, set a variable that says you are going forward, so when you center the joystick it starts ramping down from the current forward speed, and the opposite if you are ramping up backwards. Also your rampdown needs a variable that the forward and reverse can see so that you don't have to drop all the way to 0 before starting to move again (and then we need to also use those variables as interupts to stop the current script and take over with the new one so they aren't fighting each other). Not sure yet how this effects turns. I think your left and right need to know current speed and condition as well to know what speed settings to execute.
I think you may want more than one emergency stop button. One that ramps quickly (maybe just sets your speed increment variable higher) and one full stop. With something top heavy like a B9 I would be concerned that a full stop at full speed might tip over, but you still want the ability to full stop for emergencies since it is so heavy and those motors are so strong. Don't want to run over children/pets/etc.
Alan
OMG, this is going to take hours of experimentation.... Not sure if I'll have enough time before Halloween to get it done... stress.
I may just have to control the sabertooth with my Futaba R/C for now.
Shame...
Any scripting gurus want to write the code for me and help me work it out via Skype today?
I dont have a ton of $ but coud PayPal a small consulting fee ($50)...
When I get home I'll throw together a quick project which will demonstrate the whole joystick position to sabertooth speed control idea which you should be able to follow, understand and modify if necessary.
I don't have a sabertooth to test with but I'm confident that it'll work.
No consulting fee required, helping is it's own reward.