Exemplo n.º 1
0
#!/usr/bin/env python

import sys, os, time, json

import picamera
from lib.utils import dbprint
from lib.camera import update_img

from lib.frobo_ng import frobo_ng

if __name__ == '__main__':

    clockwise = int(sys.argv[1])

    c = frobo_ng()
    c.debug = True

    with picamera.PiCamera() as camera:

        try:
            c.update_state()
            print 'BEFORE %s cm to %s' % (c.state['sonar'], c.heading())
            c.find_distance(1, clockwise=clockwise)
            print 'AFTER %s cm to %s' % (c.state['sonar'], c.heading())
            json.dump(c.dots, file('dots.json', 'w'), indent=2)
        finally:
            update_img(camera)
Exemplo n.º 2
0
from lib.utils import html_data_path
from lib.utils import dbprint
from lib.camera import update_img, FeatureProcess

from lib.frobo_ng import frobo_ng

if __name__ == '__main__':

	c = frobo_ng()
	#c.debug = True

	with picamera.PiCamera() as camera:

		fp = FeatureProcess(camera)
		try:
			update_img(camera, html_data_path('pic0.jpg'))
			c.turn(350)
			time.sleep(1)
			update_img(camera, 'images/pic1.jpg'))
			fp.percent()
			c.move_straight(fwd=True, max_steps=c.m2steps(0.5), max_secs=1)
			update_img(camera, html_data_path('pic2.jpg'))
			time.sleep(1)
			c.turn(90)
			time.sleep(1)
			c.move_straight(fwd=True, max_steps=c.m2steps(0.5), max_secs=1)
			update_img(camera, html_data_path('pic3.jpg'))
			time.sleep(1)
			c.turn(210)
			time.sleep(1)
			c.move_straight(fwd=True, max_steps=c.m2steps(0.5), max_secs=1)
Exemplo n.º 3
0
import sys, os, time, json

import picamera
from lib.utils import dbprint
from lib.camera import update_img

from lib.frobo_ng import frobo_ng

if __name__ == '__main__':

    c = frobo_ng()
    c.debug = True

    t = time.time()
    try:
        dbprint('BEFORE %d (%d:%d)' %
                (c.heading(), c.state['lcount'], c.state['rcount']))
        data = c.collect_turn_data(cnt=30)
        #		data = c.collect_turn_data(cnt=100, pwr=50, dT=1, clockwise=True)
        dbprint('AFTER %d (%d:%d)' %
                (c.heading(), c.state['lcount'], c.state['rcount']))
        c.wait_until_stop()
        json.dump(data, file('data.json', 'w'), indent=2)
    finally:
        c.cmd_mstop()
        update_img(picamera.PiCamera())
        dbprint('EVENTUALLY %d (%d:%d), dist:%g, dT:%d' %
                (c.heading(), c.state['lcount'], c.state['rcount'],
                 c.state['sonar'], time.time() - t))
Exemplo n.º 4
0
import sys, time, json
from lib.frobo_ng import frobo_ng
import picamera
from lib.camera import update_img
from lib.utils import dbprint

dist = float(sys.argv[1])

debug = False
c = frobo_ng(debug=debug)
cam = picamera.PiCamera()
try:
    azim = c.heading()
    dbprint('BEFORE %d (%d:%d)' % (azim, c.state['lcount'], c.state['rcount']))
    c.move_straight(fwd=True, max_steps=c.m2steps(dist), max_secs=1)
    dbprint('AFTER FWD %d (%d:%d)' %
            (c.heading(), c.state['lcount'], c.state['rcount']))
    update_img(cam)
    azim -= 180
    dbprint("Turning around to %d" % azim)
    c.turn(azim, err=5)
    dbprint('AFTER TURN %d (%d:%d)' %
            (c.heading(), c.state['lcount'], c.state['rcount']))

    json.dump(c.dots, file('dots.json', 'w'), indent=2)
finally:
    update_img(cam)
    c.update_state()
    dbprint('EVENTUALLY %d (%d:%d)' %
            (c.heading(), c.state['lcount'], c.state['rcount']))
Exemplo n.º 5
0
import picamera
from lib.utils import dbprint
from lib.camera import update_img

from lib.frobo_ng import frobo_ng

if __name__ == '__main__':

    right = int(sys.argv[1])

    c = frobo_ng()
    c.debug = True

    with picamera.PiCamera() as camera:
        h = c.heading()
        try:
            update_img(camera, 'pic0.jpg')
            c.turn((h + (1 if right else -1) * 90) % 360, err=10)
            c.move_straight(fwd=True, max_secs=20, max_steps=c.m2steps(0.5))
            update_img(camera, 'pic1.jpg')
            c.turn(h, err=5)
            json.dump(c.dots, file('dots.json', 'w'), indent=2)
        finally:
            c.cmd_mstop()
            c.update_state()
            update_img(camera)
            change = c.heading() - h
            dbprint('EVENTUALLY %d dist=%g, turn=%g' %
                    (c.heading(), c.state['sonar'], change))