Asked — Edited
Resolved Resolved by Rich!

Script Eval

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


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

#1  

For one thing Kangaroos are daunting at best... I have not had much luck with mine... So they are on the shelf for now. The script is generally good, but one thing right off the bat is you are going to need to use sendserial() commands instead of Forward() in order to control the sabertooth (and kangaroo) properly... Especially if you want to use the Kangaroo with the sabertooth. Sendserial gives you way better control over the sabertooth... And if you will be using a V4 and the 12V batteries to power it... It has a built in software command to check battery voltage (and cpu temperature too)...

PRO
Synthiam
#2  

@Richard, why would you suggeset SendSerial instead of Forward() if @mdeming1 is using the sabertooth movement panel?

#3  

I was never able to get the forward() command to work well (I actually posted my problem months ago and someone suggested sendserial instead)... I couldn't control the speed of my sabertooth (until I switched to send serial command). So with the Forward($speed,5000) command and the sabertooth Movement Panel I was unable to control speed... No matter what value I entered for $speed, the sabertooth always went full out or stop... I will concede however, that maybe I didn't have the sabertooth set up right way back then when I was first experimenting with ARC and the sabertooth... I have never looked back since sendserial works perfectly...

#4  

Ok, so I just tried it again... Same problem. Have the 2x12 sabertooth set up for serial (as per the dips)... added the sabertooth movement panel... Then added a script with forward($speed,3000) command... where $speed=50... the Sabertooth (motors) just ran full out.. I tried different values for $speed... The sabetooth still just runs full out. The Movement Panel does however work as expected....

#5  

Hi and thanks again. Richard, for grins can you try it on D0 with the Movement Panel and dips at 1,3,6 on if you haven't already? The other week I found that only D0 worked for me (I haven't tried the roo yet) Despite up to date firmware on my v3, my sabertooth controller didn't work right until I set it to D0. My motors aren't at home right now or I'd reconnect them to try myself. Any other suggestions regarding my initial queries?

United Kingdom
#6  

Quickly looking over the script;

The labels for script_1 and script_2 should be at the very end otherwise these will run when the script is first run regardless of the conditions. That said, I have now started to make sub code such as these bits as their own scripts and using ControlCommand to run them. This also means you can manually run the scripts or have other scripts start up the same sequence of commands without re-writing it in each script.

The return after the goto should be in the sub script not after the goto.

At the end of script 2 the code would continue after the EndIf not in the Else.

So something like this;


:loop
# Run every Saturday and Sunday
  IF($Dayname = Saturday AND $Daytimehour =8)
    Goto(script_1)
    WaitUntilTime(20,00)
    Goto(script_2)
  ElseIf($Dayname = Sunday And $Daytimehour =8)
    Set(D1, on)
    Goto(script_1)
    WaitUntilTime(20,00)
    Goto(script_2)
  Else
  Endif
#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)
Goto(loop)

Halt() # This will stop the script should it ever escape the loop for any reason, rather than running script_1's commands.
:script_1
# Script_1 commands
Return()

:script_2
#Script_2 commands
Return()

On Script_1, you don't need stop() between the forward() and left() or right() commands, just using left() or right() would change the direction. Unless you wanted a noticeable stop in the movement, if so you would need to add a sleep after the stop.

There may be other ways to write the script. What I do is list out the order of operation for the commands and then look at how to achieve each part. My latest Ping Roam script is split in to multiple scripts and uses the ControlCommand to start up each part when required. In the topic (which I'll link to when I get chance to find it) I posted a bunch of my notes on my first rough code too which may give an idea how I go about thinking how to do what, where, why and if there is anything that could be done differently or better.

Hope that helps.

#7  

I did use D0 as my port and as mentioned the Movement Panel works as expected. However, using the forward() command although it works, I can not control how fast the motors spin... So forward(50,3000) is the same as forward(200,3000)... Another reason I use sendserial instead is because not all motors put out the same power. More often than not one motor is stronger than the other which causes the robot to veer to either the right or left.... SendSerial allows you to fine tune each motor individually so you can compensate for any veer... So making the robot go straight more or less...

United Kingdom
#8  

You can change the forward and reverse speeds in the Sabertooth control panel by clicking on the gear icon. If the robot veers off to one direction you just need to reduce the full forward values to suit.

I'm not sure on the sabertooth speeds since I don't have one to play with.