Asked

Smooth Start Of The Servo Movements When Starting ARC

Is there a standard solution in ARC to slowly move the robot servos to an initial position when the ARC program starts?

Especially with larger robots, switching on puts a lot of dynamic load on the servos and puts a strain on the entire mechanics of the robot.

If there is no standard solution available, how could integrate a Python or a Java script to do this job?


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

PRO
Canada
#1  

To achieve a smooth start of the servo movements when your ARC project starts, you can create an initialization script that gradually moves the servos from their current positions to the desired initial positions. This can help prevent sudden jerks and reduce strain on the robot's mechanics.

While there isn't a built-in "smooth start" feature in ARC, you can use the scripting capabilities within ARC to create this behavior. You can use either EZ-Script or JavaScript within ARC to accomplish this task. Python can also be used, but Java is not supported in ARC.

Here's an example of how you can create a smooth servo initialization using EZ-Script:

  1. Open your ARC project and add a new "Script" skill to your project if you don't already have one.

  2. In the script skill, write a script that gradually moves each servo to the desired starting position. You can use the Servo and Sleep commands to create the gradual movement.

# Define your initial positions for each servo
$startingPositionServo1 = 90
$startingPositionServo2 = 90
# ... add more servos as needed

# Define the number of steps and delay between each step
$steps = 10
$delay = 50 # milliseconds

# Gradually move servo 1 to the starting position
$position = Servo.getPosition(D0)
repeat ($i, 0, $steps)
  $position = $position + (($startingPositionServo1 - $position) / ($steps - $i))
  Servo.setPosition(D0, $position)
  Sleep($delay)
endrepeat

# Gradually move servo 2 to the starting position
$position = Servo.getPosition(D1)
repeat ($i, 0, $steps)
  $position = $position + (($startingPositionServo2 - $position) / ($steps - $i))
  Servo.setPosition(D1, $position)
  Sleep($delay)
endrepeat

# ... repeat for additional servos
  1. Save the script and set it to run when the ARC project starts. You can do this by going to the "Project" tab, selecting "Settings," and then adding your script to the "Auto Execute" section.

This script will smoothly transition each servo from its current position to the defined starting position over the specified number of steps, with a delay between each step to slow down the movement.

If you prefer to use JavaScript within ARC, you can use the ARC.Scripting object to access servo functions and create a similar script.

Remember to replace D0, D1, etc., with the actual port numbers for your servos, and adjust the $startingPositionServo1, $startingPositionServo2, etc., to the positions you want as the starting points for your robot's servos.


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.
PRO
Synthiam
#2  

Without knowing the start position it’s impossible to transition from an unknown position. So, no.

PRO
Synthiam
#4  

One last thing: are you referring to the waveshare servos or PWM hobby servos? Pwm hobby servos can never start smoothly because they have no feedback for the position. However, the Waveshare or other smart servos can provide their input and accept acceleration/velocity values for smooth transitioning.

So, if your waveshare servos are indeed working, will they accept acceleration or velocity commands? If so, that will allow them to smoothly move into an init position - IF - their firmware supports the ability to transition from a non-holding position after startup. Because the torque is disabled, their firmware may not honor acceleration/velocity.

The only way to find out is by testing the acceleration/velocity value on startup BEFORE setting the servo position.

PRO
Germany
#5   — Edited

Yes, I am referring to the WaveShare servos. I am currently dealing with the problem as follows. (not really comfortable)

Start  init process: Robo, Controller  and Servos Power on -> Servos are torque free Start my own small independent Python routine to move the servos/robot to the defined init position, smoothly and very low speed.

COMx closed and servos remain energized and maintain their torque.

Start ARC and start an auto-position action in which the servos are synchronized exactly to the init position. From now on the Robo will be 100% controlled by ARC

End of the init process.  

Now I would like to be able to integrate the Python program into ARC and start it from there. There is also a WaveShare python library included.

At the moment I still lack the knowledge. I hope that ARC offers these freedoms

PRO
Synthiam
#6  

The knowledge can be learned:) here’s how you add python libraries to arc: synthiam.com/Support/python-api/add-custom-python-modules

Your solution works but it’s not a full clean integration. Id like to know what commands and protocol the wave share are using. Maybe I can modify the Feetech robot skill to the wave share protocol commands. I need to find time to do that cause we’ve mostly halted ARC development while working on the new arc-x

PRO
Germany
#7  

You are absolutely right! That's the reason why I'm not really happy with this solution yet.:(

I will continue to familiarize myself with ARC over the next few weeks. The focus is on integrating Python programs (my favorite language) and perhaps creating new skills.

It also still needs to be decided on which hardware ARC will be integrated into the Robo. Raspberry Pi 5 / Lattepanda Alpha or fully controlled externally via WiFi.

Everything probably has advantages and disadvantages.  As always in life;)

User-inserted image

User-inserted image

Thank you again for your support

PRO
Synthiam
#8   — Edited

That’s a really great robot! Thanks for sharing a pic. It also adds context to what you’re doing.

As for the onboard computer won’t matter which one you choose when the new arc-x is released (probably in March). Because the new Arcx runs on Linux, Windows, macOS, etc. and it’s web-based, no graphic GUI is rendering onboard, making it much faster. It's about ten times faster if the browser is on another computer. Especially when running Linux.

The only limitation to Linux is that not all robot skills and libraries are compatible. So, a few things differ because Linux doesn’t have the same support for features as Windows. That’s unfortunate, but what we have to deal with