
mdeming1

Ok, so I've finally found Rich's and others script examples and come to understand that the cloud has repositories but is only available through the ez-b gui. So, I've been doing some scripting, cutting and pasting. I need a little evaluation and assistance. First off. My goal is for the robot to wake up on specific days and times (that hopefully I can ultimately control from my house online calendar but for now using the script), send an ir signal, follow a path, send a few more signals and then return later, also not wake skynet.
So here is what I have so far. I connected a SMAKN 315Mhz Rf Transmitter and Receiver Link Kit (.Receiver module parameters: 1.Product Model: MX-05V 2.Operating voltage: DC5V 3.Quiescent Current: 4mA 4.Receiving frequency: 315MHz 5.Receiver sensitivity: -105DB 6.Size: 30 x 14 x 7mm .Technical parameters of the transmitter head 1.Product Model: MX-FS-03V 2.Launch distance : 20-200 meters (different voltage, different results) 3.Operating voltage: 3.5-12V 4.Dimensions: 19 x 19mm 5.Operating mode: AM 6.Transfer rate: 4KB / S 7.Transmitting power: 10mW 8.Transmitting frequency: 315MHz 9.Pinout from left ? right: (DATA; VCC; GND)
Main Code:
:script_1
:script_2
# Run every Saturday and Sunday
IF($Dayname = Saturday AND $Daytimehour =8)
Goto(script_1)
Return
WaitUntilTime(20,00)
Goto(script_2)
Return
ElseIf($Dayname = Sunday And $Daytimehour =8)
Set(D1, on)
Goto(script_1)
Return
WaitUntilTime(20,00)
Goto(script_2)
Return
Else
#not sure what to put after the bot returns to home at the end of script 2 to make it sleep until the next Sat/Sun
Sleep(1000)
Endif
Script 1
#send ir signal
$sendiropen = Set(D13, ON)
Sleep(5000)
Forward(25, 1000)
Stop()
Right(25,900)
#go outside
Forward(50,5000)
Stop()
#turn around, close door, then turn around again
Left(25,1800)
$sendirclose = Set(D13, OFF)
Left(25,1800)
#proceed
Forward(50,3000)
#ok so here I need to figure how to plot the path and avoid obstacles see below
#continue following path
#avoid obstacles
#sleep
I have a DE-ACCM3D buffered 3d accelerometer attached to analog, the ez-b ultrasonic sensor which I have script for but not sure where to integrate, I also have the wireless camera that came with the kit or some nice old school camcorder tech or some iphone cameras, finally, I have the roborealm avm software but I'm clueless on integration for my purpose at this juncture.
My two wheelchair motors powered by two 12v batteries in parrallel are connected to the sabertooth 5x25 motor controller with the kangaroo (not sure if this needs scripting). I don't want to run a third battery pack and I'm told that the 5v from sabertooth may not be enough? It seems to run ok but would you rec an additional piece of hardware for good voltage?
My other questions are: How is the script so far? How can I integrate the other functionalities? What hardware to I still need to get? What am I not thinking about?
I have access to lots of parts. one offtopic question I'm not clear on as well. Does battery monitor script for sla batteries need a piece of hardware to work or will it work just as a software function?
I hope that it's ok to ask these. I feel so close to getting her rolling with the shoulders I'm standing on here on the forum and I really appreciate it.
Matt
The speed of the sabertooth is set by the data.
0 is stop 1 is motor 1 full speed reverse 127 is motor 1 full speed forward 63 is halfway between so I assume it is motor 1 stop (or motor 1 very very slow) 128 is motor 2 full speed reverse 191 is halfway between so I assume it is motor 2 stop (or motor 2 very very slow) 255 is motor 2 full speed forward
So, for instance, to move forward at half speed you would need to change the code I wrote to this;
1 to 63 is motor 1 reverse speed with 1 being fastest and 63 being slowest 64 to 127 is motor 1 forward speed with 64 being slowest and 127 being fastest 128 to 191 is motor 2 reverse speed with 128 being fastest and 191 being slowest 192 to 255 is motor 2 forward speed with 192 being slowest and 255 being fastest 0 is stop both motors
In my movement example, the sleeps basically determine how long the robot moves for before changing direction/movement. The script sets the motors to move forwards, then the script waits 5000ms (5 seconds), the robot will remain moving forwards for this 5 seconds. The script then changes the direction, this makes the robot turn, the sleep waits for 2000ms (2 seconds) then moves forwards again.
Hopefully that makes sense?
However if you use a kangaroo the syntax is different as the kangaroo uses a feedback sensor (or a pot) to determine position.
And FYI, there is no such thing as too many questions. Ask away. We are here to help.
Thanks Rich. I feel like I'm so close and yet on so many things I'm clueless about the last few steps. I really wish the Forward programing would work with the sabertooth (and really the roo too)because it was very easy to understand. For instance, I've modified my original Script_1 with send serial commands and your modified code. I'm worried, however that when I want to turn the bot 90 degrees for instance, in the prior command structure of move forward I could put speed and 9 milliseconds and it was easy to understand. In the send serial commands I'm thinking if it turns right 9000 milliseconds it's going to turn in a circle for 9 seconds. Here is my modified script below for eval:
You will get there, we all have the Eureka moment where everything clicks in to place.
As for turning etc. the way I did it with Melvin was to time how long it takes him to turn 90 degrees in each direction (both directions are different for my setup) by setting him turning right and using a stopwatch (or stopwatch app on my phone) checked to see how long it took to move. Then I fine tuned this by tweaking the sleep in the "Turn 90 right" script. The same for left and for 180 degrees.
I did the same for his speed for moving, that way I could roughly move him half a meter or a meter based on the time it takes.
In the code example I posted personally I would split it to multiple scripts and name them "forwards", "reverse", "left", "right" and "stop". Just basically take the code between the :label and the Return() and paste it in to a new script in script manager. You can call these with ControlCommand() in any script or run them manually that way.
If you do this you could also run the "turn left", which will spin the robot anti-clockwise (counter clockwise if you're American...). Time to see how long it takes to turn 90 degrees (I did 3 or 4 tests to get an average), then run the stop script. Write another script for "turn 90 left" which would be something like
Do the same for right turning
Then, if needed, you can call on these 90 degree turning scripts to turn with another ControlCommand in any other scripts;
Notice I used ScriptStart and ScriptStartWait. There is a difference. ScriptStart runs the script without pausing the script that calls it. ScriptStartWait will pause the script which called it until the called script is finished, then it will automatically resume.
Hopefully all of that made sense.
Thanks Rich, i'll try to make the scripts. Take a look at my post about avm when you have a chance and weigh in.
Hi Rich, since my camera won't work I decided to work on some of the programming. Wish I hadn't taken a week because I've forgotten some things. I did learn to save my work after three instances of losing everything.
Here is my script 1 problem. No syntax errors but it always just stops at #8. I made the movements separate script commands like you suggested. I'll post them below as well. Why is it stopping? I know I have a lot of sleeps, I just want to be able to identify breaks in the program. I'm not even sure if these commands will work with the sabertooth and/or the kangaroo. It is somewhat frustrating because I feel I'm making mistakes that should be obvious but aren't.
script 1
turn right script
(move forward, left, stop etc. are similar separate scripts as suggested)
Matt
It's probably easier if you upload the project file, that way I can look at the whole project as there are some questions just from looking at the script which may be answered if I was to see the whole project (such as, why is there a return() on the third line, and dotted around throughout the script when there are no goto() commands?)
Save it to the cloud and make it public or attach it to a forum post and I'll gladly take a look when I get chance. If you want to keep it quiet my email address is in my user details.
Hi Rich I think that the few times I forgot to save the file after checking syntax my script got sloppy. I originally had Forward commands, then Goto commands, then I replaced all of those with command control and now my brain is fried and I probably need to start over. I appreciate your offer of assistance. Let me see how I can get my program a little easier to understand and i'll get back to you. My program is nearly to the point that your avatar is about to be relevant to my situation. warm regards Matt