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 Skills (view all robot skills)

Absolutely - here’s a clean ARC JavaScript version of your gripper routines, converted from the EZ-Script behavior you described.
A couple of important notes first:
Servo.setPosition()is used instead ofServo(...)ADC.waitForLower()is the direct equivalent ofADC_Wait(Adc#,lower,#)Servo.release()on that servo port1) Open/Close both grippers
2) Left gripper IR detect loop
This matches your old
Grip_detectLbehavior:3) Right gripper IR detect loop
4) Lever-switch stop routine
Your EZ-Script version is close, but in JavaScript you’ll want to poll the ADC values and then release the servo when the lever switch is triggered.
Assuming:
Combined example: gripper close until lever switch hits
If you want the servo to move closed until the switch is pressed, this is usually the best pattern:
Important correction about "stop"
In ARC, there isn’t really a generic
stop()for a servo the way EZ-Script may imply in some script patterns. For a servo, the usual way to stop holding position is:or
That turns off torque/holding for that servo.
ARC Script Skill setup tip
If you’re placing this in a Script Robot Skill, you can use the kebab menu on the Script skill and open Settings, then choose JavaScript, paste the script, and save it.
One thing I’d like to confirm
To make sure the conversion behaves exactly right, can you confirm these two details?
v25andv9definitely virtual servo ports from a servo plugin skill, or are those actual servo ports on the EZ-B?If you want, I can also rewrite this as a more complete single ARC JavaScript routine with:
openGrippers()closeGrippers()monitorGrippers()so it’s easier to reuse in your project.
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.
I'm liking what I see here. To answer some of your questions....
>> When the gripper begins to close onto the object, it should just stop, still being able to have a good grip on the object (not letting it fall out of the grip unless I want it to release the object) >> When the gripper servo begins to close on the object, I'm thinking the gripper servo should "move slow" (like half speed)
>> The 2 servo ports v9 and v25 are from the SSC32 I am using for all arm servos >> ADC1 is for Right Gripper IR detect >> ADC2 is for Left Gripper IR detect >> ADC6 is for Right Gripper Lever stop >> ADC7 is for Left Gripper Lever stop
Great - that helps a lot. Since v9 and v25 are SSC-32 virtual servo ports, the best approach is:
That means we should use
Servo.setSpeed()to slow the servo motion, and then leave torque/holding enabled.Servo.release()would let go, which you don’t want when the object is grabbed.Recommended ARC JavaScript version
Below is a clean version you can paste into a Script Robot Skill in JavaScript.
How I would improve this for your robot
For SSC-32 servos, the cleanest logic is:
The important part is step 4. We do not use
Servo.release()if the claw needs to keep gripping.One caution
This line:
is a simple way to re-command the current position, but depending on how the SSC-32 skill is configured, you may prefer to stop by simply breaking out of the loop and letting the servo keep the last commanded position. In many cases that is enough.
A cleaner version is:
and then just exit. If the servo and SSC-32 are already holding position, that may be all you need.
Even better version: separate functions per arm
If you want, I can turn this into a more organized script like:
openRightGripper()openLeftGripper()closeRightGripperOnIR()closeLeftGripperOnIR()monitorLeverStops()That would make the project easier to maintain.
ARC configuration note
Since this is the SSC-32 servo Controller skill, make sure:
SSC-32 skill manual for reference: https://synthiam.com/Support/Skills/Servo/SSC-32-Servo-Controller?id=16180
A question so I can tighten this up
Do you want:
If you want, I can give you the final polished ARC JavaScript in whichever style 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.