[ODE] Yet another question about servo emulation

Shamyl Zakariya zakariya at earthlink.net
Sat May 24 13:06:02 2003


Wait, if a hinge has a built-in motor, can I just call :
		dJointSetHingeParam( _hinge, dParamFMax, _force );
		dJointSetHingeParam( _hinge, dParamVel, velocity );

to move it, like it were a motor? Also, the locking of the motor was 
the only thing keeping it from blowing up every time... whereas with 
the lock it "only" blows up now and then.

So... I'm going to give this a shot, sans motor. Treating the hinge as 
a motor and I'll see how it works.

Thanks, but I may very well be calling back in a little while!

On Saturday, May 24, 2003, at 07:59  AM, Nate W wrote:

> On Sat, 24 May 2003, Shamyl Zakariya wrote:
>
>> In my project, I need to model servo behavior, such that I can say in
>> my code, more or less something like this:
>> 	someServo->setPosition( angle )
>>
>> I gather several people have need for similar functionality.
>
> Juice certainly has that sort of thing.  But, I use the motor built 
> into
> the hinge joint itself, rather than an AMotor.  This probably doesn't 
> make
> much difference at run time, but it makes for slightly simpler code.
>
> As for the odd behavior you're seeing, my guess is that it stems from 
> your
> use of dInifinty for FMax.  Try this:
>
> void ServoMotor::step( void )
> {
>  	dReal da = _desired - getCurrentPosition(); //magnitude and direction
>
> 	dReal velocity = da * _speed;
>
> 	if (_verbose)
> 	{
> 		printf("ServoMotor::step()\tda: %.2f, velocity: %.2f\n", da, 
> velocity);
> 		dumpState();
> 	}
> 		
> 	dJointSetAMotorParam( _motor, dParamFMax, _force );
> 	dJointSetAMotorParam( _motor, dParamVel, velocity );
> }
>
> I don't think there's anything to be gained from the code you're using 
> to
> treat holding center as a special case.  It might even be the cause of 
> the
> instability you're seeing.
>
>> I'd really appreciate it if somebody here can point out what's wrong
>> with my code. Perhaps there's a logical error in the feedback loop?
>> perhaps I'm not fully understanding the dynamics of the way motors
>> work, or how to use ERP or CFM adjustments.
>
> I generally start by setting ERP to 1.0, and CFM to 0.0001.  If I get a
> lot of explosions, CFM = CFM * 10.  If I get no explosions, CFM = CFM /
> 10.  A value of 0.1 will be very stable, but also quite squishy, like 
> the
> bodies are made of rubber.  A value of 0.0000001 will be very rigid, 
> but
> prone to oscillations or explosions.  In between those extremes it's
> usually easy to find a setting that's reasonably stiff and reasonably
> stable; I just tweak CFM using those rules and usually get something 
> good
> after just a few iterations.
>
>> Also, one more thing -- if anybody can give me some notion of how to
>> get the torque force a joint/motor is experiencing while holding
>> position I'd also appreciate it. I gather the function
>> dJointGetFeedback() is the way to go, but I haven't tried it yet. And
>> I'm sufficiently new to this API that I'm uncertain about how to go
>> about doing this correctly.
>
> I think you're probably right, but I haven't messed with it either. :-)
>
> -- 
>
> Nate Waddoups
> Redmond WA USA
> http://www.natew.com
>
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>
>
Shamyl Zakariya
   "this is, after all, one of those movies where people spend a great
   deal of time looking at things and pointing."
	From a review of _Fantastic Voyage_