Re: Webots Array Passing Error in Java

"donaldnairn2004" <[email protected]> Mon, 23 Feb 2004 13:00:03 -0000
Newsgroups gmane.comp.cybernetics.webot.contest
Message-ID <[email protected]>
I know why this was caused and it was a hack around using the
shareware version
of webots, I have a Judoka0.java file I work from and another that I
copy stuff
to to upload onto the competition. The problem occurred where one of my
functions in another class (other than Judoka0.java or MyRobot.java)
called a
function MyRobot.myRobotFunction) when in fact this has never been
initialised
as it is the Judoka0.class file which initialised all the variables
(and servos
etc). Just have to be aware of this problem in future, it is difficult
to keep
the files consistent using this hack though, but fortunately it is not
a webots
bug, just my own ignorance.

Donald

--- In [email protected], Olivier Michel
<Olivier.Michel@c...> wrote:
> 
> > (snap)
> > > 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] );
> > }
> 
> As Mike mentioned, it is probably caused by a wrong argument passed to 
> servo_set_position. In such a case Webots shouldn't crash but rather 
> warn you about that wrong argument. I appreciate if you can provide me 
> with feedback about it so that I could eventually fix it in Webots.
> 
> -Olivier



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/webots-contest/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/