回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

盲人声控电梯模型 简单

头像 Ovi 2021.05.29 676 0

主旨:盲人声控电梯模型(联合国可持续发展目标3:确保健康的生活方式,促进各年龄人群的福祉)

一、背景

当前我国有各类视力障碍的人超过1000万人,由于日常出行存在种种不便,很多盲人不愿走出家门,虽然当前我国很多城市在人行道上铺设了盲道,为盲人出行提供了很多便利,但是城市大量楼宇配置的电梯,盲人操作起来仍存在较多的困难,主要因为电梯一般是通过按钮进行运行控制,特别是楼层较高的楼宇,电梯按钮更是密密麻麻。视力障碍人士操作起来存在很大困难。

二、项目目标

为了解决上述问题,本项目建立一套通过声音和手势对电梯进行控制的模型,并通过语音合成技术,播报电梯已到达楼层,来为盲人乘坐电梯提供便利。

三、项目成果

构建该盲人声控电梯模型所使用的主要材料有:乐高积木、Microbit(BBC)、Microbit扩展板、语音识别模块、手势识别模块、超时波测距模块和舵机(360连续旋转),组装之后的盲人声控电梯模型如下图所示:

project-image

该电梯操作流程为:
1、乘客通过挥动“上”和“下”两种手势;
2、听到系统提示音后,乘客说出要前往的楼层;
3、电梯到达特定楼层后,报出相关楼屋号,提示乘客下电梯。
此外系统的电梯启动时,借助于超时波传感器,将电梯下降到1楼。

材料清单

  • Microbit X1
  • Microbit 扩展板 X1
  • 手势传感器 X1
  • 声音识别模块 X1
  • 语音合成模块 X1
  • 舵机(360连续旋转) X1
  • 超声波传感器 X1
  • 乐高积木(MindStorms系列) X1
代码
def num2py(num: number):
    global rt
    if num == 1:
        rt = "yi1"
    elif num == 2:
        rt = "er4"
    elif num == 3:
        rt = "san1"
    elif num == 4:
        rt = "si4"
    elif num == 5:
        rt = "wu3"
    elif num == 6:
        rt = "liu4"
    elif num == 7:
        rt = "qi1"
    elif num == 8:
        rt = "ba1"
    elif num == 9:
        rt = "jiu3"
    elif num == 10:
        rt = "shi2"
    elif num == 11:
        rt = "shi2yi1"
    elif num == 12:
        rt = "shi2er4"
    return rt

def on_button_pressed_b():
    basic.show_icon(IconNames.SMALL_DIAMOND)
    if True:
        Asr.Asr_Clear_Buffer()
        Asr.Asr_Set_Mode(Asr.Mode.KEY_MODE)
        Asr.Asr_Add_Words(1, "yi lou")
        Asr.Asr_Add_Words(2, "er lou")
        Asr.Asr_Add_Words(3, "san lou")
        Asr.Asr_Add_Words(4, "si lou")
        Asr.Asr_Add_Words(5, "wu lou")
        Asr.Asr_Add_Words(6, "liu lou")
        Asr.Asr_Add_Words(7, "qi lou")
        Asr.Asr_Add_Words(8, "ba lou")
        Asr.Asr_Add_Words(9, "jiu lou")
        Asr.Asr_Add_Words(10, "san ding lou")
        Asr.Asr_Add_Words(11, "er ding lou")
        Asr.Asr_Add_Words(12, "ding lou")
        Asr.Cleck_Asr_Num(12)
    Asr.Asr_Gain(64)
    Asr.Asr_Voice(Asr.Voice_State.ON)
    Asr.Asr_Set_RGB2(Asr.enColor.WHITE)
    serial.set_baud_rate(BaudRate.BAUD_RATE115200)
    basic.show_icon(IconNames.YES)
input.on_button_pressed(Button.B, on_button_pressed_b)

def go1Floor():
    global g1fCnt, distance
    g1fCnt = 0
    for index in range(100):
        distance = sonar.ping(DigitalPin.P10, DigitalPin.P0, PingUnit.CENTIMETERS)
        if 4 <= distance:
            pins.servo_write_pin(AnalogPin.P5, 50)
            g1fCnt = 0
            basic.show_string("D")
            basic.pause(500)
        else:
            pins.servo_write_pin(AnalogPin.P5, 90)
            g1fCnt += 1
            basic.show_string("E")
            basic.pause(10)
        if 5 < g1fCnt:
            break
startAsrFlag = 0
gesture = 0
value = 0
mv = 0
distance = 0
g1fCnt = 0
rt = ""
basic.show_icon(IconNames.ASLEEP)
Speech.Set_IICAddress(Speech.I2C_ADDR_Select.NEW_ADDR)
Speech.set_volume(9)
Speech.set_intonation(4)
Speech.set_speed(2)
Speech.set_reader(Speech.Reader_Type.READER_XIAOYAN)
Speech.set_spell(Speech.Spell_Type.SPELL_ENABLE)
basic.show_icon(IconNames.TRIANGLE)
Speech.Speech_Text("zheng4zai4qi3dong4")
basic.pause(500)
while GestureRecognition.gesture_init() == 255:
    basic.show_icon(IconNames.SAD)
    basic.pause(1000)
basic.show_icon(IconNames.SMALL_SQUARE)
basic.pause(2000)
floor = 1
go1Floor()
Speech.Speech_Text("wan2cheng2qi3dong4")

def on_forever():
    global mv, value, floor
    mv = 0
    value = Asr.Asr_Result()
    serial.write_number(value)
    if value >= 1 and value <= 9:
        basic.show_string(convert_to_text(value))
        mv = value - floor
        floor = value
    elif value == 10:
        basic.show_leds("""
            # . # # #
            # . # . #
            # . # . #
            # . # . #
            # . # # #
            """)
        mv = value - floor
        floor = 10
    elif value == 11:
        basic.show_leds("""
            . # . # .
            . # . # .
            . # . # .
            . # . # .
            . # . # .
            """)
        mv = value - floor
        floor = 11
    elif value == 12:
        basic.show_leds("""
            # . # # .
            # . . . #
            # . . # .
            # . # . .
            # . # # #
            """)
        mv = value - floor
        floor = 12
    if mv > 0:
        pins.servo_write_pin(AnalogPin.P5, 142)
        for index2 in range(mv):
            basic.pause(2120)
        pins.servo_write_pin(AnalogPin.P5, 90)
        Speech.Speech_Text("" + num2py(floor) + "lou2dao4le1")
    elif mv < 0:
        pins.servo_write_pin(AnalogPin.P5, 38)
        for index3 in range(abs(mv)):
            basic.pause(2000)
        pins.servo_write_pin(AnalogPin.P5, 90)
        Speech.Speech_Text("" + num2py(floor) + "lou2dao4le1")
    mv = 0
basic.forever(on_forever)

def on_forever2():
    global gesture, startAsrFlag
    gesture = GestureRecognition.get_gesture()
    startAsrFlag = 0
    if floor < 10:
        basic.show_string(convert_to_text(floor))
    elif floor == 10:
        basic.show_leds("""
            # . # # #
            # . # . #
            # . # . #
            # . # . #
            # . # # #
            """)
    elif floor == 11:
        basic.show_leds("""
            . # . # .
            . # . # .
            . # . # .
            . # . # .
            . # . # .
            """)
    elif floor == 12:
        basic.show_leds("""
            # . # # .
            # . . . #
            # . . # .
            # . # . .
            # . # # #
            """)
    if gesture == GestureRecognition.select_gesture(GestureRecognition.Gesture_state.UP) or gesture == GestureRecognition.select_gesture(GestureRecognition.Gesture_state.RIGHT):
        # music.startMelody(music.builtInMelody(Melodies.Prelude), MelodyOptions.OnceInBackground)
        basic.show_arrow(ArrowNames.NORTH)
        startAsrFlag = 1
    elif gesture == GestureRecognition.select_gesture(GestureRecognition.Gesture_state.DOWN) or gesture == GestureRecognition.select_gesture(GestureRecognition.Gesture_state.LEFT):
        # music.startMelody(music.builtInMelody(Melodies.Ode), MelodyOptions.OnceInBackground)
        basic.show_arrow(ArrowNames.SOUTH)
        startAsrFlag = 1
    if startAsrFlag == 1:
        Asr.Asr_Key_ON()
        basic.pause(3000)
        for index4 in range(abs(mv)):
            basic.pause(2000)
basic.forever(on_forever2)

评论

user-avatar