Variable servo speed

Hi,

Is there a way to modify the speed and acceleration of a link during a simulation? Such that a link can travel according to any given vt-diagram.

Currently i am only able to enter the maximum speed and acceleration inside of the link properties tab. also the function “servo.setMotionTime(x)” is not quite what i am looking for.

Can someone help mo?

Thom

Changing the speed/acceleration while the servo is moving probably does not work.
Other than that, I would imagine it is OK to change these values while the simulation is running.

Ah, okay. So there is no python function where i can increase or decrease the speed/acceleration. Are there any alternatives you know that I can try?

I would try setting the MaxAcceleration and MaxSpeed directly from vcDof.

The vcServoController just has the Speed property and setMotionTime method, but those are not too convenient in this case.

Hi Este,

I’m currently reviewing this project. I did not succeed at the time. However I want to give it another try.
I know that you can set the MaxAcceleration and MaxSpeed from vcDof. I struggle however with the exact syntaxes. For example, i want to change the max speed of joint “Bx”. “Bx” is the first joint in servoBl. Current script:

from vcScript import *
from vcDof import *

app = getApplication()
comp = getComponent()
servoBl = comp.findBehaviour(“ServoBlue”)
servoRd = comp.findBehaviour(“ServoRed”)

jointsBl = servoBl.Joints
Bx = jointsBl[0]
print Bx

def OnRun():
#Primary velocity and acceleration
servoBl.setJointTarget(0, 1200)
servoBl.move()

#Lower velocity and acceleration
Bx.Dof.MaxSpeed(100)

servoBl.setJointTarget(0, 2400)
servoBl.move()

With this script i seem to only acces the list of joints. And not the actual joints which i can manipulate using vcDof. Could you please help me?

I’ve added my current dummy model:
Stacker Unit.vcmx (135.5 KB)

Thanks in advanced,
TVM

MaxSpeed and MaxAcceleration are properties, so you don’t need to call them with (). You can just assign the value with =.

Example:

def OnRun():
  
  B1_joint = servoBl.getJoint(0)
  #Primary velocity and acceleration
  B1_joint.MaxSpeed = 800.0
  servoBl.setJointTarget(0, 1200)
  servoBl.move()
  
  #Lower velocity and acceleration
  B1_joint.MaxSpeed = 100.0
  #Bx.Dof.MaxSpeed(100)

  servoBl.setJointTarget(0, 2400)
  servoBl.move()

Thank you so much for the quick response Este. This has worked :+1:

Hi Este,

I have got a follow-up question regarding this topic:

Right now, I am unable to program more ‘complex’ vt-diagrams in the simulation.

The basis of this problem lies in the fact that the Python script has a chronological order. I can only enter a new speed when a line in the code is completed.
In other words: I can only change the speed and acceleration when the movement from A to B is complete (v=0).

The image below makes it clear how I deal with this right now: the blue graph is the desired outcome. I have simplified this graph (red) and adjusted the speeds and accelerations so that the times match.
In the red graph you can see that I can change the speed from v1 to v2. For this I first have to go to a situation where the object is stationary (for a fraction of a second). This gives a fine approximation of the sequence, but not exactly what I am looking for.

Is there possibly any other way I can let objects and joints move according this graph? That is to say that I can adjust the maximum speed and acceleration while the object or joint is still moving. I have a suspicion the “servo.move()” function is of no use here.

Your help would be much appreciated!

TvM

Hy,

you could write your values over time with vcServo.moveImmediate()!

Regards
Feature

Hi Captain,

That could be a really smart workaround to solve this problem. If the steps are small enough, it may result in a smooth motion. Thanks!

However this seems quite cumbersome to me. Would there not be not be some function or method where variable speed is a standard option?

TVM

Hy,

you’re welcome!

You may report your wish to VC-Support?

Regards
Feature

It depends on how precise you want.

  1. If you only care about the joint moves to s1 for t1 seconds, moves to s2 for t2 seconds, you can do something like this
servo.setJointTarget(0, s1)
servo.setMotionTime(t1)
servo.move()

servo.setJointTarget(0, s2)
servo.setMotionTime(t2)
servo.move()
  1. If you want really precise motion, you will need s-t diagram, get s* for every 0.025 seconds, then you will get exactly what you need.
def OnRun():
  sData = [0.0, 1.0, 3.0 ...]
  while True:
   for sIndex in range(len(sData)):
    sevo.moveImmediate(sData[sIndex])
    delay(0.025)
1 Like

Hi Captain,

Would it be an option to use consecutive (two-way) paths of which you manipulate the speeds?

A drawback would be that multiple similar paths are required when multiple components have to de/accelerate on the same path. But the implementation is possibly easier?

Kr,

Niels Visser

Hy,

could be worth a try if the target is a movement of an product or component.

Regards
Feature