0
Not a bug

SetDriveTransformToValue issue

VIZtech4 2 years ago in realvirtual.io Starter and Professional updated by Support 2 years ago 4

I have Rotation Drives on the pivots of a robot arm.

To set a 'pose' position I am using "SetDriveTransformToValue" with an angle parameter for each drive.

That part works, however when I then use "drive.CurrentPosition" it gives me the wrong answer and also the limits become in the wrong place.

I tried using "drive.Offset" and "drive.DriveReset" but these did nothing.

The drive transform in Unity Editor does show the correct angle, it's the CurrentPosition that seems to be the problem or it may be I am not using it correctly.

Answer

Answer
Under review

Hi, for setting a Drives position from external code you should just use Drive.CurrentPosition = NewPosition.

This will directly set the new position. You should use it in FixedUpdate and if you want to have a smooth movement you need to take care on your own about the interpolation. 

The methods you used are misleading (and even not used from our side) - we will delete the in one of the next releases.

Answer
Under review

Hi, for setting a Drives position from external code you should just use Drive.CurrentPosition = NewPosition.

This will directly set the new position. You should use it in FixedUpdate and if you want to have a smooth movement you need to take care on your own about the interpolation. 

The methods you used are misleading (and even not used from our side) - we will delete the in one of the next releases.

Okay.

1. I don't want interpolation, I just want the robot arm to instantly take up the new position.

2. I tried "Drive.CurrentPosition = NewPosition".in FixedUpdate and it worked

3. In FixedUpdate I used a bool so that "Drive.CurrentPosition = NewPosition" would execute just once but the robot arm immediately returned to it's original position.

4. I need to call it just once and then it should stay in the new position because I then need to move it using joystick input.

5. I can't find a way to do that.


Don't know why that happened - maybe another script is setting the position. But you can set your wished position permanently in the FixedUpdate and only change it when your bool is true. Do you want to move the axis itself or the toolcenterpoint. For the toolcenterpoint in cartesian coordinates you would need the inverse kinematic - don't know if you are using professional.