JBalancePI is a two-wheeled, self-balancing robot using Raspberry Pi 3 Model B with GPIO and I2C interfaces and Java 8. To control the robot's movement and balance, it uses three modules: a sensor that contains a three-axis gyroscope and an accelerometer (MPU-6050), a pulse width modulation (PWM) servo driver (PCA9685), and a motor driver (L298N). These modules create a feedback control loop that balances the robot and automatically corrects its position.
Balancing a robot is an example of the classic inverted pendulum problem, in which a large mass is placed at the end of a pole.
The robot is prevented from falling by giving acceleration to the wheels according to the robot's inclination from the vertical axis. If the robot tilts at an angle, then in the frame of the wheels, the center of mass of the robot will experience a pseudo force that will apply a torque opposite to the direction of tilt.
PC with Ubuntu 16.04 LTE
Oracle Java ME SDK 8.3 for Ubuntu LinuxNetBeans IDE 8.1 -- JDK 1.8Oracle Java ME SDK 8.3 Plugins for NetBeans 8.1Raspberry Pi 3 model B
Raspbian Jessie Kernel 4.4Oracle Java ME Embedded 8.3 for Raspberry Pi Model B (ARM11/Linux) Oracle Java ME 8.3 API
Device I/O API 1.1Access and ControlGeneral Purpose input Output (GPIO) -- jdk.dio.gpioInter-integrated circuit bus (I2C) -- jdk.dio.i2cbusSerial Peripheral interface bus (SPI) -- jdk.dio.spibusGeneric connection framework 1.8Oracle Java(TM) Platform Micro Edition SDK 8.3
java.util.loggingjava.nioNew API
com.jcruz.demos.gpio.driver.L298Device -- L298 Interface drivercom.jcruz.demos.i2c.GfxLibI2C -- Graphic OLED interfacecom.jcruz.demos.i2c.driver.MPU6050Device -- MPU6050 interface drivercom.jcruz.demos.log.LoggingHandler -- Log managercom.jcruz.demos.spi.driver.MCP3008Device -- MCP3008 interface driver