mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-06 12:09:32 +00:00
Final test version of play_animation.py
This commit is contained in:
@@ -13,19 +13,19 @@ USE_LEDS = True
|
||||
def takeoff(): #x, y, z
|
||||
if USE_LEDS:
|
||||
LedLib.wipe_to(0, 255, 0)
|
||||
FlightLib.takeoff()
|
||||
FlightLib.takeoff1()
|
||||
|
||||
|
||||
def land():
|
||||
if USE_LEDS:
|
||||
LedLib.blink(0, 255, 0)
|
||||
FlightLib.land()
|
||||
FlightLib.land1()
|
||||
if USE_LEDS:
|
||||
LedLib.off()
|
||||
|
||||
|
||||
def do_next_animation(current_frame):
|
||||
FlightLib.navto(current_frame['x'], current_frame['y'], current_frame['z'], speed=current_frame['speed'])
|
||||
def do_next_animation(current_frame, x0 = 0, y0 = 0):
|
||||
FlightLib.navto(current_frame['x']+x0, current_frame['y']+y0, current_frame['z'], yaw = 1.57)
|
||||
if USE_LEDS:
|
||||
LedLib.fill(current_frame['green'], current_frame['red'], current_frame['blue'])
|
||||
|
||||
@@ -36,8 +36,7 @@ def read_animation_file(filepath=animation_file_path):
|
||||
animation_file, delimiter=',', quotechar='|'
|
||||
)
|
||||
for row in csv_reader:
|
||||
frame_number, x, y, z, yaw, red, green, blue = row
|
||||
speed = FlightLib.get_distance()
|
||||
frame_number, x, y, z, speed, red, green, blue = row
|
||||
frames.append({
|
||||
'number': int(frame_number),
|
||||
'x': float(x),
|
||||
@@ -57,15 +56,17 @@ def get_frames():
|
||||
|
||||
if __name__ == '__main__':
|
||||
rospy.init_node('Animation_player', anonymous=True)
|
||||
LedLib.init_led()
|
||||
|
||||
if USE_LEDS:
|
||||
LedLib.init_led()
|
||||
X0 = 0.5
|
||||
Y0 = 1.0
|
||||
read_animation_file()
|
||||
rate = rospy.Rate(10)
|
||||
#first_frame = frames[0]
|
||||
#takeoff(round(float(first_frame['x']), 4), round(float(first_frame['y']), 4), round(float(first_frame['z']), 4))
|
||||
takeoff()
|
||||
FlightLib.reach(x=frames[0]['x'], y=frames[0]['y'], z=frames[0]['z'])
|
||||
#for frame in frames:
|
||||
# rate.sleep()
|
||||
# do_next_animation(frame)
|
||||
FlightLib.reach(x=frames[0]['x']+X0, y=frames[0]['y']+Y0, z=frames[0]['z'], yaw = 1.57)
|
||||
for frame in frames:
|
||||
rate.sleep()
|
||||
do_next_animation(frame, x0 = X0, y0 = Y0)
|
||||
land()
|
||||
Reference in New Issue
Block a user