maarten-pennings / mpu6050 Goto Github PK
View Code? Open in Web Editor NEWArduino library for the MPU6050 accelerometer and gyroscope sensor with I2C interface
License: MIT License
Arduino library for the MPU6050 accelerometer and gyroscope sensor with I2C interface
License: MIT License
Hello i'm trying to use your code in python but the robot not going straight stable
moving left -> right -> left -> right ......etc
my code
import Motion
from motors import Motors
MOTOR_NOMINAL = 50
MOTOR_DELTAMAX = 50
MOTORS = None
def motor_forward(delta):
if delta > +MOTOR_DELTAMAX:
delta = +MOTOR_DELTAMAX
if delta < -MOTOR_DELTAMAX:
delta = -MOTOR_DELTAMAX
RIGHT_SPEED = MOTOR_NOMINAL-delta
LEFT_SPEED = MOTOR_NOMINAL+delta
#print(MOTOR_NOMINAL-delta)
#print(MOTOR_NOMINAL+delta)
# (right, right, left, left)
MOTORS.forword(RIGHT_SPEED,RIGHT_SPEED,LEFT_SPEED,LEFT_SPEED)
# PID ===================================================
PID_K_p = 30.0
PID_K_i = 0.2
PID_K_d = 1.0
i_input = float(0.0)
d_last = float(0.0)
def constrain(val, min_val, max_val):
return min(max_val, max(min_val, val))
def pid(error):
p_input = float(0.0)
d_input = float(0.0)
p_input = error
global i_input, d_last
i_input= constrain(i_input + error, -50, +50)
d_input = error-d_last
d_last = error
return p_input * PID_K_p + i_input * PID_K_i + d_input * PID_K_d
def motion_callback(current, tareget):
steer= pid( tareget - current )
#print("steer = %s" % steer)
motor_forward(steer)
def start(motors):
global MOTORS
MOTORS = motors
Motion.start(motion_callback)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.