Ejemplo n.º 1
0
# This uses boatd_client, a python library for interacting with boatd. For more
# information, see https://github.com/boatd/python-boatd
# Run with $ python basic_behaviour.py, after boatd is running

from boatd_client import Boat

boat = Boat()

for i in range(5):
    boat.heading
    boat.wind
    boat.position
    boat.rudder(0)
    boat.rudder(-1)
    boat.rudder(3)

    boat.sail(0)
Ejemplo n.º 2
0
import time
import boat_utils
from boatd_client import Boat

HEADING = 200
K_P = 1
K_I = 0.1

integrator = 0

boat = Boat()

while True:
    current_heading = boat.heading
    print 'heading:', current_heading, 'wanted:', HEADING,
    error = boat_utils.heading_error(current_heading, HEADING)
    integrator += error
    print 'error:', error, 'integrator:', integrator
    boat.rudder(-(K_P * error + K_I * integrator))
    time.sleep(0.5)
Ejemplo n.º 3
0
from __future__ import print_function
import time
import boat_utils
from boatd_client import Boat

HEADING = 0
K_P = 1
K_I = 0.1

integrator = 0

boat = Boat()

def get_rudder_position(heading, wanted_heading):
    current_heading = boat.heading
    print('PID heading:', current_heading, 'wanted:', HEADING, end='')
    error = boat_utils.heading_error(current_heading, HEADING)
    integrator += error
    print('error:', error, 'integrator:', integrator)
    boat.rudder( -(K_P * error + K_I * integrator))

waypoints = [(-12, 3443), (2, 334)]

for point in waypoints:
    while boat_utils.distance(boat.position, point) > 10:
        print('position:', boat.position,
            'distance to waypoint:', boat_utils.distance(boat.position, point),
            'bearing to waypoint:', boat_utils.heading(boat.position, point))

        boat.rudder(
            get_rudder_position(boat.heading,
Ejemplo n.º 4
0
import time
import boat_utils
from boatd_client import Boat

HEADING = 200
K_P = 1
K_I = 0.1

integrator = 0

boat = Boat()

while True:
    current_heading = boat.heading
    print 'heading:', current_heading, 'wanted:', HEADING,
    error = boat_utils.heading_error(current_heading, HEADING)
    integrator += error
    print  'error:', error, 'integrator:', integrator
    boat.rudder( -(K_P * error + K_I * integrator))
    time.sleep(0.5)