moving a custom joint with constant speed

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

moving a custom joint with constant speed

Postby drozzel » Sun Feb 06, 2011 7:03 pm

Hi all,


I am currently working on a simulator for a servo based robot.
All parts of the robot are connected to each other with custom joints.

In the joint callback function I used the following code:

static void joint_callback(const NewtonUserJoint* me, dFloat timestep, int threadIndex){
dFloat errorAngle;
dFloat jointAngle;
dVector pin;
SServodata *data;
NewtonJoint* newJoint;

data = (SServodata *)CustomGetUserData (me);
jointAngle = HingeGetJointAngle(me);
newJoint = CustomGetNewtonJoint(me);
HingeGetPinAxis (me, &pin[0]);

errorAngle = jointAngle + ((data->angle*data->angle_sign)* PI/180.0f);
NewtonUserJointAddAngularRow (newJoint, errorAngle, &pin[0]);
}

Now I want to adapt this function so the joint goes from its current position to a new angle over a set period of time.
example: the angle of a leg joint is at 20°. The simulator gives the command to move from 20° to 60° in a timestamp of 1 second.

From those parameters I can calculated how many °/sec the speed of the servo(joint) has to be but I am not sure how I can get an acceleration from this to use in NewtonUserJointSetRowAcceleration.

Anybody has some ideas?

Thx in advance
drozzel
 
Posts: 6
Joined: Sat Jun 26, 2010 4:27 pm

Re: moving a custom joint with constant speed

Postby Julio Jerez » Sun Feb 06, 2011 7:15 pm

you need to set the acceleration on teh right side of teh joint such that is generate the desired velocity
basically, on the right size read the error velocity and if is diffrent than what you want, subtract from the desired velocity and divide by the timestep.
That usually does the trick.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: moving a custom joint with constant speed

Postby drozzel » Thu Feb 10, 2011 7:48 pm

Thx for the explanation.

That did the trick. I made a small movie to show the result. The only problem I still see is that at fast speeds the complete robot is lifted up from the ground a couple of millimeters when one of the legs hits the ground.

drozzel
 
Posts: 6
Joined: Sat Jun 26, 2010 4:27 pm

Re: moving a custom joint with constant speed

Postby Julio Jerez » Thu Feb 10, 2011 7:57 pm

wow, very impresive constraction. I was not expecting anyhtong this complicated for your first trial. Very very nice.

I edited your post to show the video instead for the Link.

I think you can solve the lifting of the ground by make a contact material between the legs geometry and the floor.
what you are seeing is that when the robot moves faster the leg hit the floor at higher speed than when is moveing slowlliy.
the default coeficiend of elaticity to something default is 0.6
so when the leg hit the ground with a not nelglegible velocity it will bound of with some notn zero velocity.

if you make the material and set elasticity to 0.1 or 0.0, that should fix the problem,
also you may increase the static and dynamic friction so that the robot has more traction.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron