Page 1 of 1

ExceptionInInitializerError after declaring more than one motor

Posted: Sat Aug 19, 2017 3:48 pm
by john
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...

Re: ExceptionInInitializerError after declaring more than one motor

Posted: Sat Aug 19, 2017 5:32 pm
by gloomyandy
Don't use Motor.B Motor.C that is really only there for compatibility with old code. Instead use new EV3LargeRegulatedMotor(MotorPort.B) etc...

Re: ExceptionInInitializerError after declaring more than one motor

Posted: Mon Nov 20, 2017 7:22 pm
by steveiswicked
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);