Pop.Pilot - hanback-docs/SerbotMiniDocs GitHub Wiki

Pop.Pilot is an easy and fast training library for robot control. This library can control the front wheels of two and four wheel drive vehicles with steering control.


Class Driver

  • Initialization

    Driver(bus, addr, freq) : Driver object.

        Params
            bus :
            addr :
            freq :

  • Methods

    whl(id, value) :

        Params
            id :
            value :

    setSpeed(speed) :

        Params
            speed :

    getSpeed() :

    stop() :

    setDirection(degree) :

        Params
            degree :

    setSteer(degree) :

        Params
            degree :

    move(degree=None, speed=None) :

        Params
            degree :
            speed :

    drive(steer=None, speed=None) :

        Params
            steer :
            speed :

    turnLeft() :

    turnRight() :

  • Example
from pop.Pilot import Driver

Class joystick

  • Initialization

    joystick(callback=None) : Joystick Object

        Params
            callback :

  • Methods

    show() : Display joystick.

  • Example
from pop.Pilot import joystick

Class SerBot

Class for easy control of AIoT SerBot Series.

  • Initialization

    SerBot(bus=None) : SerBot Object

        Params
            bus :

  • Variables

    steering : Steer the front wheel of the SerBot left or right. Specify a value between -1.

  • Methods

    correctError(value) :

        Params
            value :

    turnLeft() : Let the SerBot turn left in place.

    turnRight() : Let the SerBot turn right in place.

    setSpeed(speed) : Control SerBot speed.

        Params
            speed : Specify a value between 0 and 99.

    getSpeed() : Return current speed.

    stop() : Stop SerBot.

    forward(speed=None) : Let the SerBot move forward.

        Params
            speed : Specify a value between 0 and 99.

    backward(speed=None) : Let the SerBot move backward.

        Params
            speed : Specify a value between 0 and 99.

    move(degree, speed) : SerBot moves in the direction specified by degree.

        Params
            degree : Specify the direction of movement.
            speed : Specify a value between 0 and 99.

    joystick() : The SerBot is controlled using a virtual joystick.

    setSensorStatus(ultrasonic=1,axis9=1,euler=0,gravity=0,quat=0,battery=0) : Set broadcast sensor value. 1 means on. 0 means off.

        Params
            ultrasonic : Ultrasonic sensor value.
            axis9 : IMU sensor accel, magnetic, gyro value.
            euler : IMU sensor euler value.
            gravity : IMU sensor gravity value.
            quat : IMU sensor quat value.
            battery : Battery volt, NTC value.

    setUltrasonicEnable(sensor_id=0x07,time=0x00) : Enable ultrasonic value broadcast.

        Params
            sensor_id : set broadcast data. 1 means enable. 0 means disable.
                 0 bit : Rear ultrasonic data
                 1 bit : Left ultrasonic data
                 2 bit : Right ultrasonic data
            time : set broadcast interval time. broadcast only 1 time when time set 0. If the time value is set to a value other than 0, broadcast continuously in units of 100ms.

    setUltrasonicDisable() : Disable ultrasonic value broadcast.

    setIMUEnable(sensor_id=0x3F,time=0x00) : Enable IMU value broadcast.

        Params
            sensor_id : set broadcast data. 1 means enable. 0 means disable.
                 0 bit : calibrate data
                 1 bit : accel data
                 2 bit : magnetic data
                 3 bit : gyro data
                 4 bit : euler data
                 5 bit : gravity data
                 6 bit : quat data
            time : set broadcast interval time. broadcast only 1 time when time set 0. If the time value is set to a value other than 0, broadcast continuously in units of 100ms.

    setIMUDisable() : Disable IMU value broadcast.

    setBattEnable(time=0x00) : Enable battery volt, NTC value broadcast.

        Params
            time : set broadcast interval time. broadcast only 1 time when time set 0. If the time value is set to a value other than 0, broadcast continuously in units of 1 second.

    setBattDisable() : Disable battery volt, NTC value broadcast.

    setObstacleDistance(ultra_distance=20) : Set Obstacle Distance.

        Params
            ultra_distance : Range is 20 ~ 180. From 21, Obstacle function work.

    getEncoder() : Return Encoder value. [front, left, right]

    getUltrasonic() : Return Ultrasonic value. [rear, left, right]

    getAxis9() : Return the [accel, magnetic, gyro] value through the sensor mounted on the SerBot.

    getAccel(axis=None) : Return the accel value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getMagnetic(axis=None) : Return the magnetic value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getGyro(axis=None) : Return the gyro value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getEuler(axis=None) : Return the euler value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getGravity(axis=None) : Return the gravity value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getQuat(axis=None) : Return the quaternion value through the sensor mounted on the SerBot.

        Params
            axis : Enter 'w' or 'x' or 'y' or 'z' to return the gyro value of the axis. Return all if there is no input.

    getBattery() : Return battery [volt, NTC] value.

  • Example
from pop.Pilot import SerBot

Class Data_Collector

Image data collection class for machine learning.

  • Initialization

    Data_Collector(separator, camera=None, auto_ready=True, save_per_sec=5) : Data_Collector Object

        Params
            separator : Enter the purpose of data collection. 'Collision_Avoid' or 'Track_Follow'. In AIoT AutoCAR 3, 'Track_Follow_Turn' or 'Object_Follow' can be available.
            camera : Camera class to utilize camera images.
            auto_ready : Set whether to automatically configure a GUI screen to assist data collection.
            save_per_sec : Amount of data stored per second.

  • Methods

    show() : GUI display for data collection.

    ready() : Construct a GUI screen to assist data collection. It is configured according to Collision Avoid or Track Follow.

    save_as_joystick(value) : Save the image using the joystick. Only use for Track Follow.

        Params
            value : This is a list containing 'sep', 'x', 'y'.

    control_as_joystick(value) : Use the joystick to control the robot. Only use for Collision Avoid.

        Params
            value : This is a list containing 'sep', 'x', 'y'.

    save_blocked() : Save the block image file in the specified path. Only use for Collision Avoid. default save path "./collision_dataset/blocked".

    save_free() : Save the free image file in the specified path. Only use for Collision Avoid. default save path "./collision_dataset/free".

    save_snapshot(directory) : Save the image file in the specified path. Only use for Collision Avoid.

        Params
            directory : Path to save image file.

  • Example
from pop.Pilot import Data_Collector

Class Collision_Avoid

The Collision_Avoid is a convolutional neural network class for obstacle recognition.

  • Initialization

    Collision_Avoid(camera) : Collision_Avoid Object

        Params
            camera : Camera class to utilize camera images.

  • Methods

    load_datasets(path=dataset_path) : Load the previously collected dataset.

        Params
            path : Path of pre-collected dataset. default path "./collision_dataset"

    train(times=5, autosave=True) : Train through the loaded dataset.

        Params
            times : Learning count.
            autosave : Whether to automatically save after learning.

    load_model(path=MODEL_PATH) : Load the saved model.

        Params
            path : Path to model file.

    save_model(path=MODEL_PATH) : Save the model.

        Params
            path : Path to model file.

    show() : The camera screen and model prediction values are displayed on the screen.

    run(value=None, callback=None) : Output the predicted value of the model.

        Params
            value : Direct image data to be recognized. Used to recognize data other than the camera image currently assigned to the class.
            callback : Callback method to process by passing the result value.

  • Example
from pop.Pilot import Collision_Avoid

Class Object_Follow

The Object_Follow is a convolutional neural network class for optimal object recognition.

  • Initialization

    Object_Follow(camera, classes_path=None) : Object_Follow Object

        Params
            camera : Camera class to utilize camera images.
            classes_path :

  • Methods

    load_model(path=MODEL_PATH) : Load the saved model.

        Params
            path : Path to model file.

    show() : Whether the execution result is expressed as a graphic element.

    detect(image=None, index=None, threshold=0.3, show=True, callback=None) : Recognize objects with the loaded model.

        Params
            image : Direct image data to be recognized. Used to recognize data other than the camera image currently assigned to the class.
            index : You can specify which objects are recognized. If you do not enter an index, results are returned for all recognizable objects.
            threshold : Value that determines which index the detected object corresponds to.
            show : Whether the execution result is expressed as a graphic element.
            callback : Callback method to process by passing the result value.

  • Example
from pop.Pilot import Object_Follow

Class Track_Follow

The Track_Follow is a neural network class designed with a convolutional neural network for track recognition.

  • Initialization

    Track_Follow(camera) : Track_Follow Object

        Params
            camera : Camera class to utilize camera images.

  • Methods

    load_datasets(path=dataset_path) : Load the previously collected dataset.

        Params
            path : Path of pre-collected dataset. default path "./track_dataset".

    train(time=5, autosave=True) : Train through the loaded dataset.

        Params
            time : Learning count.
            autosave : Whether to automatically save after learning.

    Load_model(path=MODEL_PATH) : Load the saved model.

        Params
            path : Path to model file.

    save_model(path=MODEL_PATH) : Save the model.

        Params
            path : Path to model file.

    show() : The camera screen and model prediction values are displayed on the screen.

    run(value=None, callback=None) : Output the predicted value of the model.

        Params
            value : Direct image data to be recognized. Used to recognize data other than the camera image currently assigned to the class.
            callback : Callback method to process by passing the result value.

  • Example
from pop.Pilot import Track_Follow
⚠️ **GitHub.com Fallback** ⚠️