Asked — Edited

Some Questions About Programing

Ok I have my chassis to my robot sort of up and running. It has 2 hb 25s. Every now and then one drops comm and i cant control it. I think it has to do with the jumper and the comm loss safety that they have.

Anyway I have ran it with the Movement Panel and modified servo panel. I have a ping plugged in also and played with it. I have a couple more pings that I am going to mount.

Sorry for this post being long winded

What I am aiming for is is roaming self avoiding type of thing.

I can see the programing broken up into small scripts and called as needed by a master script. That is how I program some of the robots and plc's I work with at work. Can this be done here or is it better to write a big script and use jump to label's instead?

Thanks for any advice and help as I go

Happy New Year


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

PRO
Synthiam
#1  

That's a difficult question to answer. There are reasons for both cases, large or separate scripts...

I honestly can't give you a definite answer because you'll be modifying the requirements as you progress. Start with a single script and see what happens :)

In many cases, the Ping Radar control will do a great job at self roaming.

#2  

I figured it was kind of opened ended to many was of answering type of question.

So I'll narrow it down a bit.

Can I call other scripts from another then return to the main script where I left?

#3  

I don't know if I can add to this discussion but this is a good question and something I need to also work at to understand aslo. As I stated before; I've never written scripts before a few months ago. I have several basic scripts already written and working nicely in my B9 Robot Control project (I have it in EZ-Cloud) but am still struggling with this issue. As of right now in my learning curve I've found it easier (probably due to my ignorance and lack of experance) to have smaller scripts calling a master scripts. Sometimes I'll call on stating a variable, sometimes just using a CommandControl command.

I even have two scripts called "Kill" and "Alive" that will call each other after a CC, Sleep and then Halt(). That way the each will always be running but not at the same time. What I wanted to do was have the first script standing by and monitoring an ADC port for a switch closure at start up. Once it sees the voltage change when the switch closes it will run a CommandControl for both a different script that will move a motor to a certin point and also a CC to call the second script that monitors the ADC of that same switch again. Now when this second script (It's now running and monitoring the same ADC port) sees the voltage change again it will move the motor back and reset the first script to monitor the ADC port, waiting for this switch to operate again.

Sorry, I hope you followed all that. In real life what I wanted to accomplish was to pull the Power Pack on B9 off the side of the robot, that would open a switch, the robot would grown, appear to go dead and bend over. When the Power Pack was replaced the same switch would be closed, B9 would appear to come back alive, say something and stand up straight. The two scripts mentioned above call several other scripts to do all this nicely and always stop themselves and reset the other.

With ALL that said I wish I knew how to condense all these different scripts into just a few or even one. I'm sure it can be done with the Label, Start, Goto, If and Else functions but I'm not really that good at script writing (yet hopefully). I guess this is the genies and marvel of ARC; it will let newbie like me fumble around and still let me make cool animation like this work.

Hopefully as time goes buy I'll be able to write better scripts that don't need several smaller scripts called to do what I want. Maybe then I'd know the answer to your (and my) question.

Again, sorry for the loooooong and rambling post. If interested here's my ARC project as it sits as of last night:

B9RobotControl.EZB

Have Fun, Dave Schulpius

#4  

@dschulpius How do you call other scripts in EZ-Script.

#5  

Go ahead and open my project in ARC I pointed to above and open the script labeled Kill by clicking on the Config button at the top of the control box. When inside you'll see this (hopefully):


#This script will bend the robot over
#when the power pack is pulled.

:Start
  $adcSpecified = 30

  $adcCurrent = GetADC(adc0)

   if ($adcCurrent < $adcSpecified)
   goto(Hipsdown)

goto(Start)

:Hipsdown
CC("Hips Down", ScriptStart)
Sleep(7000)
CC("Alive", ScriptStart) 
Halt()

In the Hipsdown section you see the statement:

CC("Hips Down", ScriptStart) . CC is short for ControlCommand, "Hips Down" is the name of the other script I have written that will move my motor to the proper spot and ScriptStart is the command to start that script. You can find these on the Script Help section next to where you write your script in the EZ Script window. :)

Sleep(7000) is the statement that pauses the script in MS so the actions before can complete before it moves on the next statement.

CC("Alive", ScriptStart) is the ControlCommand that starts the next script. In my case it's a script "Alive" that I want to monitor the same switch as was being watched that's attached to ACD0 in the Start loop. Again, ScriptStart is the command to start that script.

Halt() is the command to stop the script so it will be ready for the next call. Also it wont just hang there or loop depending how you close it out. If I place a Return there instead then the script would go back up to Start and just loop around till it gets a call. I think that's called polling. Problem is if the came actions will execute unless it's written differently using other functions like "Else" or "Else If".

#6  

Here's the other Script called "Alive that will be started and has the above script as one of it's calls to start. In effect what is happening here is each one called the other to start just before it Halts:


#This script will stand the robot up
#when the power pack is replaced.

:Start

  $adcSpecified = 160

  $adcCurrent = GetADC(adc0)

  if ($adcCurrent > $adcSpecified)
  goto(Hipsup)

goto(Start)

:Hipsup
CC("Hips Up", ScriptStart)
Sleep(7000)
CC("Kill", ScriptStart) 
Halt()

Again, I'm still learning so if I'm wrong about any of this I hope someone will step in and keep me honest.

#7  

Dang Dave again thank you for the help.

I like to use smaller scripts instead of one big one I find it easier to trouble shoot cause its down to one small file.

At least that is the way I program plc's at work so I am hoping it works this way here too. Maybe your right the better way will be with one script.