ExceptionInInitializerError after declaring more than one motor

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

john
New User
Posts: 8
Joined: Wed Jun 10, 2015 7:56 pm

ExceptionInInitializerError after declaring more than one motor

Postby john » Sat Aug 19, 2017 3:48 pm

Hi All,

I have bee getting an ExceptionInInitializerError which was Caused by: lejos.hardware.DeviceException: unable to open port, when declaring more than one motor... I have pinpointed this error to be coming from the following lines of code:

Code: Select all

EncoderMotor cam_motor = new UnregulatedMotor(MotorPort.D);


 wheel1 = WheeledChassis.modelWheel(Motor.B, 55.0).offset(-59.2565).gearRatio(2);
 wheel2 = WheeledChassis.modelWheel(Motor.C, 55.0).offset(59.2565).gearRatio(2);
 
chassis = new WheeledChassis(new Wheel[] { wheel1, wheel2 }, WheeledChassis.TYPE_DIFFERENTIAL);
      


When removing the line for declaring the unregulated cam_motor, the motors for the chassis are declared and initialised without any problems and vice versa, as if the program is not accepting more than two motors.. even though different motor ports are being used...

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: ExceptionInInitializerError after declaring more than one motor

Postby gloomyandy » Sat Aug 19, 2017 5:32 pm

Don't use Motor.B Motor.C that is really only there for compatibility with old code. Instead use new EV3LargeRegulatedMotor(MotorPort.B) etc...
leJOS news https://lejosnews.wordpress.com/

steveiswicked
Novice
Posts: 33
Joined: Sun Feb 06, 2011 11:22 pm
Contact:

Re: ExceptionInInitializerError after declaring more than one motor

Postby steveiswicked » Mon Nov 20, 2017 7:22 pm

Like
static EV3MediumRegulatedMotor tiltMot = new EV3MediumRegulatedMotor(MotorPort.B);

static Wheel leftWheel = WheeledChassis.modelWheel((new EV3LargeRegulatedMotor(MotorPort.D)), 36).offset(74).invert(true);
static Wheel rightWheel = WheeledChassis.modelWheel((new EV3LargeRegulatedMotor(MotorPort.C)), 36).offset(-74).invert(true);
static Chassis myChassis = new WheeledChassis( new Wheel[]{leftWheel, rightWheel}, WheeledChassis.TYPE_DIFFERENTIAL);
public static MovePilot pilot = new MovePilot(myChassis);


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest