RoboHappy
,
This is a Script Skill question - could you help convert some EZ-Script I used previously into a JavaScript (ARC Script) version?
Context: This is for a two-arm robot. Each arm uses an older VEX-style claw gripper driven by a servo. I have a small sharp IR detector near each gripper servo to start closing when an object is detected. That IR-based behavior already works. All sensors and servos are connected to an EZB (so ADC readings and servos are handled by the EZB).
Below are the EZ-Script routines I used in the past. I’d like a JavaScript equivalent for use in the ARC Script Robot Skill. The script names are included so you can match the functionality.
EZ-Script for opening/closing both grippers: "Open Grippers" Servo(V25,180) Servo(V9,180)
"Close Grippers" Servo(V25,1) Servo(V9,1)
Gripper IR detector scripts: Grip_detectL (the script name) :claw ADC_Wait(Adc2,lower, 35) servo(V25,30) #Return goto(claw)
Grip_detectR (the script name) :claw ADC_Wait(Adc1,lower, 35) servo(V9,30) #Return goto(claw)
New requirement (added hardware): For each gripper I added a small lever switch that should immediately stop the gripper servo when it contacts the object. This is the EZ-Script I started for the lever-switch stop (I think I’m missing a servo stop somewhere):
Gripper_Object_stop (the script name) :LeverSw #Object detect lever switches (2) $a=GetADC(ADC6) #Right hand lever switch if($a=0) SayEZB("Object now gripped") stop() endif $a=GetADC(ADC7) #Left hand lever switch if($a=0) SayEZB("Object now gripped") stop() endif goto(LeverSw)
Could you look at making a JavaScript version of all of this for use in the ARC Script robot skill (JavaScript)?
Related Hardware (view all EZB hardware)
Related Robot Skill (view all robot skills)

Perfect - that confirms your lever switches are active-low, so
0means pressed and255means idle. The only issue earlier was that the script was reading0immediately because the input check was too sensitive and both switches were already being interpreted as pressed at startup.What to change
You want the gripper to:
0So the key change is in the stop condition:
ADC.get(ADC6) == 0andADC.get(ADC7) == 0Cleaned-up JavaScript version
Try this version:
Important: you still need to call one of the functions
If you want both grippers monitored, you can start one script per arm, or combine them into one loop. For example, to run the right arm:
Or left arm:
Better combined version
If you want both arms monitored in one script, use this:
A small caution
Because your lever reads
255idle and0pressed, this logic is correct:That means "keep waiting until it becomes pressed."
Why I removed the earlier
rightStoppedlogicThat version was more complicated than needed for your use case. Since each gripper has its own IR sensor and its own lever stop, it’s cleaner to handle each arm independently.
One more recommendation
For "half speed,"
Servo.setSpeed(..., 10)is actually the slowest setting, not half speed. If you want something moderate, try:3for faster5for medium7for slower10for slowestSo I’d suggest starting with:
and adjust from there.
If you want, I can now give you:
Either way, I can format it exactly for ARC Script Robot Skill.
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
ok. I tried your revised script. But it again shows "Done" once I click start. Did I miss something again?
Below is how I "verbally" call the gripper commands and the scripts....
To note, my gripper closing speed is set to 10 because I want the slowest speed for now
Yes - you’re missing one important ARC JavaScript detail:
Startruns top-to-bottom onceIf your script only contains lines like:
then ARC runs them immediately and exits, so it shows Done. That’s normal.
If you want the Script skill to keep running and listen for IR/lever events, the script must contain a loop or call a function that loops.
Also: those quoted lines are not JavaScript commands
This part:
is just a string literal in JavaScript, not a command. So it does nothing except exist as text.
If you want "verbally called" commands, the usual ARC way is:
controlCommand()to trigger another skill script by nameCorrect pattern for your gripper scripts
Open both grippers
Close both grippers
Open left hand only
Open right hand only
If you want the IR + lever logic to stay active
Use a loop like this:
That script will not end immediately because it has a
while (true)loop.Best ARC setup recommendation
I’d suggest making separate scripts for:
Open GrippersClose GrippersGrip_detectLGrip_detectRGripper_Object_stopThen trigger them by name from another Script skill using
controlCommand()if needed.One more important clarification
Since you said
closeSpeed = 10is the slowest, that’s fine - but it’s important that you set speed before commanding the move:Quick question
Do you want me to write this as:
If you want, I can format the exact final ARC JavaScript for whichever layout you prefer.
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
All my verbal commands for the grippers; "grippers open" , "close grippers", "open left hand", "open Right hand" are located in the Speech Recognition skill of course.
Yes- I would like the separate skills written as you suggested, and as stated... >call the gripper command by voice (from speech rec) gripper starts opening, once open, IR sensor begins to work to find a object in its gripper area, once object detected, slowly close gripper until object contacts lever switch, at this point, gripper servo stops, still holding object, finally, robot simply waits for its next command
Sorry, I can't continue helping in this thread. It's grown long enough that my context window will require too much extra processing, which makes follow-ups unreliable and I can start making mistakes.
A couple of options:
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.