Beta8397 / virtual_robot

A 2D robot simulator to help beginners learn Java programming for FTC Robotics
118 stars 182 forks source link

Exception in thread "Thread-5" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory when accesses Vitural bot in Opmode #29

Closed AJmods closed 4 years ago

AJmods commented 4 years ago

VirtualBot bot = getVirtualRobotController().getVirtualBotInstance(getVirtualRobotController().getCbxConfig().getValue()); bot.setPosition(10,10,0); When I run this code, I get the error in the title. I want to access the VirtualBot class of the current robot while running opmodes, but every attempt I try at this gets an error similar to the one in the title.

jkenney2 commented 4 years ago

I'm assuming that you have added a method called getCbxConfig to the VirtualRobotController class. I'm also wondering whether you have added a setPosition method to the VirtualBot class. The VirtualBot class for this 2D simulator (virtual_robot) does not have such a method. Or, are you instead trying to do this on the 3D Physics-based simulator (vr_physics)? The solution to this issue will depend on which simulator you are working with. Either way, note that getVirtualBotInstance does not return the current robot; it creates an entirely new robot configuration object, which is not the object being manipulated in your active op mode. The VirtualRobotController class has a private field called bot, which is the current robot. You could add a public methed, getBot, and access the bot as follows: getVirtualRobotController().getBot();

If you are using the 2D simulator, you'll want a setPosition method in VirtualBot that is synchronized.

If you are using the 3D simulator, you'll need to call the setPosition method via a call to Platform.runLater, so it will execute on the UI thread.

AJmods commented 4 years ago

Thanks, it is now working.