功能说明:
岸上的岸基控制台会向无人控制器发射数据形为,例如:“aa15ss6”
aa后面的数值区间为:‘-15~15’,ss后面的数值区间为:‘1~9’
目的是为了取出aa后面的数值以及ss后面的数值
环境python-2.7.12
#! usr/bin/ python
#-*- coding:utf-8 -*-
import time
import random
data=['aa-15ss2','aa14ss3','aa12ss6','aa12ss8','aa13ss5','aa-6ss4','aa10ss4','aa11ss9','aa-15ss8','aa11ss7','aa3ss8']
i=random.randint(1,11)
other=data[i-1]
n=len(other)
if other[2]=='-':
if n==8:
jiaodu=other[3:5]
#quyujiayi
sudu=other[7]
print '-'+jiaodu,sudu
elif n==7:
jiaodu=other[3]
sudu=other[6]
print '-'+jiaodu,sudu
else:
if n==7:
jiaodu=other[2:4]
sudu=other[6]
print jiaodu,sudu
elif n==6:
jiaodu=other[2]
sudu=other[5]
print jiaodu,sudu
本文介绍了一种从岸基控制台发出的数据中提取角度和速度信息的方法。使用Python脚本解析形如“aa15ss6”的指令,其中aa后的数值范围为-15到15,ss后的数值范围为1到9。通过随机选取数据样本进行解析,并根据数据长度的不同处理方式打印结果。
713

被折叠的 条评论
为什么被折叠?



