Exemplo n.º 1
0
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)
Exemplo n.º 2
0
#!/usr/bin/python2
#
# Move the robot forwards and backwards
from romipi_astar.romipi_driver import AStar
import time

romi = AStar()

distance = 10.0
runtime = 15.0

romi.twist(2 * 3.14 * distance / runtime, 2 * 3.14 / runtime)
time.sleep(runtime)

romi.twist(0.0, 0.0)

print("all done.")
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.")
Exemplo n.º 4
0
def monitor_pose(duration_s):
    monitor_freq_hz = 2.0

    # move forward for two seconds
    for i in range(0, int(duration_s*monitor_freq_hz)):
        print("{:} twist {:}"
              " motor speed m/s {:}"
              " pose_twist {:}".format(
            i / monitor_freq_hz,
            romi.read_twist(),
            romi.read_pose_motors(),
            romi.read_pose_twist()))
        # print motor_speeds for two seconds
        time.sleep(1.0/monitor_freq_hz)

print("initializing...")
romi.pixels(0,0,255)

print("moving forwards...")
# twist format is forward vector, rotation vector
romi.twist(forward_speed_m_s, stop_speed_m_s)
romi.pixels(0,255,0)

# move forward for two seconds
monitor_pose(2.0)

print("stopping.")
romi.twist(stop_speed_m_s, stop_speed_m_s)
romi.pixels(0,0,255)

monitor_pose(10.0)
Exemplo n.º 5
0
# Move the robot forwards and backwards
from romipi_astar.romipi_driver import AStar
import time

motor_delay_s = 5.0
forward_speed_m_s = 0.25
stop_speed_m_s = 1.25
romi = AStar()

# int main()
# turn off all LEDs
romi.leds(False, False, False)
romi.pixels(0, 0, 0)
print("Displaying Circle Code")
var = input("Press s/S to stop and any key to continue: ")  #input
while var != "s" and var != "S":
    currentTime = time.time()
    nextTime = currentTime + motor_delay_s
    while currentTime < nextTime:  #loops for prev time delay
        romi.twist(forward_speed_m_s, stop_speed_m_s)  # makes a circle
        currentTime = time.time()
    romi.twist(0.0, 0.0)  # stop
    var = input("Press s/S to stop and any key to continue: ")  #input
Exemplo n.º 6
0
#!/usr/bin/python2
#
# Move the robot forwards and backwards
from romipi_astar.romipi_driver import AStar
import time

romi = AStar()

distance = 15
sides = 4
for j in range(sides):
    for i in range(distance):
        romi.twist(distance, 0.0)
        time.sleep(1.0)
        romi.twist(0.0, 3.14 / 2)
        time.sleep(1.0)

romi.twist(0.0, 0.0)

print("all done.")
Exemplo n.º 7
0
motor_delay_s = 2.2
forward_speed_m_s = 0.25
stop_speed_m_s = 0.0
romi = AStar()

# int main()
# turn off all LEDs
romi.leds(False, False, False)
romi.pixels(0, 0, 0)

print("Displaying Square Code")
var = input("Press s/S to stop and any key to continue: ")  #input
while var != "s" and var != "S":
    # twist format is forward vector, rotation vector
    # moves in square
    for i in range(4):
        currentTime = time.time()
        nextTime = currentTime + motor_delay_s  # next time
        while currentTime < nextTime:  # loops for prev time
            romi.twist(forward_speed_m_s, stop_speed_m_s)  #go forward
            currentTime = time.time()

        romi.twist(stop_speed_m_s, stop_speed_m_s)  # stop
        currentTime = time.time()
        nextTime = currentTime + (motor_delay_s / 2.0)
        while currentTime < nextTime:  # loops for prev time
            romi.twist(stop_speed_m_s, 3.14159265358979323846 / 2)  #turns
            currentTime = time.time()
        romi.twist(stop_speed_m_s, stop_speed_m_s)  # stop
    var = input("Press s/S to stop and any key to continue: ")  #input
Exemplo n.º 8
0
#!/usr/bin/python2
#
# Move the robot forwards and backwards
from romipi_astar.romipi_driver import AStar
import time

romi = AStar()
linear_ms = 0.1
rotate_rads = 0.5
count = 0
finalCount = 48000


print("initializing...")
#romi.pixels(0,0,255)

print("begin circle...")

while(True):
	romi.twist(linear_ms,rotate_rads)
	count += 1
	if (count == finalCount):
		break