Re: Webots Array Passing Error in Java

"Mike Jost" <[email protected]> Sat, 21 Feb 2004 12:44:52 -0600
Newsgroups gmane.comp.cybernetics.webot.contest
Message-ID <000901c3f8aa$cada78b0$0300a8c0@mjmc>
donaldnairn2004 wrote:
> Hi all,
> 
> I think I've found a small bug in the webots interface, there seems to
> be a problem with the way Webots handles array passing, I have no idea
> of the root cause of
> the problem other than every method I personally have defined for my
> own robot which
> passes an array of ints, floats, etc has caused the following exception
> 
> An unexpected exception has been detected in native code outside the VM.
> Unexpected Signal : 11 occurred at PC=0x4CEE6933
> Function=servo_set_position+0x27
> Library=/home/s0094293/mlsc/prac1/webots/lib/libController.so
> 
> which is caused by the line of code
> 
> servo_set_position(joint[LEFT_SHOULDER_1],counter[0]);
> 
> Has anyone else encountered this problem and is there a soln to it
> other than not
> passing array as arguments in your own methods or doing :
> 
> int increment;
> servo_set_position(joint[LEFT_SHOULDER_1],increment);
> 
> with the code above

1) Possibly the joint[ ] array values have been corrupted and contain values other than the values returned by the robot_get_device( ) function.

2) Possibly the values in your counter[ ] array contains data such as Float.NaN, Float.POSTIVE_INFINITY, or Float.NEGATIVE_INFINITY which may cause Webots to throw an exception.

3) The servo_set_position(int, float)  function should be called with the second argument as a float value and not as an integer as shown in your code above.
The Java compiler should be reporting a warning that the argument types do not match.   

I use the following call to set the servo positions in my controller with no problems.
int i;
int[] joint;
float[] futurePosition;
for (i=0; i<21; i++) {
   servo_set_position( joint[i], futurePosition[i] );
}


Mike Jost,  (FreeTime)