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

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

#9  

I know Rich... I have played with the Movement Panel and it works as expected (speed changes are no problem just using the movement panel)... Also I do completely understand the sabertooth serial ControlCommand set 1... 64 .... 127 (motor 1) and 128.... 192 ... 255 (motor 2). Changing these settings within the Movement Panel has the expected effect... What I am saying is that when I use the script command Forward($speed,500) and if the Movement Panel is set to default values ( which is full out), then I am unable to adjust the speed of the motors from within a script... So no matter what value $speed is set to, the motors just run full out... I can stop(), left(), right() and reverse() no problem... but only at full speed... So to summarize... In order to adjust speeds I have to manually go back to the Movement Panel and change the settings there... then the script commands (Forward, left, right etc) will run at the settings set in the Movement Panel only...

#10  

@RichardR

I was wondering if you might share with me the script that you use for the Sabertooth control using the SendSerial Commands. I would like to test it out and see which would work better for me.

Thanks

#11  

Man I wish I had my motors handy, should get them back today or tomorrow. I think I used that slider motor speed control when I rigged mine up briefly to compensate for the all out speed and I think it worked. I'm not clear on how built in functions like the controller interface and script functions are then all Combined to be a single program that runs automatically. Rich, thanks for the script pointers. I've read all of your tutorials and they've proven helpful. Richard R if I use the send serial with the kangaroo do I have to change my pin settings again? You had some you were trying in an earlier post. Is there a way to add the additional receive port for the ezb without having to buy a v4?

#12  

It's pretty simple... $mot1=127 #full forward $mot2=255 #full forward

SendSerial(D0,$mot1) #motor 1 SendSerial(D0,$mot2) #motor 2

So $mot1 can be any number between 1 and 127 .... 64 is stop ... below 64 is reverse, above 64 is forward for that motor So $mot2 can be any number between 128 and 255... 192 is stop... below 192 is reverse, above 192 is forward for that motor

If $mot1 or $mot2 are set to 0 then both motors stop...

United Kingdom
#13  

@Richard R, comments are made by using the # not the '

Also, SendSerial needs the baud rate, so should be SendSerial(Port, Baud, Data, Data, Data...) or in this case SendSerial(D0,38400,127).

Here's a quick example which also covers the correct use of goto, return and halt (2 birds with 1 stone and all)


# Quick movement example
Goto(MoveForward)
Sleep(5000)
Goto(TurnRight)
Sleep(2000)
Goto(MoveForward)
Sleep(5000)
Goto(TurnLeft)
Sleep(2000)
Goto(MoveReverse)
Sleep(5000)
Goto(Stop)

Halt()

:MoveForward
# Left motor forward
SendSerial(D0,38400,127)
# Right motor forward
SendSerial(D0,38400,255)
Return()

:MoveReverse
# Left motor reverse
SendSerial(D0,38400,1)
# Right motor forward
SendSerial(D0,38400,128)
Return()

:TurnRight
# Left motor forward
SendSerial(D0,38400,127)
# Right motor reverse
SendSerial(D0,38400,128)
Return()

:TurnLeft
# Left motor reverse
SendSerial(D0,38400,1)
# Right motor forward
SendSerial(D0,38400,255)
Return()

:Stop
# Both motors stop
SendSerial(D0,38400,0)
Return()

#14  

Ooops, Thanks Rich... I go back and forth all the time between ARC and my basic atom IDE software... Basic atom uses ' to comment out...

#15  

OK, fantastic. Let me change my movements to script and i'll repost for eval. Just to be clear though, now that I'm using the kangaroo can I keep the pins as they were for 38400 when using just the sabertooth (1,3,6) or does it need to be changed? ALso, I read in one of RichR's earlier threads the KRoo needed a sensor. I have the aforementioned 3d accelerometer attached physically to the ezb, should I connect this to the roo? Is it something that has to be separately programmed.

Thank you for your patience with my questions. Believe me I'm learning tons and reading and re-reading just about every forum post there has been. If I'm asking too much just let me know. I wish I hadn't have gotten delayed two years ago. Back then I totally agreed with DJ about the future of robotics and the robot rev. is going to burst into everyday consciousness any day now. Very exciting.

#16  

Well at the risk of sounding foolish. If I'm programming send serial with similar script to the above reference how/where do I indicate speed? For instance using an appended version of Rich's example:


Goto(MoveForward)
Sleep(5000)

:MoveForward
# Left motor forward
SendSerial(D0,38400,127)
# Right motor forward
SendSerial(D0,38400,255)
Return()

Would I do this?


Goto(MoveForward)
Goto(MoveForwardSpeed)
Goto(MoveForwardSpeedTime)
Sleep(5000)

:MoveForward
#Left motor forward
SendSerial(D0,38400,127
#Right Motor forward
SendSerial(D0,38400,255

:MoveForwardSpeed
#Left motor speed
SendSerial(DO,38400,50
#Right motor speed
SendSerial(D0,38400,198)

:MoveForwardTime
#not sure, maybe (5000)?

or, conversely Option 2:


#here just adding speed of 198 for 5 seconds
Goto(MoveForward,198,5000)
Sleep(5000)

:MoveForward
# Left motor forward
SendSerial(D0,38400,127)
# Right motor forward
SendSerial(D0,38400,255)
Return(

I understood the forward commands in my original example but am not sure if I can use the same speed/time variables in the sample send serial codes. Hope it makes sense.