Skip to content

5. Classes description

chronis10 edited this page Aug 5, 2019 · 6 revisions

Classes description

Under Construction

5.0 Library initiation and exit

Used to import the classes for electronic parts control.

from proteas_lib import control

Used to import the classes for computer vision applications.

from proteas_lib import vision

Initiate the control classes, Should be used every time after the import of the control classes.

control.start_lib() 

Clean up the GPIO pin parameters, should me used every time in the end of the program.

control.clean()

5.1 motor()

That class used to control dc motor with PWM.

motor_a = control.motor(speed_pin,terma_pin,termb_pin) # User selected pins default frequency 10000 Hz and DC 70%
#or
motor_a = control.motor(speed_pin,terma_pin,termb_pin,freq=10000,dc=70) # User selected pins,frequency and DC
#functions
motor_a.move() # The motor moves forward by default
#or
motor_a.move(direction="reverse") # User selected direction "forward"/"reverse"
motor_a.stop() # Stops the rotation of the motor
motor_a.set_speed(speed=50) # Change the motor default speed 0-100%
motor_a.control_speed(speed=90) # Change dynamically the motor speed 0-100%

5.2 odometer()

That class used to take measurements from odometer sensors.

odometer_1 = control.odometer() # Deafult 20 lines sensor disc
#or
odometer_1 = control.odometer(sensor_disc=20) # User selected lines for sensor disc
#functions
odometer_1.get_state() # Returns realtime the state of the sensor, 0/1 or True/False
odometer_1.count_revolutions() # Used inside the while of for loop to count the revolutions of the wheel
odometer_1.get_steps() # Return the number of the steps(sensor disc activations)
odometer_1.get_revolutions() # Return the number of the revolutions of the wheel
odometer_1.get_distance(wheel_diameter=6.6,precision = 2)# Returns the distance traveled the robot in cm with default wheel diameter 6.6 cm and precision 2 for the value of the disatnce 
odometer_1.reset() # Reset the revolutions counter

5.3 ultrasonic_sensor()

That class used to measure distance using a ultrasonic sensor.

ultra_1 = control.ultrasonic_sensor() # Default echo pin 14 and trigger pin 15
#or
ultra_1 = control.ultrasonic_sensor(echo_pin=14,trig_pin=15) # User selected pins
#functions
ultra_1.get_distance() # Return distance in cm

5.4 obstacle()

5.5 button()

That class used for buttons with software pull down activated.

button_1() = control.button() # Default pin 18
#or
button_1() = control.button(pin = 18) # User selected pin
#functions
button_1.get_state() #Return the state of the pin, 0/1 or True/False

5.6 gen_input()

That class used for input eg. noise sensor, digital light sensor or every electronic circuit with digital output.

noise_1 = control.gen_input() # Default pin 4
#or
noise_1 = control.gen_input(pin=4) # User selected pin
#functions
noise_1.get_state() #Return the state of the pin, 0/1 or True/False

5.7 gen_output()

That class used for output eg. led (with proper resistor 330 ohms), relay shield or every electronic circuit with digital input.

led_1 = control.gen_output() # Default pin 5
#or
led_1 = control.gen_output(pin=5) # User selected pin
#functions
led_1.set_on() #Power on the pin
led_1.set_off() #Power off the pin

5.8 accelerometer()

That class used to receive measurements of acceleration and gyro from the MPU6050 sensor .

mpu = control.accelerometer.() # Deafault address 0x68
#or
mpu = control.accelerometer.(address=0x68) # User selected address
#functions
mpu.get_acceleration() # By default return 3 values x,y,z
#or 
mpu.get_acceleration(dimension = "all") # User select "all","x","y","z"

mpu.get_gyro() # By default return 3 values x,y,z
#or 
mpu.get_gyro(dimension = "all") # User select "all","x","y","z"

5.9 compass()

5.10 servo()

That class used to control servo motor.

servo_1 = control.servo(pin=24) # User selected pin
#functions
servo_1.set_angle(angle=25) # User selected andgle in degrees

5.11 screen()

That class used for Nokia 5110 screen control.

main_screen = control.screen() # Default pins SCLK = 21,DIN = 20,DC = 16,RST =7,CS = 12
#or
main_screen = control.screen(SCLK = 21,DIN = 20,DC = 16,RST =7,CS = 12) # User selected pins
#functions
main_screen.ip_screen() # Print on the screen the ip of the robot
main_screen.print_text(text_list) # Take as input a list of 5 strings eg. text_list=['one','two',..,'five'] and prints every element of the list in a row

5.12 arm_2dof()

5.13 PID()

5.14 data_loger()

5.15 timer()

5.16 aruco_find()

5.17 camera()

5.18 show_image()

5.19 face_detection()

5.20 robot_center()

5.21 robot_follow()

5.22 line_follower()

5.22 buzzer()

That function used to control a buzzer with PWM.

buz_1 = control.buzzer(pin=25) # User selected pin with default frequency 1500Hz and DC 50%
#or
buz_1 = control.buzzer(pin=25,freq=1500,dc=50) # User selected pin, frequency and DC
#functions
buz_1.beep() # Short tone
buz_1.timer(count=10) # User selected time to delay with one short tone per second

Clone this wiki locally