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

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

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.