基于创意之星AI控制的六足机器人,是基于创意之星AI控制器,并搭建出六足机器人构型。
搭建方案请参考随机说明的《六足机器人搭建手册》或自行完成搭建
如下所示,是我们搭建的六足机器人构型。
在创意之星AI组件包控制器中,六足机器人的程序位于创意之星AI控制器的up_cyzx_demo文件夹下的cyzx_hexapod.py文件中。
在六足机器人的程序中,我们主要实现了六足机器人的前进、后退、左转、右转、左移、右移、上升、下降等基本运动。
比如,初始化的时候,我们将所有的接入舵机设置为舵机模式:
#设置所有舵机模式 :0舵机,1电机 舵机id(1~20)
for id in range(1,21):
self.up.CDS_SetMode(id,0)
舵机可按照一些设定的动作进行运动,比如前进:
def GoForward(self):
self.count += 1
if self.count > 5:
self.up.CDS_SetAngle(19,512,512)
self.up.CDS_SetAngle(20,562,512)
time.sleep(0.5)
self.BackSquat()
self.ShakeHead()
self.count = 0
self.forward_flag = 0
self.Standup()
self.up.CDS_SetAngle(1,435,300)
self.up.CDS_SetAngle(2,619,300)
self.up.CDS_SetAngle(3,324,300)
self.up.CDS_SetAngle(4,475,300)
self.up.CDS_SetAngle(5,517,300)
self.up.CDS_SetAngle(6,222,300)
self.up.CDS_SetAngle(7,695,300)
self.up.CDS_SetAngle(8,612,300)
self.up.CDS_SetAngle(9,358,300)
self.up.CDS_SetAngle(10,780,300)
self.up.CDS_SetAngle(11,520,300)
self.up.CDS_SetAngle(12,230,300)
self.up.CDS_SetAngle(13,420,300)
self.up.CDS_SetAngle(14,657,300)
self.up.CDS_SetAngle(15,303,300)
self.up.CDS_SetAngle(16,430,300)
self.up.CDS_SetAngle(17,532,300)
self.up.CDS_SetAngle(18,241,300)
time.sleep(0.4)
self.up.CDS_SetAngle(5,657,512)
self.up.CDS_SetAngle(6,312,512)
self.up.CDS_SetAngle(11,640,512)
self.up.CDS_SetAngle(12,320,512)
self.up.CDS_SetAngle(17,627,512)
self.up.CDS_SetAngle(18,341,512)
time.sleep(0.4)
self.up.CDS_SetAngle(1,315,300)
self.up.CDS_SetAngle(2,499,300)
self.up.CDS_SetAngle(3,234,300)
self.up.CDS_SetAngle(4,615,300)
self.up.CDS_SetAngle(7,575,300)
self.up.CDS_SetAngle(8,517,300)
self.up.CDS_SetAngle(9,220,300)
self.up.CDS_SetAngle(10,660,300)
self.up.CDS_SetAngle(13,560,300)
self.up.CDS_SetAngle(14,547,300)
self.up.CDS_SetAngle(15,213,300)
self.up.CDS_SetAngle(16,310,300)
time.sleep(0.4)
self.up.CDS_SetAngle(2,619,512)
self.up.CDS_SetAngle(3,324,512)
self.up.CDS_SetAngle(8,612,512)
self.up.CDS_SetAngle(9,358,512)
self.up.CDS_SetAngle(14,657,512)
self.up.CDS_SetAngle(15,303,512)
time.sleep(0.4)
类似的动作设置可以直接在程序中调用,搭配传感器扩展新的功能。
在实际应用中,可以根据实际情况调整舵机角度,或者设置新的六足运动动作。