コード例 #1
0
def main():
    """Process all events forever."""

    # ####################################################################
    # Load the configuration
    #
    dir_path = os.path.dirname(os.path.realpath(__file__))

    with open(os.path.join(dir_path, "config.yml"), 'r') as ymlfile:
        cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)

    # ####################################################################
    # Create the API client

    client = deepracer_vehicle_api.Client(cfg['password'], cfg['ip'])
    client.set_manual_mode()
    client.start_car()
    t1 = threading.Thread(target=event_loop, name='t1')
    t1.start()
    max_speed = -0.75
    global done, drive, steer, stop
    while not done:
        if drive < 0 and drive < max_speed:
            drive = max_speed
        elif drive > max_speed * -1:
            drive = max_speed * -1
        client.move(steer, drive)
        print("Steering command: " + str(steer) + " Throttle command: " +
              str(drive))
        last_drive = drive
        last_steer = steer
        # time.sleep(0.1)

        if stop:
            client.stop_car()
            print("Emergency stop")
            time.sleep(2)
            print("Start the car")
            client.start_car()
            stop = False

    client.stop_car()
    t1.join()
コード例 #2
0
import os 
import yaml
import time
import deepracer_vehicle_api

# ####################################################################
# Load the configuration
#
dir_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(dir_path,"config.yml"), 'r') as ymlfile:
    cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)

# ####################################################################
# Create the API client and login

client = deepracer_vehicle_api.Client(cfg['password'], cfg['ip'])

# ####################################################################
# 
print(client.set_calibration_mode())

print(client.set_calibration_throttle(cfg["calibration"]["throttle"]))
print(client.set_calibration_angle(cfg["calibration"]["angle"]))

print("Throttle", client.get_calibration_throttle())
print("Angle", client.get_calibration_angle())