コード例 #1
0
#!/usr/bin/python2
#
# Blink the lights connected to the RomiPi
# The neopixel should turn red, yellow, then red
from romipi_astar.romipi_driver import AStar
import time

led_delay_s = 2.0

romi = AStar()

# turn on red LED
romi.leds(True, False, False)
romi.pixels(250, 0, 0)
print("LED RED")
print("PIXEL RED")
time.sleep(led_delay_s)

# turn on yellow LED
romi.leds(False, True, False)
romi.pixels(0, 250, 0)
print("LED YELLOW")
print("PIXEL GREEN")
time.sleep(led_delay_s)

# turn on green LED
romi.leds(False, False, True)
romi.pixels(0, 0, 250)
print("LED GREEN")
print("PIXEL BLUE")
time.sleep(led_delay_s)
コード例 #2
0
print(args)

romi = AStar()


def monitor_pose():
    monitor_freq_hz = 2.0
    # move forward for two seconds
    i = 0
    while True:
        print("{:} : poses ->"
              " motor m/s {:}"
              " twist_tuple {:}".format(i / monitor_freq_hz,
                                        romi.read_pose_motors(),
                                        romi.read_pose_twist()))
        # print motor_speeds for two seconds
        i = i + 1
        time.sleep(1.0 / monitor_freq_hz)


romi.twist(args.twist_linear, args.twist_angular)

if args.twist_linear == 0.0 and args.twist_angular == 0.0:
    romi.pixels(0, 0, 255)
else:
    romi.pixels(0, 255, 0)

time.sleep(args.time)
romi.twist(0.0, 0.0)

print("all done.")
コード例 #3
0
ファイル: circle.py プロジェクト: limam1/CPE476
from romipi_astar.romipi_driver import AStar
import time

romi = AStar()
linear_ms = 0.0
rotate_rads = 0.0


def update_twist():
    """send twist to driver and change light color if moving"""
    if linear_ms == 0.0 and rotate_rads == 0.0:
        romi.pixels(0, 0, 100)
    else:
        romi.pixels(0, 100, 0)
    romi.twist(linear_ms, rotate_rads)


# all set up, now run the robot
t_end = time.time() + 900
t_end1 = time.time() + 1
while True:
    linear_ms = 0
    rotate_rads = .2
    update_twist()
    if t_end1 < time.time():
        break

# stop motors and shut down light
romi.twist(0.0, 0.0)
romi.pixels(0, 0, 0)
コード例 #4
0
#!/usr/bin/python2
# pixels_utility.py
#
# Manually control the Neopixel colors
# on the Romi
#
# Peter F. Klemperer
# September 26, 2018
from romipi_astar.romipi_driver import AStar
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('red', type=int, help='red (0-255) value of pixel')
parser.add_argument('green', type=int, help='green (0-255) value of pixel')
parser.add_argument('blue', type=int, help='blue (0-255) value of pixel')
args = parser.parse_args()
print(args)

romi = AStar()

# turn on pixel according to arguments
romi.pixels(args.red, args.green, args.blue)