Before to call an exorcist I will ask you :

I have sometime problems about no worky commands ( rest() moveTo() or autodetach if velocity =-1 )
Problems ocure often at startup.

This is the smallest thing I can use to isolate. When I launch rest() , slider in swing go to the asked position, but no action on servo or virtual servo. ( like the servo is disabled, but servo is electrised)
and if I move the slider a little degree, servo go to good position.

leftPort = "COM20"
varduinoleft = Runtime.start("varduinoleft","VirtualArduino")
varduinoleft.connect(leftPort)
i01 = Runtime.createAndStart("i01", "InMoov")
i01.startHead(leftPort)
i01.startVinMoov()
sleep(2)
i01.head.rothead.setRest(90)
i01.head.rothead.rest()

 

calamity

6 years 11 months ago

Just to be sure I understand the problem you are reporting. You see that happen in the vinMoov but that should not happen on the real inMoov

If it is the case, the reason lie in how the vinMoov get updated.

In the first place, I want the vinMoov to be a copy of the real inMoov so it imitate everything the real inmoov is doing.

When you ask a servo to move (servo.moveTo(), or use slider or a service that move the servo (IK)), the Servo service send the message to the Arduino service, who send it to the hardware (or virtual hardware) who will answer with a servoEvent (that said I move the servo to position x). The vinMoov catch up the servoEvent and use it to update the position.

In your script, the Servo get initialized in the startHead() method. who probably set the rest position and move to that position. Since that happen before the vinMoov initialisation, it wont catch that.

When you initialise the vinMoov. it still don't know where the servo position is, so it start at position 0.

When you call rest(). the servo is already in it's rest position and the message probably get discarted as some point as there is nothing to update. So there is no servoEvent sent to update the vinMoov.

If you use servo.moveTo(servo.getRest()+0.1) that will trigger a servoEvent and make vinMoov to get to the right position. I should probably add something similar in the vinMoov initialisation process.

 

I hope it help