United Kingdom
Asked — Edited
Resolved Resolved by CochranRobotics!

Rgb Animator Help

Hi guys.

I have a quick question regarding the RGB animator config "Settings" menu. At the moment I have 4 animator actions and would like to know if I can asign a soundboard file to just one of these actions, and not have all four actions play the sound file on the "Positioner start script"?

Or is it a case of having 2 animator controls, one with sounds and one without?

Thanks in advance.

Steve.


ARC Pro

Upgrade to ARC Pro

Subscribe to ARC Pro, and your robot will become a canvas for your imagination, limited only by your creativity.

United Kingdom
#1  

1 quick additional question, what script command do I need to use to automaticly start an animation action after the EZ-B establishes a connection. I don't mean straight after connection (connection control config menu), I mean after the start up script has been run from the connection control.

I hope you can understand what I mean. If not, let me know. :)

#2  

in the connect box, click the gear. from there, you can use the 0-connection Established Cmd to set the script that would run when the connection establishes.

oops, didnt read the entire post. will re-read and then answer.

What I do is generate an init script that fires after the connection is established which then sets up everything to run as I need it to. In that script, I do things like set the movement action to stop, start monitoring power, set led's and start monitoring everything by calling a monitor script which is setup to loop.

United Kingdom
#3  

@d.cochran.

Thanks for your (edited) reply my friend.:P

I thought there might be a way so thanks for confirming. I haven't had much experience (or luck) with init scripts yet. Could you post a small example of one for me if you wouldn't mind?

Cheers, Steve. :)

PRO
Synthiam
#4  

Read this lesson, it'll help you:) https://synthiam.com/Tutorials/Lesson/23

Apply what you learn from that lesson to the Connection Control's Configuration Menu. And as @d.cochran said, you're code will go into the Connection Established

#5  

I haven't looked at these in a while but here is what I have on my project

Startup Script


#Starting variables
$x = 0
$lastDay = $day
$batteryLEDs = "BlinkLights"
$rsstext = ""
$QuestionAnswer = ""

#set decent voice
  ControlCommand("Speech Settings", SetVoice, "Microsoft Hazel Desktop")
  ControlCommand("Speech Settings", SetVoiceAge, "Teen")
  ControlCommand("Speech Settings", SetVoiceEmphasis, "Strong")

say("Monitoring battery power levels")
# battery monitor
ControlCommand("Script Manager", ScriptStart, "BatteryMonitor")
if ($batteryLEDs = "BlinkLights")
  say("There is an issue with the battery.  Please correct.")
  #Need to add stop once things ar connected and the bot can get readings.
elseif ($batteryLEDs = "LightsOff")
  say("Battery power is very low.  Please put in a new battery.")
  stop()
else
endif

say("Turn off some unused stuff for now")
  ControlCommand("Radar Scan", PauseOn)
  sleep(1000)
  ControlCommand("Light", PauseOn)
  sleep(1000)
  ControlCommand("RightEdge Detection", PauseOn)
  sleep(1000)
  ControlCommand("LeftEdgeDetection", PauseOn)
  sleep(1000)
  ControlCommand("Floor Map", PauseOn)
  sleep(1000)
  ControlCommand("Battery Cell 1", PauseOn)
  sleep(1000)
  ControlCommand("Compass", PauseOn)
  sleep(1000)
  ControlCommand("Battery Cell 2", PauseOn)
  sleep(1000)
  ControlCommand("Temp", PauseOn)
  

say("Starting systems monitors")
#Start monitoring
  sleep(1000)
  ControlCommand("Script Manager", ScriptStart, "MonitorTemps")
  sleep(1000)
  ControlCommand("Script Manager", ScriptStart, "MonitorLight")
  sleep(1000)
  ControlCommand("Script Manager", ScriptStart, "MonitorTilt")

#Play wakeup sound
  ControlCommand("Soundboard", Track_13)

say("Setting up camera")
  controlcommand("camera", cameraservotrackenable)
  sleep(1000)
  controlcommand("camera", cameramovementtrackdisable)
  sleep(1000)
  controlcommand("Camera", cameraview)
  sleep(1000)
  ControlCommand("Camera", CameraStop)

say("Starting personality script")
  #Start up the personality script
  sleep(1000)
  ControlCommand("Script Manager", ScriptStart, "Personality Generator")

say("Turning on Speech recognition")
  #Turn on speech recognition
  #controlCommand("Speech Recognition", PauseOff)

Here are the other scripts Battery Monitor - This script is from Rich and is old. I am replacing it with the abilities that the V4 has built into it already. I was using this when I was passing only 5 volts to the V4 but was using 7.4 volt batteries. Now I pass 7.4 volts to the V4 and regulate power after the V4.


# Read voltage level of 2S LiPo battery and report to software.
# Set variables
# Change $vundervoltage to the under voltage of your specific battery (leave at 3v if unsure)
# Change $vcritical to your lowest voltage you wish for the battery to get before human intervention
# Change $vmin to low level alert value
# Change $vmax to battery full charge
# Change $multiplyer if using voltage divider
# Factor is 5/255 for adc value conversion to volts
$vundervoltage = 3
$vcritical = 3.5
$vmin = 3.7
$vmax = 4.5
$multiplier = 2
$factor = 0.019607843
$batteryLEDs = "BlinkLights"
:ReadCells
# Get ADC values
$vc1 = GetADC(ADC0)
$vc2 = GetADC(ADC1)

# Convert values to voltage
$cell2 = $vc1 * $factor
$cell1 = $vc2 * $factor * $multiplier
$cell1 = $cell1 - $cell2
$batteryv = $cell1 + $cell2

# Check for errors on circuit
IF ($cell1 > $vmax or $cell2 > $vmax)
  Print("Battery Monitor Error")
  Print("Check Monitor Circuits")
  $batteryLEDs="BlinkLights"

  # Check for errors on battery connection
ELSEIF ($cell1 <= 0 or $cell2 <= 0)
  Print ("Battery Connection Error")
  Print("Check Battery Connection")
  #Lights off
  $batteryLEDs="LightsOff"
  
  # Check for under voltage
ELSEIF ($cell1 <= $vundervoltage or $cell2 <= $vundervoltage)
  Print ("Battery Under Voltage")
  Print("Check Or Replace Battery")
  $batteryLEDs="BlinkLights"

  # Check if at critical levels
  # Cell 1
ELSEIF ($cell1 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 1 Critical")
  # Shut down all power, switch to back up battery alarm?
  # Shutdown power script

  # Cell 2
ELSEIF ($cell2 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 2 Critical")
  # Shut down all power, switch to back up battery alarm?
  #Shutdown power script

#add code for led levels
ELSE 
  # Output voltages
  $cell1round = Round($cell1,2)
  $cell2round = Round($cell2,2)
  $totalround = Round($batteryv,2)
  Print("C1 " + $cell1round + "V")
  Print("C2 " + $cell2round + "V")
  Print("To " + $totalround + "V")
    IF ($totalround >= 9.0)
    #Light15LED
    $batteryLEDs="Light15LED"
    ELSEIF ($totalround >= 8.82)
    #Light14LED
    $batteryLEDs="Light14LED"
    ELSEIF ($totalround >= 8.69)
    #Light13LED
    $batteryLEDs="Light13LED"
    ELSEIF ($totalround >= 8.56)
    #Light12LED
    $batteryLEDs="Light12LED"
    ELSEIF ($totalround >= 8.43)
    #Light11LED
    $batteryLEDs="Light11LED"
    ELSEIF ($totalround >= 8.3)
    #Light10LED
    $batteryLEDs="Light10LED"
    ELSEIF ($totalround >= 8.17)
    #Light9LED
    $batteryLEDs="Light9LED"
    ELSEIF ($totalround >= 8.04)
    #Light8LED
    $batteryLEDs="Light8LED"
    ELSEIF ($totalround >= 7.91)
    #Light7LED
    $batteryLEDs="Light7LED"
    ELSEIF ($totalround >= 7.78)
    #Light6LED
    $batteryLEDs="Light6LED"
    ELSEIF ($totalround >= 7.64)
    #Light5LED
    $batteryLEDs="Light5LED"
    ELSEIF ($totalround >= 7.52)
    #Light4LED
    $batteryLEDs="Light4LED"
    ELSEIF ($totalround >= 7.39)
    #Light3LED
    $batteryLEDs="Light3LED"
    ELSEIF ($totalround >= 7.26)
    #Light2LED
    $batteryLEDs="Light2LED"
    ELSEIF ($totalround >= 7.13)
    #Light1LED
    $batteryLEDs="Light1LED"
    ELSEIF ($totalround >= 7.0)
    #Flash1LED
    $batteryLEDs="BlinkLights"
  ENDIF

ENDIF 
ControlCommand("Script Manager", ScriptStart, "SetPowerLED")
# Wait 5 seconds
Sleep(60000)
# Go back to the start
Goto(ReadCells)

Set LED's for power


$lightCommand = $batteryLEDs
IF($batteryLEDs = "BlinkLights")
Repeat($counter,0,10,1)
  set(d0,on)
  set(d1,on)
  set(d2,on)
  set(d3,on)
  saywait("There is an issue with the batteries")
  set(d0,off)
  set(d1,off)
  set(d2,off)
  set(d3,off)
EndRepeat

ELSEIF ($batteryLEDs = "Lights15LED")
set(d0,on)
set(d1,on)
set(d2,on)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights14LED")
set(d0,off)
set(d1,on)
set(d2,on)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights13LED")
set(d0,on)
set(d1,off)
set(d2,on)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights12LED")
set(d0,off)
set(d1,off)
set(d2,on)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights11LED")
set(d0,on)
set(d1,on)
set(d2,off)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights10LED")
set(d0,off)
set(d1,on)
set(d2,off)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights9LED")
set(d0,on)
set(d1,off)
set(d2,off)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights8LED")
set(d0,off)
set(d1,off)
set(d2,off)
set(d3,on)

ELSEIF ($batteryLEDs = "Lights7LED")
set(d0,on)
set(d1,on)
set(d2,on)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights6LED")
set(d0,off)
set(d1,on)
set(d2,on)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights5LED")
set(d0,on)
set(d1,off)
set(d2,on)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights4LED")
set(d0,off)
set(d1,off)
set(d2,on)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights3LED")
set(d0,on)
set(d1,on)
set(d2,off)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights2LED")
set(d0,off)
set(d1,on)
set(d2,off)
set(d3,off)

ELSEIF ($batteryLEDs = "Lights1LED")
set(d0,on)
set(d1,off)
set(d2,off)
set(d3,off)

ELSEIF ($batteryLEDs = "LightsOff")
set(d0,off)
set(d1,off)
set(d2,off)
set(d3,off)

ENDIF

Light monitor


:start
$dark = GetDigital(d23)
if ($dark > 0)
say("it sure is dark in here.")
endif
Sleep(60000)
goto(start)

tilt monitor


:start
#$tilted = GetDigital(d22)
$tilted = 0
if ($tilted > 0)
say("Please set me upright")
endif
Sleep(5000)
goto(start)

temp monitor


#float tempC;
#int reading;
#int tempPin = 0;
#void setup()
#{
#  Serial.begin(9600);
#  analogReference(INTERNAL);
#}
#void loop()
#{
#  reading = analogRead(tempPin);
#  tempC = reading / 9.31;
#  Serial.print("Temp:"); //Display the temperature on Serial monitor
#  Serial.print(tempC);
#  Serial.println("C");
#  delay(500);
#}

:Start
$tempC = GetADC(adc5) / 9.31
$tempF = ($tempC*9/5)+32
if ($tempF > 100)
ControlCommand("Soundboard", Track_12)
endif
Sleep(60000)
goto (Start)

Personality Generator


:GeneratePersonality
$personality = GetRandom(0,19)

If($personality = 0) 
 say("I want to dance")

ElseIf($personality = 1)
ControlCommand("Script Manager", ScriptStart, "TellMeAJoke")

ElseIf($personality = 2)
ControlCommand("Script Manager", ScriptStart, "SayRandomFact")

ElseIf($personality = 3)
  SAY("ask if anyone else is getting hungery")

ElseIf($personality = 4)
  SAY("Call Maples name and start autonimous movement")

ElseIf($personality = 5)
  SAY("make a huge expression then look down with your arms hung low.")

ElseIf($personality = 6)
  SAY("check the temp and if it is hot or cold, make a comment about it")

ElseIf($personality = 7)
  SAY("Act like you are reading")

ElseIf($personality = 8)
  SAY("look up and find someone, identify them, and ask how they are doing today.")

ElseIf($personality = 9)
  SAY("see if it dark and if so, see if it is after 9 PM. if so, ask if it is bedtime")

ElseIf($personality = 10)
  Say("Can I chase the ball?")
:ChaseBall
   WaitForChange($QuestionAnswer)
  if ($QuestionAnswer = "yes")
    ControlCommand("Script Manager", ScriptStart, "ChaseColor")
  Elseif ($QuestionAnswer = "no")
    SAY("look sad")
  else
    say("I did not hear you. Can I chase the ball?")
  endif
  If($QuestionAnswer = "")
    Goto(ChaseBall)
  endif
  $QuestionAnswer = ""

ElseIf($personality = 11)
say("Did you know it is ") 
ControlCommand("Script Manager", ScriptStart, "SayTime")

ElseIf($personality = 12)
  SAY("autonomous collision avoidance")

ElseIf($personality = 13)
  SAY("look mad and play mad sound")

ElseIf($personality = 14)
  SAY("sway from side to side and play song")

ElseIf($personality = 15)
  SAY("find someone and wave at them")

ElseIf($personality = 16)
  SAY("look sad and say eve")

ElseIf($personality = 17)
  SAY("scratch head - Thinking")

ElseIf($personality = 18)
  SAY("Raise arms and gears")
  SAY("Make yawn sound")

ElseIf($personality = 19)
  SAY("look up and find someone")
  ControlCommand("Script Manager", ScriptStart, "FollowMotion")
  ControlCommand("Soundboard", Track_4)
  ControlCommand("Script Manager", ScriptStart, "kiss")
  Left(255,1000)
  Right(255,1000)
else
endif
SleepRandom(60000,300000)
goto(GeneratePersonality)

Let me know if you have any questions.

Thanks David

United Kingdom
#6  

@DJ.

Thanks for your reply. I will have a look. I didn't think I could add a long running script in the connection config as it would block other commands from executing. I already have a connection script that runs for about 10 seconds, but what I want to add would run for a lot longer (blinking eye animation). I will check out the lesson though.
:)

@d.cochran.

Wow, didn't expect that much. Thanks very much for that. I will go through it and see if I can figure out what I need. ;)

#7  

ARC is multi-threaded. This allows multiple scripts to run at one time without affecting each other.

Also, I wanted to make sure you had enough to learn from. Each of these scripts either calls other scripts or movements. I dont have an example of calling the rgb component but it would be done the same way. Also, in ARC, when you are editing a script, you can use the Cheat Sheet tab which will allow you to add other scripts or actions that you have programmed to be called by your script by clicking on the command you want to add. You will see this done above through the use of the ControlCommand command.

PRO
Synthiam
#8  

Things like the Auto Position and RGB Animator are background threaded - this means once you ask them to start, they run the loop for ever. The script doesn't "wait" for the animation to run. The script will merely nudge the animator and say "hey, run" and the animator will run in the background for ever until told to stop.

Of course, it will only run for ever if the checkbox is set for "repeat" on Auto Position or RGB Animator

It isn't great practice to through loops and such in the connection control - that's too much overhead for the connection established feature. However, nudging another script to "start" with the ControlCommand() is safe.

Essentially, ControlCommand() is the same effect as a human pressing the buttons on the control that you are directing it too. As a human, you don't press a button, sit, stare and wait for it to finish... You move on to other things - and that's how the ControlCommand() was designed.

United Kingdom
#9  

I have used the control commands for a lot of my project, some of which are already being used in connection established command. If I can run my ControlCommand() "eyes" script straight from there then that's cool. But the reason why I ask is the message on the top of the event EZ script editor.

"You are editing an event with EZ-Script. While this code executes, it will block other events of this control from executing. Make sure you are not performing any time-consuming operations in this event code."

What u want to run will run for quite a while as I mentioned, is for a pair of eyes that will blink, roll ect on a loop, so I didnt think this was the right place to put this script.

I have already gone through the scripting lesson a while back and got a lot from it, but there are still some things I just can't get the hang of. confused

United Kingdom
#10  

Almost forgot. Can anyone help with the question in my first post? ;)

PRO
Synthiam
#11  

That's what we're doing:)

United Kingdom
#12  

Are we? confused I thought we were talking about starting a script after the connection status issue (post #2). The first post (post #1) was regarding RGB editor playing sounds on selected actions (unless I missed something).

PRO
Synthiam
#13  

Ah, well you have 2 ways to do it...

  1. As d.cochran was explaining... "Create a new script that will launch both the Audio and the RGB Animator"

-or-

  1. Have the RGB Animator trigger FROM the audio, not the other way around. Do that by pressing the EDIT button on the audio and adding a script positioned at the point in the audio
#14  

I have spent the day "repairing" the robots that my class uses. I am getting them back to 100% working order as after multiple classes with students working in teams, some of the servo motors have been stripped, and some of the parts have been moved from the left side to the right side of the robots and such. I have just finished putting JD back in working order and am looking at the RGB Animator right now. It is the first time that I have seen placing the script inside the Soundboard V4 control and it is really cool. I wish I had this for something I was doing a few months back. Nice addition DJ.

I would call your script from within the Soundboard V4. It is a very easy way to make the script start at a specific time in the song, or call one script and then another later. The script would be something like this.


ControlCommand("RGB Animator", AutoPositionAction, "banana")

This is added to the song in a location you specify by right mouse clicking in the sound section (black background with green line) and then selecting Add Script. In the Script section (bottom of the control) you can click the Edit Script button and put in the code above. It will call the Banana RGB Animation Action. Just replace Banana with the RGB sequence you want to use.

Now, in your startup script, when you are ready for the sound file to play, just add


ControlCommand("Soundboard v4", Track_0)

replacing Track_0 with the location of the track you want to play.

That should get you what you want. If you want multiple RGB Animations to run, just add those to the Soundboard V4 song where you want them to activate.

Let us know if you have any questions.

United Kingdom
#15  

Thanks for that guys. Those solutions worked great. The deeper I dive in to ARC, the more smiles it puts in my face. :):):)

Haven't had a look in regards to my second question about the auto script start after my connection script has run, but I will do shortly and hopefully figure it out.

Thanks again d.cochran and DJ for your help. :D

United Kingdom
#16  

@DJsures.

Just a quick update. Tried the RGB start ControlCommand() in the connection script, and works like a charm. Thanks once again for your assistance. Bit of a Homer Simpson moment for me as that was really easy to set up. eyeroll love the ControlCommand() option. Nice job.

Hey, K-9 2.0 will be up in the project showcase within a couple of weeks if your interested. I know your a Dr Who fan. Just need to do some finishing touches and knock up a video or 2 to show him off. cool cool cool . Can't wait to see what you and others will think of him.

#17  

@Steve G... Of course we're interested!... We wanna' see what the rookie can do...;)

United Kingdom
#18  

Wow. No pressure then lol. sick

PRO
Synthiam
#19  

Super excited to see a video of your k9. Im a serious doctor who fan!

User-inserted image

United Kingdom
#20  

Cool. The weeping angles. I'm 41 years old and they scare the heck out of me. But you gotta love them Darleks though. Seriously cool bad guys.

Don't remember the cool dude duck in DW though. Must of missed that episode. :P:P:P

User-inserted image

PRO
Synthiam
#21  

No spoilers but that Hollywood duck is the master in the latest season!

United Kingdom
#22  

:D:D You rotten spoilsport. Now you've ruined the surprise :D:D . I think he would be good at playing the part. Who knows what evil genius lurks behind them shades? eek

United Kingdom
#23  

@DJ.

I'm having an issue with RGB animator and sound files. Can you have a look post #6 here and suggest what the problem could be. Thanks.