示例#1
0
#device = '/dev/tty.usbmodem1'
# Windows address
#device = 'COM3'

target_heading = 80  # random choice - will be changed after calibrating in pool
target_depth = 0.3  # not too deep for a tank test
forward_speed = 10  # not too fast for a tank test
side_speed = 10  # not too fast of a value

heading_time = 10  # max heading task time, seconds
depth_time = 10  # max depth task time, seconds
drive_time = 10  # max drive task time, seconds
total_time = 10

# setup devices
pn = PixhawkNode(device)

# uncomment to test the zed camera
# zn = ZedNode(device)

# create dictionary of nodes needed for this task
node_dict = {'pn': pn}

# uncomment to test the zed camera
# node_dict = {'pn':pn, 'zn':zn}

runnum = episode()
# try loop is used to ensure that communication with pixhawk is
# terminated.
try:
    # startup data stream
示例#2
0
from time import time
import numpy as np
import matplotlib.pyplot as plt
from serial import SerialException
from zoidberg import PixhawkNode, pause, episode

update_period = 0.05
# Mac OSX address
device = '/dev/tty.usbmodem1'
# Linux address
#device = '/dev/ttyACM0'
# Windows address
#device = 'COM3'

runnum = episode()
pn = PixhawkNode(device)
pn.isactive(True)
# try loop is used to ensure that communication with pixhawk is
# terminated.

try:
    # startup data stream
    pn.isactive(True)
    # change mode
    pn.change_mode('MANUAL')
    motor_out = []
    readtime = []

    total_time = 3  # total collection time, seconds
    run_start = time()
    loop_start = run_start
示例#3
0
from zoidberg import PixhawkNode, pause
from serial import SerialException
from time import time

update_period = 0.05
# Mac OSX address of pixhawk
#device = '/dev/tty.usbmodem1'
device = '/dev/ttyACM0'
pn = PixhawkNode(device)

# try loop is used to ensure that communication with pixhawk is
# terminated.
try:
    # startup data stream
    pn.isactive(True)
    while True:
        loop_start = time()
        pn.check_readings()
        print("Current heading: %.2f" % pn.heading)
        # sleep to maintain constant rate
        pause(loop_start, update_period)
except SerialException:
    print('Pixhawk is not connected to %s' % device)
finally:
    print('Shutting down communication with Pixhawk')
    pn.isactive(False)
示例#4
0
from time import time
import numpy as np
import matplotlib.pyplot as plt
from serial import SerialException
from zoidberg import PixhawkNode, pause, episode, actionperiod, main_loop, \
                     constant_r_task, constant_r_success

# Linux address
device = '/dev/ttyACM0'
# Mac OSX address
#device = '/dev/tty.usbmodem1'
# Windows address
#device = 'COM3'

runnum = episode()
pn = PixhawkNode(device)

total_time = 30  # total task time, seconds
target_heading = 80  # random choice
r_P = 3  # proportionality constant for heading correction
r_max = 70  # max rate of turn
r_tol = 5  # if we are within this number of degrees, we have succeeded

# create dictionary of nodes needed for this task
node_dict = {'pn': pn}

# try loop is used to ensure that communication with pixhawk is
# terminated.
try:
    # startup data stream
    pn.isactive(True)