响应活动号召,参加一把S1的歌舞大赛......
首先,要强调一下的是:偶...不是一个程序猿!半个也算不上!!~~~虽然专业是软件工程,但写代码、编程序的这些个“饭碗”技能,这些年(掐指算来...十个手指头不够数,还得加十个脚趾头)... ...基本都还给老师啦!~~~
所以,各位看官嘴下留情,但凡看到什么可笑的、低级的代码表达,还请放过一马咯!~~~
年纪大了,废话比较多咯,进入正题吧,下面是参赛视频剪辑
***由于论坛设置等原因,原本程序内的部分代码给自动屏蔽叻!现已修正,早先复制/粘贴后,运行报错的,劳烦重新复制/粘贴一下咯!~~~ ^_^***
程序完整代码如下:
global k1,k2,k3
k1=[rm_define.media_sound_solmization_1C,
rm_define.media_sound_solmization_1D,
rm_define.media_sound_solmization_1E,
rm_define.media_sound_solmization_1F,
rm_define.media_sound_solmization_1G,
rm_define.media_sound_solmization_1A,
rm_define.media_sound_solmization_1B]
k2=[rm_define.media_sound_solmization_2C,
rm_define.media_sound_solmization_2D,
rm_define.media_sound_solmization_2E,
rm_define.media_sound_solmization_2F,
rm_define.media_sound_solmization_2G,
rm_define.media_sound_solmization_2A,
rm_define.media_sound_solmization_2B]
k3=[rm_define.media_sound_solmization_3C,
rm_define.media_sound_solmization_3D,
rm_define.media_sound_solmization_3E,
rm_define.media_sound_solmization_3F,
rm_define.media_sound_solmization_3G,
rm_define.media_sound_solmization_3A,
rm_define.media_sound_solmization_3B]
global ms
ms='E1C1D2626264E2G2E2G2E46272C2625854E2G2E262C4D2D2D2C2E4C468325262323252522214a402g1a11222325262323252521228041222325262323252522218\
04122232526232325252122804043432223222344442124252445452625252523228021212a234322232223444421242C2C2C27262540212625258626262C26252E8\
62526252G8515152E2C2C2C2C25254D2C272C27462525262E402A2A4G4C8515152E2C2C25254E4D8E1C1D2626264E2G2E2G2E4\
D2D1C1D2D1C1D2E25454E2G2E262C4D2D1C1D2D1C1E2C262C264E2G2E2G2E4G2G1E1G2G1E1G2E2C4G4A2G2G4E4G8E2C2C468025161C2C2C8025161C2E2E8\
025161C2C2C8E2C2C4683432223222344442124252445452625252523228021212a234322232223444421242C2C2C27262540212625258\
626262C26252E862526252G8515152E2C2C2C2C25254D2C272C27462525262E402A2A4G4C8515152E2C2C25254E4D8E1C1D2626264E2G2E2G2E4\
D2D1C1D2D1C1D2E25454E2G2E262C4D2D1C1D2D1C1E2C262C264E2G2E2G2E4G2G1E1G2G1E1G2E2C4G4A2G2G4E4G8E2C2C468025161C2C2C8025161C2E2E8\
025161C2C2C8E2C2C468' #cdefgab,CDEFGAB分别表示低音七个音阶和高音七个音阶
#芒种
ms1='54332116111112b2a212g402113154332116111112b2a212242111b1a1g2g1g1g2g1g1g2g1g1g2g1g12234122221212252361222g1g1a2b21211111202\
02111112120211111212f4a4162246221404f4a4164226a2g404f4a4162246221404f4a42413a1g4g3g1f404\
g4g3g11413412423g11404g4g3g11413412413a152423222C404e3g11212g3112222362111g6a1112612g611d1362111g6a1112622\
24a1b114a1b113b1a2b21411b11121g4b1a1g1f1e4g3g1a2g2a21224232124021131\
54332116111112b2a212g402113154332116111112b2a212242111b1a1g2g1g1g2g1g1g2g1g1g2g1g12234122221212252361222g1g1a2b21211111202' #cdefgab,CDEFGAB分别表示低音七个音阶和高音七个音阶
#分列式进行曲
import math
def start():
global k1,k2,k3
global ms
robot_ctrl.set_mode(rm_define.robot_mode_free)
v=0.5
low=['c','d','e','f','g','a','b'] #低音音符
high=['C','D','E','F','G','A','B'] #高音音符
m=[]
for i in ms:
if i in '0123456789': #0用来表示休止符
m.append([2,int(i)-1])
if i in 'cdefgab':
m.append([1,low.index(i)])
if i in 'CDEFGAB':
m.append([3,high.index(i)])
tools.timer_ctrl(rm_define.timer_start)
for i in range(len(m)):
if i%2==0:
if m[ i ][0]==2:
if m[ i ][1]>=0:
media_ctrl.play_sound(k2[m[ i ][1]])
if m[ i ][0]==1:
media_ctrl.play_sound(k1[m[ i ][1]])
if m[ i ][0]==3:
media_ctrl.play_sound(k3[m[ i ][1]])
else:
t0=tools.timer_current()
t=t0
while t<t0+(m[ i ][1]+1)*0.1:
t=tools.timer_current()
Bottom_Action(t,v) #底盘运动
Ledf(t)
chassis_ctrl.stop()
Salute()
def Bottom_Action(t,v):
t1=t+math.pi*2
cost=math.cos(t1/0.5) #1/2theta
cos05t=math.cos(t1) #1/2theta
x=v*cost #∞线 t1=t+math.pi*2 v=0.3--0.5
y=v*1.165*cos05t #∞线 t1=t+math.pi*2 v=0.3--0.5
chassis_ctrl.move_with_speed(x,y,0)
def Ledf(t):#炫彩走马灯
t=tools.timer_current()
t2=int(t*20)
i=t2%8+1
j=t2//8%256
w=255-(i*32+j)%256
if w<85:
[r,g,b]=[255-w*3,0,w*3]
else:
if w<170:
w-=85
[r,g,b]=[0,w*3,255-w*3]
else:
w-=170
[r,g,b]=[w*3,255-w*3,0]
led_ctrl.set_top_led(rm_define.armor_top_all,r,g,b,rm_define.effect_always_off)
k=(i+3)%8+1
led_ctrl.set_single_led(rm_define.armor_top_all,[i,k],rm_define.effect_always_on)
def Salute():
gimbal_ctrl.set_rotate_speed(540)
gimbal_ctrl.yaw_ctrl(-20)
time.sleep(0.2)
gimbal_ctrl.pitch_ctrl(35)
led_ctrl.gun_led_on()
time.sleep(1)
led_ctrl.gun_led_off()
gimbal_ctrl.yaw_ctrl(0)
gimbal_ctrl.pitch_ctrl(0)
time.sleep(1)
gimbal_ctrl.angle_ctrl(0,-20)
time.sleep(1.5)
gimbal_ctrl.recenter(0,0)
其中:
*底盘运动,炫彩走马灯都是借鉴论坛内“老妖怪”的方法,在此拜谢!~~~
**乐曲附送一首:分列式进行曲
***云台动作来不及加上了,后补吧!~~~~
****曲谱调用是做的列表嵌套,感谢全国3群里“AI道场”赵老师嘀帮助!拜谢!~~~~~
曲谱组成形式是奇数位为音符,偶数位为持续时长!~~~~
*****至于:x=v*cost 可以添加一个参数,用以调整∞符号的宽度,类似 x=v*1.2*cost
y=v*1.165*cos05t 同样可以添加一个参数,用以调整∞符号的整体长度,1.165是我自己场地大小调整的数字,看官可以根据自己的需求调整咯!~~~~
******v前添加(-)负号,y式可以改变运动的左、右方向,x式可以改变上、下方向!~~~~
…^_^...
首先,要强调一下的是:偶...不是一个程序猿!半个也算不上!!~~~虽然专业是软件工程,但写代码、编程序的这些个“饭碗”技能,这些年(掐指算来...十个手指头不够数,还得加十个脚趾头)... ...基本都还给老师啦!~~~
所以,各位看官嘴下留情,但凡看到什么可笑的、低级的代码表达,还请放过一马咯!~~~
年纪大了,废话比较多咯,进入正题吧,下面是参赛视频剪辑
***由于论坛设置等原因,原本程序内的部分代码给自动屏蔽叻!现已修正,早先复制/粘贴后,运行报错的,劳烦重新复制/粘贴一下咯!~~~ ^_^***
程序完整代码如下:
global k1,k2,k3
k1=[rm_define.media_sound_solmization_1C,
rm_define.media_sound_solmization_1D,
rm_define.media_sound_solmization_1E,
rm_define.media_sound_solmization_1F,
rm_define.media_sound_solmization_1G,
rm_define.media_sound_solmization_1A,
rm_define.media_sound_solmization_1B]
k2=[rm_define.media_sound_solmization_2C,
rm_define.media_sound_solmization_2D,
rm_define.media_sound_solmization_2E,
rm_define.media_sound_solmization_2F,
rm_define.media_sound_solmization_2G,
rm_define.media_sound_solmization_2A,
rm_define.media_sound_solmization_2B]
k3=[rm_define.media_sound_solmization_3C,
rm_define.media_sound_solmization_3D,
rm_define.media_sound_solmization_3E,
rm_define.media_sound_solmization_3F,
rm_define.media_sound_solmization_3G,
rm_define.media_sound_solmization_3A,
rm_define.media_sound_solmization_3B]
global ms
ms='E1C1D2626264E2G2E2G2E46272C2625854E2G2E262C4D2D2D2C2E4C468325262323252522214a402g1a11222325262323252521228041222325262323252522218\
04122232526232325252122804043432223222344442124252445452625252523228021212a234322232223444421242C2C2C27262540212625258626262C26252E8\
62526252G8515152E2C2C2C2C25254D2C272C27462525262E402A2A4G4C8515152E2C2C25254E4D8E1C1D2626264E2G2E2G2E4\
D2D1C1D2D1C1D2E25454E2G2E262C4D2D1C1D2D1C1E2C262C264E2G2E2G2E4G2G1E1G2G1E1G2E2C4G4A2G2G4E4G8E2C2C468025161C2C2C8025161C2E2E8\
025161C2C2C8E2C2C4683432223222344442124252445452625252523228021212a234322232223444421242C2C2C27262540212625258\
626262C26252E862526252G8515152E2C2C2C2C25254D2C272C27462525262E402A2A4G4C8515152E2C2C25254E4D8E1C1D2626264E2G2E2G2E4\
D2D1C1D2D1C1D2E25454E2G2E262C4D2D1C1D2D1C1E2C262C264E2G2E2G2E4G2G1E1G2G1E1G2E2C4G4A2G2G4E4G8E2C2C468025161C2C2C8025161C2E2E8\
025161C2C2C8E2C2C468' #cdefgab,CDEFGAB分别表示低音七个音阶和高音七个音阶
#芒种
ms1='54332116111112b2a212g402113154332116111112b2a212242111b1a1g2g1g1g2g1g1g2g1g1g2g1g12234122221212252361222g1g1a2b21211111202\
02111112120211111212f4a4162246221404f4a4164226a2g404f4a4162246221404f4a42413a1g4g3g1f404\
g4g3g11413412423g11404g4g3g11413412413a152423222C404e3g11212g3112222362111g6a1112612g611d1362111g6a1112622\
24a1b114a1b113b1a2b21411b11121g4b1a1g1f1e4g3g1a2g2a21224232124021131\
54332116111112b2a212g402113154332116111112b2a212242111b1a1g2g1g1g2g1g1g2g1g1g2g1g12234122221212252361222g1g1a2b21211111202' #cdefgab,CDEFGAB分别表示低音七个音阶和高音七个音阶
#分列式进行曲
import math
def start():
global k1,k2,k3
global ms
robot_ctrl.set_mode(rm_define.robot_mode_free)
v=0.5
low=['c','d','e','f','g','a','b'] #低音音符
high=['C','D','E','F','G','A','B'] #高音音符
m=[]
for i in ms:
if i in '0123456789': #0用来表示休止符
m.append([2,int(i)-1])
if i in 'cdefgab':
m.append([1,low.index(i)])
if i in 'CDEFGAB':
m.append([3,high.index(i)])
tools.timer_ctrl(rm_define.timer_start)
for i in range(len(m)):
if i%2==0:
if m[ i ][0]==2:
if m[ i ][1]>=0:
media_ctrl.play_sound(k2[m[ i ][1]])
if m[ i ][0]==1:
media_ctrl.play_sound(k1[m[ i ][1]])
if m[ i ][0]==3:
media_ctrl.play_sound(k3[m[ i ][1]])
else:
t0=tools.timer_current()
t=t0
while t<t0+(m[ i ][1]+1)*0.1:
t=tools.timer_current()
Bottom_Action(t,v) #底盘运动
Ledf(t)
chassis_ctrl.stop()
Salute()
def Bottom_Action(t,v):
t1=t+math.pi*2
cost=math.cos(t1/0.5) #1/2theta
cos05t=math.cos(t1) #1/2theta
x=v*cost #∞线 t1=t+math.pi*2 v=0.3--0.5
y=v*1.165*cos05t #∞线 t1=t+math.pi*2 v=0.3--0.5
chassis_ctrl.move_with_speed(x,y,0)
def Ledf(t):#炫彩走马灯
t=tools.timer_current()
t2=int(t*20)
i=t2%8+1
j=t2//8%256
w=255-(i*32+j)%256
if w<85:
[r,g,b]=[255-w*3,0,w*3]
else:
if w<170:
w-=85
[r,g,b]=[0,w*3,255-w*3]
else:
w-=170
[r,g,b]=[w*3,255-w*3,0]
led_ctrl.set_top_led(rm_define.armor_top_all,r,g,b,rm_define.effect_always_off)
k=(i+3)%8+1
led_ctrl.set_single_led(rm_define.armor_top_all,[i,k],rm_define.effect_always_on)
def Salute():
gimbal_ctrl.set_rotate_speed(540)
gimbal_ctrl.yaw_ctrl(-20)
time.sleep(0.2)
gimbal_ctrl.pitch_ctrl(35)
led_ctrl.gun_led_on()
time.sleep(1)
led_ctrl.gun_led_off()
gimbal_ctrl.yaw_ctrl(0)
gimbal_ctrl.pitch_ctrl(0)
time.sleep(1)
gimbal_ctrl.angle_ctrl(0,-20)
time.sleep(1.5)
gimbal_ctrl.recenter(0,0)
其中:
*底盘运动,炫彩走马灯都是借鉴论坛内“老妖怪”的方法,在此拜谢!~~~
**乐曲附送一首:分列式进行曲
***云台动作来不及加上了,后补吧!~~~~
****曲谱调用是做的列表嵌套,感谢全国3群里“AI道场”赵老师嘀帮助!拜谢!~~~~~
曲谱组成形式是奇数位为音符,偶数位为持续时长!~~~~
*****至于:x=v*cost 可以添加一个参数,用以调整∞符号的宽度,类似 x=v*1.2*cost
y=v*1.165*cos05t 同样可以添加一个参数,用以调整∞符号的整体长度,1.165是我自己场地大小调整的数字,看官可以根据自己的需求调整咯!~~~~
******v前添加(-)负号,y式可以改变运动的左、右方向,x式可以改变上、下方向!~~~~
…^_^...