NAOQI OS是軟銀pepper和nao機器人的核心操作系統(tǒng),NAOQI API提供了訪問機器人的各種傳感器設備接口以及應用接口详瑞。
NAOqi Core之ALBehaviourManager
ALBehaviorManager旨在管理行為(Behaviour)遗嗽。有了這個模塊粘我,你可以:
- 加載,啟動痹换,停止一個行為征字;
- 管理默認行為;
- 獲取有關行為的信息娇豫;
默認行為:一些行為可以被標記為“默認”匙姜,這意味著它們在NAOqi啟動時自動啟動。 ALBehaviorManager允許用戶添加或刪除這些行為冯痢,或啟動和停止它們氮昧。
行為名字:一個行為的名稱由其來包ID及其本地路徑組成框杜。開始行為通常如下所示:
myBehaviorManagerProxy.startBehavior("my_application/a_behavior")
示例:albehaviormanager_example.py
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Use ALBehaviorManager Module"""
import qi
import argparse
import sys
import time
def main(session, behavior_name):
"""
Use ALBehaviorManager Module.
"""
# Get the service ALBehaviorManager.
behavior_mng_service = session.service("ALBehaviorManager")
getBehaviors(behavior_mng_service)
launchAndStopBehavior(behavior_mng_service, behavior_name)
defaultBehaviors(behavior_mng_service, behavior_name)
def getBehaviors(behavior_mng_service):
"""
Know which behaviors are on the robot.
"""
names = behavior_mng_service.getInstalledBehaviors()
print "Behaviors on the robot:"
print names
names = behavior_mng_service.getRunningBehaviors()
print "Running behaviors:"
print names
def launchAndStopBehavior(behavior_mng_service, behavior_name):
"""
Launch and stop a behavior, if possible.
"""
# Check that the behavior exists.
if (behavior_mng_service.isBehaviorInstalled(behavior_name)):
# Check that it is not already running.
if (not behavior_mng_service.isBehaviorRunning(behavior_name)):
# Launch behavior. This is a blocking call, use _async=True if you do not
# want to wait for the behavior to finish.
behavior_mng_service.runBehavior(behavior_name, _async=True)
time.sleep(0.5)
else:
print "Behavior is already running."
else:
print "Behavior not found."
return
names = behavior_mng_service.getRunningBehaviors()
print "Running behaviors:"
print names
# Stop the behavior.
if (behavior_mng_service.isBehaviorRunning(behavior_name)):
behavior_mng_service.stopBehavior(behavior_name)
time.sleep(1.0)
else:
print "Behavior is already stopped."
names = behavior_mng_service.getRunningBehaviors()
print "Running behaviors:"
print names
def defaultBehaviors(behavior_mng_service, behavior_name):
"""
Set a behavior as default and remove it from default behavior.
"""
# Get default behaviors.
names = behavior_mng_service.getDefaultBehaviors()
print "Default behaviors:"
print names
# Add behavior to default.
behavior_mng_service.addDefaultBehavior(behavior_name)
names = behavior_mng_service.getDefaultBehaviors()
print "Default behaviors:"
print names
# Remove behavior from default.
behavior_mng_service.removeDefaultBehavior(behavior_name)
names = behavior_mng_service.getDefaultBehaviors()
print "Default behaviors:"
print names
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
parser.add_argument("--behavior_name", type=str, required=True,
help="Name of the behavior")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session, args.behavior_name)
示例運行步驟:運行python腳本,給出NAO的IP和行為名稱作為參數(shù)袖肥,如下
python albehaviormanager_example.py robotIp behaviorName
運行結果:
[W] 1496392380.189819 5379 qi.path.sdklayout: No Application was created, trying to deduce paths
Behaviors on the robot:
['animationMode', 'animations/LED/CircleEyes', 'animations/Stand/BodyTalk/Listening/Listening_1', 'animations/Stand/BodyTalk/Listening/Listening_2', 'animations/Stand/BodyTalk/Listening/Listening_3', 'animations/Stand/BodyTalk/Listening/Listening_4', 'animations/Stand/BodyTalk/Listening/Listening_5', 'animations/Stand/BodyTalk/Listening/Listening_6', 'animations/Stand/BodyTalk/Listening/Listening_7', 'animations/Stand/BodyTalk/Speaking/BodyTalk_1', 'animations/Stand/BodyTalk/Speaking/BodyTalk_10', 'animations/Stand/BodyTalk/Speaking/BodyTalk_11', 'animations/Stand/BodyTalk/Speaking/BodyTalk_12', 'animations/Stand/BodyTalk/Speaking/BodyTalk_13', 'animations/Stand/BodyTalk/Speaking/BodyTalk_14', 'animations/Stand/BodyTalk/Speaking/BodyTalk_15', 'animations/Stand/BodyTalk/Speaking/BodyTalk_16', 'animations/Stand/BodyTalk/Speaking/BodyTalk_2', 'animations/Stand/BodyTalk/Speaking/BodyTalk_3', 'animations/Stand/BodyTalk/Speaking/BodyTalk_4', 'animations/Stand/BodyTalk/Speaking/BodyTalk_5', 'animations/Stand/BodyTalk/Speaking/BodyTalk_6', 'animations/Stand/BodyTalk/Speaking/BodyTalk_7', 'animations/Stand/BodyTalk/Speaking/BodyTalk_8', 'animations/Stand/BodyTalk/Speaking/BodyTalk_9', 'animations/Stand/BodyTalk/Thinking/Remember_1', 'animations/Stand/BodyTalk/Thinking/Remember_2', 'animations/Stand/BodyTalk/Thinking/Remember_3', 'animations/Stand/BodyTalk/Thinking/ThinkingLoop_1', 'animations/Stand/BodyTalk/Thinking/ThinkingLoop_2', 'animations/Stand/Emotions/Negative/Angry_1', 'animations/Stand/Emotions/Negative/Angry_2', 'animations/Stand/Emotions/Negative/Angry_3', 'animations/Stand/Emotions/Negative/Angry_4', 'animations/Stand/Emotions/Negative/Anxious_1', 'animations/Stand/Emotions/Negative/Bored_1', 'animations/Stand/Emotions/Negative/Bored_2', 'animations/Stand/Emotions/Negative/Disappointed_1', 'animations/Stand/Emotions/Negative/Exhausted_1', 'animations/Stand/Emotions/Negative/Exhausted_2', 'animations/Stand/Emotions/Negative/Fear_1', 'animations/Stand/Emotions/Negative/Fear_2', 'animations/Stand/Emotions/Negative/Fearful_1', 'animations/Stand/Emotions/Negative/Frustrated_1', 'animations/Stand/Emotions/Negative/Humiliated_1', 'animations/Stand/Emotions/Negative/Hurt_1', 'animations/Stand/Emotions/Negative/Hurt_2', 'animations/Stand/Emotions/Negative/Late_1', 'animations/Stand/Emotions/Negative/Sad_1', 'animations/Stand/Emotions/Negative/Sad_2', 'animations/Stand/Emotions/Negative/Shocked_1', 'animations/Stand/Emotions/Negative/Sorry_1', 'animations/Stand/Emotions/Negative/Surprise_1', 'animations/Stand/Emotions/Negative/Surprise_2', 'animations/Stand/Emotions/Negative/Surprise_3', 'animations/Stand/Emotions/Neutral/Alienated_1', 'animations/Stand/Emotions/Neutral/AskForAttention_1', 'animations/Stand/Emotions/Neutral/AskForAttention_2', 'animations/Stand/Emotions/Neutral/AskForAttention_3', 'animations/Stand/Emotions/Neutral/Cautious_1', 'animations/Stand/Emotions/Neutral/Confused_1', 'animations/Stand/Emotions/Neutral/Determined_1', 'animations/Stand/Emotions/Neutral/Embarrassed_1', 'animations/Stand/Emotions/Neutral/Hesitation_1', 'animations/Stand/Emotions/Neutral/Innocent_1', 'animations/Stand/Emotions/Neutral/Lonely_1', 'animations/Stand/Emotions/Neutral/Mischievous_1', 'animations/Stand/Emotions/Neutral/Puzzled_1', 'animations/Stand/Emotions/Neutral/Sneeze', 'animations/Stand/Emotions/Neutral/Stubborn_1', 'animations/Stand/Emotions/Neutral/Suspicious_1', 'animations/Stand/Emotions/Positive/Amused_1', 'animations/Stand/Emotions/Positive/Confident_1', 'animations/Stand/Emotions/Positive/Ecstatic_1', 'animations/Stand/Emotions/Positive/Enthusiastic_1', 'animations/Stand/Emotions/Positive/Excited_1', 'animations/Stand/Emotions/Positive/Excited_2', 'animations/Stand/Emotions/Positive/Excited_3', 'animations/Stand/Emotions/Positive/Happy_1', 'animations/Stand/Emotions/Positive/Happy_2', 'animations/Stand/Emotions/Positive/Happy_3', 'animations/Stand/Emotions/Positive/Happy_4', 'animations/Stand/Emotions/Positive/Hungry_1', 'animations/Stand/Emotions/Positive/Hysterical_1', 'animations/Stand/Emotions/Positive/Interested_1', 'animations/Stand/Emotions/Positive/Interested_2', 'animations/Stand/Emotions/Positive/Laugh_1', 'animations/Stand/Emotions/Positive/Laugh_2', 'animations/Stand/Emotions/Positive/Laugh_3', 'animations/Stand/Emotions/Positive/Mocker_1', 'animations/Stand/Emotions/Positive/Optimistic_1', 'animations/Stand/Emotions/Positive/Peaceful_1', 'animations/Stand/Emotions/Positive/Proud_1', 'animations/Stand/Emotions/Positive/Proud_2', 'animations/Stand/Emotions/Positive/Proud_3', 'animations/Stand/Emotions/Positive/Relieved_1', 'animations/Stand/Emotions/Positive/Shy_1', 'animations/Stand/Emotions/Positive/Shy_2', 'animations/Stand/Emotions/Positive/Sure_1', 'animations/Stand/Emotions/Positive/Winner_1', 'animations/Stand/Emotions/Positive/Winner_2', 'animations/Stand/Gestures/Angry_1', 'animations/Stand/Gestures/Angry_2', 'animations/Stand/Gestures/Angry_3', 'animations/Stand/Gestures/BowShort_1', 'animations/Stand/Gestures/BowShort_2', 'animations/Stand/Gestures/BowShort_3', 'animations/Stand/Gestures/But_1', 'animations/Stand/Gestures/CalmDown_1', 'animations/Stand/Gestures/CalmDown_2', 'animations/Stand/Gestures/CalmDown_3', 'animations/Stand/Gestures/CalmDown_4', 'animations/Stand/Gestures/CalmDown_5', 'animations/Stand/Gestures/CalmDown_6', 'animations/Stand/Gestures/Choice_1', 'animations/Stand/Gestures/ComeOn_1', 'animations/Stand/Gestures/Confused_1', 'animations/Stand/Gestures/Confused_2', 'animations/Stand/Gestures/CountFive_1', 'animations/Stand/Gestures/CountFour_1', 'animations/Stand/Gestures/CountMore_1', 'animations/Stand/Gestures/CountOne_1', 'animations/Stand/Gestures/CountThree_1', 'animations/Stand/Gestures/CountTwo_1', 'animations/Stand/Gestures/Desperate_1', 'animations/Stand/Gestures/Desperate_2', 'animations/Stand/Gestures/Desperate_3', 'animations/Stand/Gestures/Desperate_4', 'animations/Stand/Gestures/Desperate_5', 'animations/Stand/Gestures/DontUnderstand_1', 'animations/Stand/Gestures/Enthusiastic_3', 'animations/Stand/Gestures/Enthusiastic_4', 'animations/Stand/Gestures/Enthusiastic_5', 'animations/Stand/Gestures/Everything_1', 'animations/Stand/Gestures/Everything_2', 'animations/Stand/Gestures/Everything_3', 'animations/Stand/Gestures/Everything_4', 'animations/Stand/Gestures/Everything_6', 'animations/Stand/Gestures/Excited_1', 'animations/Stand/Gestures/Explain_1', 'animations/Stand/Gestures/Explain_10', 'animations/Stand/Gestures/Explain_11', 'animations/Stand/Gestures/Explain_2', 'animations/Stand/Gestures/Explain_3', 'animations/Stand/Gestures/Explain_4', 'animations/Stand/Gestures/Explain_5', 'animations/Stand/Gestures/Explain_6', 'animations/Stand/Gestures/Explain_7', 'animations/Stand/Gestures/Explain_8', 'animations/Stand/Gestures/Far_1', 'animations/Stand/Gestures/Far_2', 'animations/Stand/Gestures/Far_3', 'animations/Stand/Gestures/Follow_1', 'animations/Stand/Gestures/Give_1', 'animations/Stand/Gestures/Give_2', 'animations/Stand/Gestures/Give_3', 'animations/Stand/Gestures/Give_4', 'animations/Stand/Gestures/Give_5', 'animations/Stand/Gestures/Give_6', 'animations/Stand/Gestures/Great_1', 'animations/Stand/Gestures/HeSays_1', 'animations/Stand/Gestures/HeSays_2', 'animations/Stand/Gestures/HeSays_3', 'animations/Stand/Gestures/Hey_1', 'animations/Stand/Gestures/Hey_10', 'animations/Stand/Gestures/Hey_2', 'animations/Stand/Gestures/Hey_3', 'animations/Stand/Gestures/Hey_4', 'animations/Stand/Gestures/Hey_6', 'animations/Stand/Gestures/Hey_7', 'animations/Stand/Gestures/Hey_8', 'animations/Stand/Gestures/Hey_9', 'animations/Stand/Gestures/Hide_1', 'animations/Stand/Gestures/Hot_1', 'animations/Stand/Gestures/Hot_2', 'animations/Stand/Gestures/IDontKnow_1', 'animations/Stand/Gestures/IDontKnow_2', 'animations/Stand/Gestures/IDontKnow_3', 'animations/Stand/Gestures/IDontKnow_4', 'animations/Stand/Gestures/IDontKnow_5', 'animations/Stand/Gestures/IDontKnow_6', 'animations/Stand/Gestures/Joy_1', 'animations/Stand/Gestures/Kisses_1', 'animations/Stand/Gestures/Look_1', 'animations/Stand/Gestures/Look_2', 'animations/Stand/Gestures/Maybe_1', 'animations/Stand/Gestures/Me_1', 'animations/Stand/Gestures/Me_2', 'animations/Stand/Gestures/Me_4', 'animations/Stand/Gestures/Me_7', 'animations/Stand/Gestures/Me_8', 'animations/Stand/Gestures/Mime_1', 'animations/Stand/Gestures/Mime_2', 'animations/Stand/Gestures/Next_1', 'animations/Stand/Gestures/No_1', 'animations/Stand/Gestures/No_2', 'animations/Stand/Gestures/No_3', 'animations/Stand/Gestures/No_4', 'animations/Stand/Gestures/No_5', 'animations/Stand/Gestures/No_6', 'animations/Stand/Gestures/No_7', 'animations/Stand/Gestures/No_8', 'animations/Stand/Gestures/No_9', 'animations/Stand/Gestures/Nothing_1', 'animations/Stand/Gestures/Nothing_2', 'animations/Stand/Gestures/OnTheEvening_1', 'animations/Stand/Gestures/OnTheEvening_2', 'animations/Stand/Gestures/OnTheEvening_3', 'animations/Stand/Gestures/OnTheEvening_4', 'animations/Stand/Gestures/OnTheEvening_5', 'animations/Stand/Gestures/Please_1', 'animations/Stand/Gestures/Please_2', 'animations/Stand/Gestures/Please_3', 'animations/Stand/Gestures/Reject_1', 'animations/Stand/Gestures/Reject_2', 'animations/Stand/Gestures/Reject_3', 'animations/Stand/Gestures/Reject_4', 'animations/Stand/Gestures/Reject_5', 'animations/Stand/Gestures/Reject_6', 'animations/Stand/Gestures/Salute_1', 'animations/Stand/Gestures/Salute_2', 'animations/Stand/Gestures/Salute_3', 'animations/Stand/Gestures/ShowFloor_1', 'animations/Stand/Gestures/ShowFloor_2', 'animations/Stand/Gestures/ShowFloor_3', 'animations/Stand/Gestures/ShowFloor_4', 'animations/Stand/Gestures/ShowFloor_5', 'animations/Stand/Gestures/ShowSky_1', 'animations/Stand/Gestures/ShowSky_10', 'animations/Stand/Gestures/ShowSky_11', 'animations/Stand/Gestures/ShowSky_12', 'animations/Stand/Gestures/ShowSky_2', 'animations/Stand/Gestures/ShowSky_3', 'animations/Stand/Gestures/ShowSky_4', 'animations/Stand/Gestures/ShowSky_5', 'animations/Stand/Gestures/ShowSky_6', 'animations/Stand/Gestures/ShowSky_7', 'animations/Stand/Gestures/ShowSky_8', 'animations/Stand/Gestures/ShowSky_9', 'animations/Stand/Gestures/ShowTablet_1', 'animations/Stand/Gestures/ShowTablet_2', 'animations/Stand/Gestures/ShowTablet_3', 'animations/Stand/Gestures/Shy_1', 'animations/Stand/Gestures/Stretch_1', 'animations/Stand/Gestures/Stretch_2', 'animations/Stand/Gestures/Surprised_1', 'animations/Stand/Gestures/Take_1', 'animations/Stand/Gestures/TakePlace_1', 'animations/Stand/Gestures/TakePlace_2', 'animations/Stand/Gestures/Thinking_1', 'animations/Stand/Gestures/Thinking_2', 'animations/Stand/Gestures/Thinking_3', 'animations/Stand/Gestures/Thinking_4', 'animations/Stand/Gestures/Thinking_5', 'animations/Stand/Gestures/Thinking_6', 'animations/Stand/Gestures/Thinking_7', 'animations/Stand/Gestures/Thinking_8', 'animations/Stand/Gestures/This_1', 'animations/Stand/Gestures/This_10', 'animations/Stand/Gestures/This_11', 'animations/Stand/Gestures/This_12', 'animations/Stand/Gestures/This_13', 'animations/Stand/Gestures/This_14', 'animations/Stand/Gestures/This_15', 'animations/Stand/Gestures/This_2', 'animations/Stand/Gestures/This_3', 'animations/Stand/Gestures/This_4', 'animations/Stand/Gestures/This_5', 'animations/Stand/Gestures/This_6', 'animations/Stand/Gestures/This_7', 'animations/Stand/Gestures/This_8', 'animations/Stand/Gestures/This_9', 'animations/Stand/Gestures/WhatSThis_1', 'animations/Stand/Gestures/WhatSThis_10', 'animations/Stand/Gestures/WhatSThis_11', 'animations/Stand/Gestures/WhatSThis_12', 'animations/Stand/Gestures/WhatSThis_13', 'animations/Stand/Gestures/WhatSThis_14', 'animations/Stand/Gestures/WhatSThis_15', 'animations/Stand/Gestures/WhatSThis_16', 'animations/Stand/Gestures/WhatSThis_2', 'animations/Stand/Gestures/WhatSThis_3', 'animations/Stand/Gestures/WhatSThis_4', 'animations/Stand/Gestures/WhatSThis_5', 'animations/Stand/Gestures/WhatSThis_6', 'animations/Stand/Gestures/WhatSThis_7', 'animations/Stand/Gestures/WhatSThis_8', 'animations/Stand/Gestures/WhatSThis_9', 'animations/Stand/Gestures/Whisper_1', 'animations/Stand/Gestures/Wings_1', 'animations/Stand/Gestures/Wings_2', 'animations/Stand/Gestures/Wings_3', 'animations/Stand/Gestures/Wings_4', 'animations/Stand/Gestures/Wings_5', 'animations/Stand/Gestures/Yes_1', 'animations/Stand/Gestures/Yes_2', 'animations/Stand/Gestures/Yes_3', 'animations/Stand/Gestures/You_1', 'animations/Stand/Gestures/You_2', 'animations/Stand/Gestures/You_3', 'animations/Stand/Gestures/You_4', 'animations/Stand/Gestures/You_5', 'animations/Stand/Gestures/YouKnowWhat_1', 'animations/Stand/Gestures/YouKnowWhat_2', 'animations/Stand/Gestures/YouKnowWhat_3', 'animations/Stand/Gestures/YouKnowWhat_4', 'animations/Stand/Gestures/YouKnowWhat_5', 'animations/Stand/Gestures/YouKnowWhat_6', 'animations/Stand/Gestures/Yum_1', 'animations/Stand/Reactions/EthernetOff_1', 'animations/Stand/Reactions/EthernetOn_1', 'animations/Stand/Reactions/Heat_1', 'animations/Stand/Reactions/Heat_2', 'animations/Stand/Reactions/LightShine_1', 'animations/Stand/Reactions/LightShine_2', 'animations/Stand/Reactions/LightShine_3', 'animations/Stand/Reactions/LightShine_4', 'animations/Stand/Reactions/SeeColor_1', 'animations/Stand/Reactions/SeeColor_2', 'animations/Stand/Reactions/SeeColor_3', 'animations/Stand/Reactions/SeeSomething_1', 'animations/Stand/Reactions/SeeSomething_3', 'animations/Stand/Reactions/SeeSomething_4', 'animations/Stand/Reactions/SeeSomething_5', 'animations/Stand/Reactions/SeeSomething_6', 'animations/Stand/Reactions/SeeSomething_7', 'animations/Stand/Reactions/SeeSomething_8', 'animations/Stand/Reactions/ShakeBody_1', 'animations/Stand/Reactions/ShakeBody_2', 'animations/Stand/Reactions/ShakeBody_3', 'animations/Stand/Reactions/TouchHead_1', 'animations/Stand/Reactions/TouchHead_2', 'animations/Stand/Reactions/TouchHead_3', 'animations/Stand/Reactions/TouchHead_4', 'animations/Stand/Waiting/AirGuitar_1', 'animations/Stand/Waiting/BackRubs_1', 'animations/Stand/Waiting/Bandmaster_1', 'animations/Stand/Waiting/Binoculars_1', 'animations/Stand/Waiting/BreathLoop_1', 'animations/Stand/Waiting/BreathLoop_2', 'animations/Stand/Waiting/BreathLoop_3', 'animations/Stand/Waiting/CallSomeone_1', 'animations/Stand/Waiting/Drink_1', 'animations/Stand/Waiting/DriveCar_1', 'animations/Stand/Waiting/Fitness_1', 'animations/Stand/Waiting/Fitness_2', 'animations/Stand/Waiting/Fitness_3', 'animations/Stand/Waiting/FunnyDancer_1', 'animations/Stand/Waiting/HappyBirthday_1', 'animations/Stand/Waiting/Helicopter_1', 'animations/Stand/Waiting/HideEyes_1', 'animations/Stand/Waiting/HideHands_1', 'animations/Stand/Waiting/Innocent_1', 'animations/Stand/Waiting/Knight_1', 'animations/Stand/Waiting/KnockEye_1', 'animations/Stand/Waiting/KungFu_1', 'animations/Stand/Waiting/LookHand_1', 'animations/Stand/Waiting/LookHand_2', 'animations/Stand/Waiting/LoveYou_1', 'animations/Stand/Waiting/Monster_1', 'animations/Stand/Waiting/MysticalPower_1', 'animations/Stand/Waiting/PlayHands_1', 'animations/Stand/Waiting/PlayHands_2', 'animations/Stand/Waiting/PlayHands_3', 'animations/Stand/Waiting/Relaxation_1', 'animations/Stand/Waiting/Relaxation_2', 'animations/Stand/Waiting/Relaxation_3', 'animations/Stand/Waiting/Relaxation_4', 'animations/Stand/Waiting/Rest_1', 'animations/Stand/Waiting/Robot_1', 'animations/Stand/Waiting/ScratchBack_1', 'animations/Stand/Waiting/ScratchBottom_1', 'animations/Stand/Waiting/ScratchEye_1', 'animations/Stand/Waiting/ScratchHand_1', 'animations/Stand/Waiting/ScratchHead_1', 'animations/Stand/Waiting/ScratchLeg_1', 'animations/Stand/Waiting/ScratchTorso_1', 'animations/Stand/Waiting/ShowMuscles_1', 'animations/Stand/Waiting/ShowMuscles_2', 'animations/Stand/Waiting/ShowMuscles_3', 'animations/Stand/Waiting/ShowMuscles_4', 'animations/Stand/Waiting/ShowMuscles_5', 'animations/Stand/Waiting/ShowSky_1', 'animations/Stand/Waiting/ShowSky_2', 'animations/Stand/Waiting/SpaceShuttle_1', 'animations/Stand/Waiting/Stretch_1', 'animations/Stand/Waiting/Stretch_2', 'animations/Stand/Waiting/TakePicture_1', 'animations/Stand/Waiting/Taxi_1', 'animations/Stand/Waiting/Think_1', 'animations/Stand/Waiting/Think_2', 'animations/Stand/Waiting/Think_3', 'animations/Stand/Waiting/Think_4', 'animations/Stand/Waiting/Waddle_1', 'animations/Stand/Waiting/Waddle_2', 'animations/Stand/Waiting/WakeUp_1', 'animations/Stand/Waiting/Zombie_1', 'asleep-update/animations/nok', 'asleep-update/interactive', 'boot-config', 'boot-config/animations/onNextPage', 'boot-config/animations/onPrevPage', 'boot-config/animations/poseInit', 'boot-config/animations/ok', 'boot-config/animations/success', 'boot-config/animations/poseInitUp', 'boot-config/animations/turnTabletOn_end', 'boot-config/animations/turnTabletOn_start', 'boot-config/animations/warning', 'boot-config/animations/warningValidate', 'boot-config/animations/nok', 'boot-config/animations/updateLoop', 'boot-config/animations/updateOut', 'boot-config/animations/networkLoop', 'boot-config/animations/networkOut', 'boot-config/animations/inviteTablet', 'boot-config/animations/hello', 'boot-config/animations/updateFailed', 'boot-config/animations/finishWizard', 'boot-config/animations/onPlugged', 'boot-config/animations/onUnPlugged', 'boot-config/animations/shutdown', 'boot-config/animations/bipGentle', 'boot-config/animations/endReco', 'dialog_applauncher', 'dialog_lexicon', 'dialog_lexicon/behavior_1', 'ft_seeandlisten_cctv/behavior_1', 'ipepperserver-qishanshi/iPepperServer', 'j-tablet-browser', 'naospyserver/NAOSpyServer', 'push-recovered/animations/pushed_0', 'push-recovered/animations/pushed_1', 'push-recovered/animations/pushed_2', 'push-recovered/solitary', 'push-recovered/animations/searchHumans_1', 'run_dialog_dev', 'run_dialog_dev/init', 'sbr_8641813c-6336-41ef-b317-140d85039314_ets/resident', 'sleep-reactions/Animations/Start_ShakeHead', 'sleep-reactions/Animations/End_ShakeHead', 'sleep-reactions/TouchHand', 'sleep-reactions/RandomHand', 'three_musketeers_story-ad31f7', 'three_musketeers_story-ad31f7/animations/acclaimed', 'three_musketeers_story-ad31f7/animations/cardinal', 'three_musketeers_story-ad31f7/animations/brass-band', 'three_musketeers_story-ad31f7/animations/fierce-duel', 'three_musketeers_story-ad31f7/animations/horse-riding', 'three_musketeers_story-ad31f7/animations/adventure', 'three_musketeers_story-ad31f7/animations/bravest', 'three_musketeers_story-ad31f7/animations/defeated', 'three_musketeers_story-ad31f7/animations/louis', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/behavior_1', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/resident', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/editmode', '.lastUploadedChoregrapheBehavior/behavior_1']
Running behaviors:
['.lastUploadedChoregrapheBehavior/behavior_1', 'dialog_applauncher/.', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/behavior_1', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/editmode']
Default behaviors:
['zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/behavior_1', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/editmode', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/resident']
Default behaviors:
['run_dialog_dev/.', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/behavior_1', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/editmode', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/resident']
Default behaviors:
['zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/behavior_1', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/editmode', 'zzzzzz_c9da7da9-3524-4dc3-867b-7505bf884f55_b2bral/resident']
NAOqi Core之ALConnectionManager
ALConnectionManager提供了管理網(wǎng)絡連接的方法:它包含了允許您配置或連接網(wǎng)絡的命令咪辱,也包含了獲取網(wǎng)絡屬性或創(chuàng)建網(wǎng)絡的命令。 ALConnectionManager支持以太網(wǎng)椎组,WiFi和藍牙等多種技術油狂。
主要功能有:
列出可用的網(wǎng)絡服務。
連接到網(wǎng)絡服務寸癌。
創(chuàng)建網(wǎng)絡服務(支持WiFi接入點和藍牙PAN)专筷。
列出可用的網(wǎng)絡技術。
配置網(wǎng)絡服務蒸苇。
此模塊可以訪問不同網(wǎng)絡服務的有用信息磷蛹,例如WiFi服務的強度,其當前狀態(tài)或其安全性要求溪烤。
此模塊通過事件通知有關網(wǎng)絡連接的更改弦聂。
ALConnectionManager基于開源軟件ConnMan獲取有關所有網(wǎng)絡服務的信息并與之連接。
SoftBank Robotics是ConnMan項目的貢獻者氛什,我們的ConnMan源代碼位于github http://github.com/aldebaran上莺葫,只有幾個補丁與官方ConnMan版本不同。
WiFi服務由WPA Supplicant提供枪眉。藍牙服務由BlueZ提供捺檬。
局限性:
ALConnectionManager僅在機器人上可用。
ALConnectionManager目前不支持WPA企業(yè)安全贸铜。
啟用網(wǎng)絡共享模式(tethering mode)時堡纬,WiFi服務列表不可用。
ALConnectionManager不處理藍牙設備配對蒿秦。
示例:獲取網(wǎng)絡連接的全局狀態(tài)
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Use state Method"""
import qi
import argparse
import sys
def main(session):
"""
This example uses the state method.
"""
# Get the service ALConnectionManager.
con_mng_service = session.service("ALConnectionManager")
# Get network state.
print "Network state: " + con_mng_service.state()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)
運行結果:Network state: online
示例:獲取網(wǎng)絡服務列表
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Use scan and services Methods"""
import qi
import argparse
import sys
def main(session):
"""
This example uses the scan and services method.
"""
# Get the service ALConnectionManager.
con_mng_service = session.service("ALConnectionManager")
#Scanning is required to update the services list
con_mng_service.scan()
services = con_mng_service.services()
for service in services:
network = dict(service)
if network["Name"] == "":
print "{hidden} " + network["ServiceId"]
else:
print network["Name"] + " " + network["ServiceId"]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)
運行結果:
ARC-5G wifi_48a9d2969a99_4152432d3547_managed_psk
alibaba-inc wifi_48a9d2969a99_616c69626162612d696e63_managed_ieee8021x
alibaba-guest wifi_48a9d2969a99_616c69626162612d6775657374_managed_none
ARC24G wifi_48a9d2969a99_415243323447_managed_psk
360免費WiFi-C3 wifi_48a9d2969a99_333630e5858de8b4b9576946692d4333_managed_psk
U+Net869B wifi_48a9d2969a99_552b4e657438363942_managed_psk
NAOqi Core之Extractors
Extractors模塊作為視覺和感知模塊的基類烤镐。
從ALExtractor繼承的模塊列表:
? ALCloseObjectDetection
? ALEngagementZones
? ALFaceDetection
? ALGazeAnalysis
? ALLandMarkDetection
? ALPeoplePerception
? ALRedBallDetection
? ALSittingPeopleDetection
? ALSonar
? ALVisualSpaceHistory
? ALWavingDetection
? ALVisionRecognition
從ALExtractor和ALVisionExtractor繼承的模塊列表:
? ALBacklightingDetection
? ALBarcodeReader
? ALDarknessDetection
? ALMovementDetection
? ALSegmentation3D
? ALVisualCompass
任何ALExtractor從ALModule API繼承方法,它還具有以下自己特有的方法:
參數(shù)更新
? ALExtractor::subscribe
? ALExtractor::unsubscribe
? ALExtractor::updatePeriod
? ALExtractor::updatePrecision
自我檢查
? ALExtractor::getCurrentPeriod
? ALExtractor::getCurrentPrecision
? ALExtractor::getEventList
? ALExtractor::getMemoryKeyList
? ALExtractor::getMyPeriod
? ALExtractor::getMyPrecision
? ALExtractor::getOutputNames
? ALExtractor::getSubscribersInfo
任何ALVisionExtractor繼承自ALExtractor API和ALModule API的方法棍鳖。它還具有自己特有的方法:
參數(shù)更新
? ALVisionExtractor::setFrameRate
? ALVisionExtractor::setResolution
? ALVisionExtractor::setActiveCamera
? ALVisionExtractor::pause
自我檢查
? ALVisionExtractor::getFrameRate
? ALVisionExtractor::getResolution
? ALVisionExtractor::getActiveCamera
? ALVisionExtractor::isPaused
? ALVisionExtractor::isProcessing
NAOqi Core之ALMemory
ALMemory模塊用于存儲與機器人的硬件配置相關的所有關鍵信息炮叶。
更具體地說,ALMemory提供有關執(zhí)行器和傳感器的當前狀態(tài)的信息渡处。
ALMemory是一個互斥和無序的升級map镜悉。map包含變體(ALValue)。
Mutex是讀/寫互斥體医瘫,從性能上侣肄,可以保護:
? The map
? A value
? The value history (only for events)
例如:
? Remove a data blocks all readers/writers.
? Insert an existing data only blocks the modified data.
? Read data blocks only writers of read data.
notifications由線程池(本地)或唯單獨的通知線程(遠程)管理。
事件與微型事件
事件是將他的歷史存儲到ALMemory中的MicroEvent醇份。它們基本相同稼锅,但MicroEvent更快吼具。
可以使用ALMemoryProxy :: getEventHistory訪問事件歷史記錄。
此外矩距,當某人訂閱一個活動時拗盒,模塊可以自動啟動。此功能可以使用ALMemoryProxy :: declareEvent訪問剩晴,其中包含兩個參數(shù)锣咒。
插入和獲取數(shù)據(jù)示例:
from naoqi import ALProxy
try:
# create proxy on ALMemory
memProxy = ALProxy("ALMemory","localhost",9559)
#insertData. Value can be int, float, list, string
memProxy.insertData("myValueName1", "myValue1")
#getData
print "The value of myValueName1 is", memProxy.getData("myValueName1")
except RuntimeError,e:
# catch exception
print "error insert data", e
訂閱一個事件示例:
"""
with sample of python documentation
"""
from naoqi import *
import time
check = 0
# create python module
class myModule(ALModule):
"""python class myModule test auto documentation: comment needed to create a new python module"""
def pythondatachanged(self, strVarName, value):
"""callback when data change"""
print "datachanged", strVarName, " ", value, " ", strMessage
global check
check = 1
def _pythonPrivateMethod(self, param1, param2, param3):
global check
broker = ALBroker("pythonBroker","10.0.252.184",9999,"naoverdose.local",9559)
# call method
try:
pythonModule = myModule("pythonModule")
prox = ALProxy("ALMemory")
#prox.insertData("val",1) # forbidden, data is optimized and doesn't manage callback
prox.subscribeToEvent("FaceDetected","pythonModule", "pythondatachanged") # event is case sensitive !
except Exception,e:
print "error"
print e
exit(1)
while (1):
time.sleep(2)
NAOqi Core之ALModule
ALModule可以用作用戶模塊的基類侵状,以幫助他們提供和宣傳他們的方法赞弥。
每個模塊都會將其希望向參與網(wǎng)絡的客戶端提供的方法通告給同一進程中的broker。
然后趣兄,broker透明地處理目錄服務绽左,以便客戶端不需要知道提供服務的模塊是否處于同一進程,同一臺機器上或同一tcp網(wǎng)絡上艇潭。
在同一的進程中拼窥,直接方法調用用于提供最佳速度,而無需更改方法簽名蹋凝。
任務管理
? ALModule::isRunning
? ALModule::wait
? ALModule::stop
? ALModule::exit
自我檢查
? ALModule::getBrokerName
? ALModule::getMethodList
? ALModule::getMethodHelp
? ALModule::getModuleHelp
? ALModule::getUsage
? ALModule::ping
? ALModule::version
事件列表
? ClientConnected()
? ClientDisconnected()
NAOqi Core之ALNotificationManager
ALNotificationManager模塊提供了管理機器人通知的方法鲁纠。
當應用程序發(fā)送通知時:
- 它被附加到待處理通知的列表中。
- 通知最終用戶有待處理的通知鳍寂,并可以要求機器人讀取它改含。
在以下情況下,通知將從待處理通知列表中刪除:
- 它已被讀取
- 它被應用程序刪除迄汛,例如捍壤,它不再有效。
ALValue NotificationInfo
ALValue NotificationInfo是n對(key鞍爱,value)的數(shù)組鹃觉。
為了與其他模塊交換此對象,Notification對象可以用以下結構表示為ALValue:
key | value type | default value |
---|---|---|
"id" | int | -1 |
"message" | string | "" |
"severity" | string | "info" |
"removeOnRead" | bool | true |
添加一個通知示例:
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Use add Method"""
import qi
import argparse
import sys
def main(session):
"""
This example uses the add method.
"""
# Get the service ALNotificationManager.
notif_mng_service = session.service("ALNotificationManager")
# Add a notification.
notificationId = notif_mng_service.add({"message": "Hello World!", "severity": "info", "removeOnRead": True})
print "Notification ID: " + str(notificationId)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)
打印所有通知消息的示例:
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
"""Example: Use notifications Method"""
import qi
import argparse
import sys
def main(session):
"""
This example uses the notifications method.
"""
# Get the service ALNotificationManager.
notif_mng_service = session.service("ALNotificationManager")
# Get the notifications.
notifications = notif_mng_service.notifications()
for notification in notifications:
notifDict = dict(notification)
print "Notification ID: " + str(notifDict["id"])
print "\tMessage: " + notifDict["message"]
print "\tSeverity: " + notifDict["severity"]
print "\tRemove On Read: " + str(notifDict["removeOnRead"])
print "-----------\n"
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)
NAOqi Core之ALPreferenceManager
ALPreferenceManager允許管理機器人的首選項睹逃。 機器人首選項用于存儲機器人上運行的應用程序的所有設置盗扇。
存儲
機器人首選項存儲在機器人和Aldebaran Cloud上的數(shù)據(jù)庫中; ALPreferenceManager確保不同副本之間的一致性。
格式化
一個首選項如下定義:
- 域:它可以是使用首選項設置的應用程序的名稱沉填。
- 名稱:它是設置的名稱粱玲。
- 值:目前僅支持字符串值。
例如拜轨,如果您正在開發(fā)國際象棋應用程序抽减,則可以具有以下首選項:
? Domain: “com.aldebaran.apps.chess”
? Name: “/game/level/default”
? Value: “medium”
性能與限制
存儲
在機器人上,首選項存儲在SQLite數(shù)據(jù)庫的路徑下:
/home/nao/.local/share/PreferenceManager/prefs.db
只有當機器人與Aldebaran用戶帳戶相關聯(lián)時橄碾,首選項才能同步并保存在Aldebaran Cloud中卵沉。如果沒有颠锉,首選項只會在本地存儲。
字符限制:
- 僅使用字母數(shù)字字符
- 禁止使用'\'
NAOqi Core之ALResourceManager
ALResourceManager提供了一種管理資源的方法史汗。資源可以是:電機琼掠,麥克風,LED停撞,CPU瓷蛙,剛度參數(shù),相機設置戈毒,球體...
ALResourceManager允許你:
? 避免另一種行為使用您需要的資源
? 同步運動艰猬,LED,聲音...
? 當另一個行為想要你的資源時埋市,運行特定的操作冠桃。例如,在其他行為操作行走行為之前道宅,停止現(xiàn)在的行走行為食听。
資源遵循資源層次結構。
資源管理器使用對象行為層次結構:假設你創(chuàng)造一種踢足球的行為污茵。首先樱报,機器人應該在沒有移動的情況下搜索球。如果機器人發(fā)現(xiàn)球并需要走路泞当,您需要確保在行走前有足夠的資源迹蛤。 資源管理器允許在根對象或根行為中獲取資源,所有子對象將自動將資源轉移到父級零蓉,但是子對象之間可以彼此沖突笤受。
資源管理器允許同步一組資源
您可以預留頭部電機,文字敌蜂,語音和LED箩兽,以確保同步運動紊婉,語音和LED呵俏。
這組資源的管理與一個資源完全一樣:
? 在請求期間蒙兰,丟失一個資源會釋放所有資源坚俗。
? 所有的資源等待都有超時機制。
? 請求組不能死鎖帆啃。
創(chuàng)建一個資源示例:
# create proxy on resource manager
proxy = ALProxy("ALResourceManager","localhost",9559)
#createResource in root (parent resource is "")
proxy.createResource("newResource","")
檢查資源是否可用:
#check resource is free
free = proxy.areResourcesFree(["newResource"])
等待資源變?yōu)榭捎茫ㄗ枞{用)
# take resource
# acquireResource(resource name, owner name, callback to notify you that someone want the resource, timeout)
proxy.acquireResource("newResource", "myFooModule", "", 1)
回調沖突
class MyFooModule:
def myFooCallback(self, resource, currentOwner):
#decide what to do with the ressource.
#either call releaseResource or pass
if iwanttoreleasetheresource:
releaseResource(resource, currentOwner)
# alternatively, you can specify a callback on myFooModule as third parameter that will be called in case of conflict.
proxy.acquireResource("newResource", "MyFooModule", "myFooCallback", 1)
釋放waitForResource占用的資源
#release resource
proxy.releaseResource("newResource", "myFooModule")
NAOqi Core之ALSystem
ALSystem提供可用于配置系統(tǒng)并執(zhí)行關閉或重新啟動等操作的原語俊啼。
ALSystem從ALModule API繼承方法剂陡。它還具有自己特有的方法:
class ALSystemProxy
? ALSystemProxy::robotName
? ALSystemProxy::robotIcon
? ALSystemProxy::setRobotName
? ALSystemProxy::shutdown
? ALSystemProxy::reboot
? ALSystemProxy::systemVersion
? ALSystemProxy::timezone
? ALSystemProxy::setTimezone
? ALSystemProxy::freeMemory
? ALSystemProxy::totalMemory
? ALSystemProxy::diskFree
? ALSystemProxy::previousSystemVersion
? ALSystemProxy::changePassword
? ALSystemProxy::upgrade
? ALSystemProxy::factoryReset
Event list
? ALSystem/RobotNameChanged()
NAOQI VISION
視頻與圖片管理:
USE | To ... |
---|---|
ALPhotoCapture | 拍照并將其保存在磁盤 |
ALVideoDevice | 管理視頻輸入 |
ALVideoRecorder | 記錄視頻 |
視頻檢測:
USE | To ... |
---|---|
ALBacklightingDetection | 檢查相機的圖像是否背光 |
ALBarcodeReader | 檢測并讀取圖像中的條形碼 |
ALColorBlobDetection | 檢測給定顏色的斑點(圓形或非圓形) |
ALDarknessDetection | 檢查環(huán)境是否黑暗 |
ALLandMarkDetection | 檢測具體的視覺地標 |
ALMovementDetection | 檢測一些運動摊唇,并告知它來自哪里 |
ALRedBallDetection | 檢測紅色和圓形物體 |
視覺記憶工具:
USE | To ... |
---|---|
ALVisionRecognition | 使機器人學習和識別視覺模式:對象咐蝇,圖片... |
ALVisualSpaceHistory | 構建頭部位置的帶有時間戳的地圖 |
視覺作為導航工具:
USE | To ... |
---|---|
ALLocalization | 給機器人回到一個家的能力(家:已學習) |
ALVisualCompass | 使用圖像作為指南針 |
3D傳感器相關:
USE | To ... |
---|---|
ALCloseObjectDetection | 檢測要被3D傳感器直接感知的物體 |
ALSegmentation3D | 分割由3D傳感器返回的深度圖像 |
NAOQI VISION之ALBacklightingDetection
ALBacklightingDetection提取器檢查相機返回的圖像是否背光。當光源(例如窗口)和觀察到的場景之間存在高對比度時巷查,背光打開有序。
為每個幀計算以下背光值:
? 0: no backlight
? 1: possible backlight
? 2: backlight identified
該值存儲在ALMemory中抹腿。當?shù)谝淮螜z測到背光狀況(即背光值剛剛變?yōu)?)時,會觸發(fā)事件旭寿。
為了計算背光值警绩,提取器:
分析當前幀是否超過2%的像素被裁剪(當像素傳感器接收到更多的光可以“存儲”時發(fā)生的現(xiàn)象,導致該像素的數(shù)字轉換之后的值為“255”)盅称;
檢查超過60%的像素的亮度是否低于70肩祥;
最終結果是“255”處的像素百分比和低于“70”的像素百分比的加權組合。
NAOQI VISION之ALBarcodeReader
ALBarcodeReader掃描相機中的圖像并查找條形碼缩膝。如果在圖像中找到條形碼混狠,模塊將嘗試解密它。
每當讀取QR代碼時都會觸發(fā)事件逞盆。此事件還包含代碼數(shù)據(jù)和角位置檀蹋,如圖所示松申。請注意云芦,第一個角落(標有“0”)總是與沒有黑色方塊的角落相對。剩下的角落被逆時針標記贸桶。
ALBarcodeReader目前僅適用于QR碼舅逸。可以在單個圖像中處理多條QR代碼皇筛。 由于條形碼由小元素(條形琉历,正方形)構成,所以圖像分辨率必須根據(jù)相機與代碼本身之間的距離進行設置水醋。檢測率也取決于打印的代碼質量和尺寸旗笔。
NAOQI VISION之ALCloseObjectDetection
ALCloseObjectDetection允許您檢測到距機器人太近的對象,以便3D傳感器直接檢測到拄踪。
為了出現(xiàn)在由3D傳感器返回的深度圖像中蝇恶,物體必須距離傳感器的距離最小。使用紅外圖像(也由3D傳感器返回)惶桐,可以檢測物體何時太近并計算其位置撮弧,因為這些對象將對應于紅外圖像中的飽和像素。
每次通過模塊ALCloseObjectDetection在3D傳感器的“近距離”范圍內檢測到一個對象時姚糊,將更新ALMemory鍵CloseObjectDetection / ObjectInfo贿衍,并觸發(fā)ALMemory事件CloseObjectDetection / ObjectDetected()。
存儲鍵包含有關最近對象檢測的信息救恨。組織如下:
ObjectInfo =
[
TimeStamp,
CloseObjectInfo,
CameraPose_InTorsoFrame,
CameraPose_InRobotFrame,
Camera_Id
]
TimeStamp: 該字段是用于執(zhí)行檢測的圖像的時間戳
TimeStamp [
TimeStamp_Seconds,
Timestamp_Microseconds
]
CloseObjectInfo: 這些字段中的每一個都包含檢測到的接近對象的描述
CloseObjectInfo =
[
PositionOfCog,
AngularRoi,
PixelsProportion,
]
PositionOfCog = [x贸辈,y]包含對象重心的角坐標(弧度)。
AngularRoi = [x肠槽,y擎淤,width躏哩,height]包含關于包含對象的最小矩形(ROI)的信息。 [x揉燃,y]對應于當前深度圖像中ROI的左上角的角坐標(弧度)扫尺。 [寬度,高度]對應于ROI的角度大写短馈(弧度)正驻。
PixelsProportion = [In_Frame,In_Roi]對應于屬于接近對象的像素的比例抢腐。 In_Frame是相對于幀中像素總數(shù)的比例姑曙,In_Roi是相對于對象ROI的像素數(shù)的比例。
CameraPose_InTorsoFrame:在FRAME_TORSO中描述拍攝圖像時深度相機的Position6D迈倍。
CameraPose_InRobotFrame:在FRAME_ROBOT中描述拍攝圖像時深度相機的Position6D伤靠。
Camera_Id:給出用于檢測的相機的ID,即深度相機啼染。
注釋:
ROI(region of interest)宴合,感興趣區(qū)域。機器視覺迹鹅、圖像處理中卦洽,從被處理的圖像以方框、圓斜棚、橢圓阀蒂、不規(guī)則多邊形等方式勾勒出需要處理的區(qū)域,稱為感興趣區(qū)域弟蚀。
NAOQI VISION之ALColorBlobDetection
ALColorBlobDetection是一個提供快速2D視覺彩色斑點檢測器的模塊蚤霞。
ALColorBlobDetection基于快速搜索給定顏色的一組像素(在一定閾值內)∫宥ぃ可以選擇顏色和它的threhsold昧绣,也可以定義對象跨度及其最小尺寸。
NAOQI VISION之ALDarknessDetection
ALDarknessDetection可以檢查機器人是否處于黑暗環(huán)境中断医。 為相機返回的每個幀計算一個暗度值滞乙。該值存儲在ALMemory中。當機器人首次檢測到其周圍的環(huán)境較暗(即鉴嗤,暗度值大于閾值)時斩启,會觸發(fā)事件。
該功能首先計算對應于機器人周圍環(huán)境的照明條件的0到100之間的值:
0:亮環(huán)境
100:暗環(huán)境
然后將該值與黑暗閾值進行比較:
如果它小于閾值醉锅,周圍環(huán)境不被認為是黑暗的兔簇。
如果它大于閾值,則周圍環(huán)境被認為是黑暗的。
黑暗閾值可以使用ALDarknessDetectionProxy :: getDarknessThreshold函數(shù)訪問垄琐。它的默認值為60边酒,但可以使用ALDarknessDetectionProxy :: setDarknessThreshold函數(shù)進行更改。
性能與限制
必須激活相機的相機AutoExposition參數(shù)才能正常工作狸窘。
NAOQI VISION之ALLandMarkDetection
ALLandMarkDetection是一個視覺模塊墩朦,其中機器人識別具有特定模式的特殊地標。我們把這些地標稱為Naomarks翻擒。
您可以使用ALLandMarkDetection模塊進行各種應用氓涣。例如,您可以將這些地標放置在機器人操作區(qū)域的不同位置陋气。根據(jù)機器人檢測到哪個地標劳吠,您可以獲取有關機器人位置的一些信息。與其他傳感器信息相結合巩趁,可以幫助您構建更強大的本地化模塊痒玩。
NaoMarks包括以圓圈為中心的白色三角形粉絲的黑色圓圈。不同三角形風扇的具體位置用于區(qū)分不同的Naomark议慰。
性能與限制
光照:地標檢測已經在辦公室照明條件下測試通過蠢古,即低于100到500 lux。由于檢測本身依賴于對比度差異褒脯,所以只要輸入圖像中的標記對比度高一些便瑟,實際表現(xiàn)會好一些缆毁。
檢測到的標記的尺寸范圍:
最小值:?0.035 rad = 2 deg它對應于QVGA圖像中的?14像素
最大值:?0.40 rad = 23度它對應于QVGA圖像中?160個像素
傾斜:+/- 60度(0度對應于面向相機的標記)
圖像平面中的旋轉:不變番川。
使用監(jiān)視器查看檢測結果:
了解ALLandMarkDetection可以做什么,您可以使用Monitor并啟動視覺插件脊框。激活LandMarkDetection復選框并開始攝像颁督。然后,如果您將Naomark放置在攝像機的視野中浇雹,Monitor應通過在視頻輸出窗格中盤點來報告檢測到的Naomarks沉御。此外,Naomark標識符顯示在圓圈旁邊昭灵,應該與真實的Naomark標識符相對應吠裆。
開始檢測:
要啟動Naomark檢測功能,請使用ALLandMarkDetection代理訂閱ALLandMarkDetection烂完。在Python中试疙,此訂閱的代碼是:
from naoqi import ALProxy
IP = "your_robot_ip"
PORT = 9559
# Create a proxy to ALLandMarkDetection
markProxy = ALproxy("ALLandMarkDetection", IP, PORT)
# Subscribe to the ALLandMarkDetection extractor
period = 500
markProxy.subscribe("Test_Mark", period, 0.0 )
period參數(shù)指定(以毫秒為單位)ALLandMarkDetection嘗試運行其檢測方法的頻率,并將結果輸出到名為LandmarkDetected的ALMemory輸出變量中抠蚣。
至少對ALLandMarkDetection模塊訂閱一次祝旷,ALLandMarkDetection才能開始運行。
獲取結果:
ALLandMarkDetection模塊將其結果寫入ALMemory(LandmarkDetected)中的變量。 您確定要直接在代碼中使用檢測結果怀跛,您可以定期檢查ALMemory的變量距贷。
為此,只需創(chuàng)建一個代理到ALMemory吻谋,并從ALMemory代理中使用getData(“LandmarkDetected”)檢索Landmark變量忠蝗。
變量結果解析:
如果沒有檢測到Naomarks,變量為空漓拾。它是一個零元素的陣列(即在python中打印為[])什湘。
如果檢測到N Naomarks,則可變結構由兩個字段組成: [[TimeStampField] [Mark_info_0晦攒,Mark_info_1闽撤,。 脯颜。 哟旗。 ,Mark_info_N-1]]
TimeStampField = [TimeStamp_seconds栋操,Timestamp_microseconds]闸餐。該字段是用于執(zhí)行檢測的圖像的時間戳。
Mark_info = [ShapeInfo矾芙,ExtraInfo]舍沙。對于每個檢測到的標記,我們有一個Mark_info字段剔宪。 ShapeInfo = [1拂铡,alpha,beta葱绒,sizeX感帅,sizeY,heading]地淀。 alpha和beta表示Naomark在相機角度方面的位置失球;sizeX和sizeY是相機角度的標記尺寸;heading角度描述了關于機器人頭部的Naomark是如何面向垂直軸的帮毁。
ExtraInfo = [MarkID]实苞。標記ID是寫在Naomark上的數(shù)字,對應于其圖案烈疚。
NAOQI VISION之ALMovementDetection
ALMovementDetection允許您檢測Aldebaran機器人的視野中的移動黔牵。
Aldebaran機器人使用3D相機(如果有的話),否則它們使用RGB相機胞得。
以定期的間隔收集幀荧止,并將每個新幀與前一幀進行比較屹电。差異高于閾值的像素被標識為“移動像素”。然后所有的“移動像素”都使用它們的物理接近度和它們的值差異進行聚類跃巡。
對于沒有3d相機的Aldebaran機器人危号,可以使用以下方式更改閾值: - ALMovementDetectionProxy :: setColorSensitivity
對于具有3d相機的Aldebaran機器人,可以使用以下方式更改閾值: - ALMovementDetectionProxy :: setDepthSensitivity
ALMemory KEY
每次檢測到一些移動時素邪,ALMemory鍵的MoveDetection / MovementInfo被更新外莲,并且觸發(fā)了一個ALMemory事件MoveDetection / MovementDetected。
存儲鍵包含有關“移動”像素的不同簇的信息兔朦。它的組織如下:
MovementInfo =
[
TimeStamp,
[ClusterInfo_1, ClusterInfo_2, ... ClusterInfo_n],
CameraPose_InTorsoFrame,
CameraPose_InRobotFrame,
Camera_Id
]
Timestamp:該字段是用于執(zhí)行檢測的圖像的時間戳偷线。
TimeStamp [
TimeStamp_Seconds,
Timestamp_Microseconds
]
這些字段中的每一個都包含“移動”集群的描述。它具有以下結構沽甥,具體取決于相機的類型:
RGB Camera
ClusterInfo_i(RGB) =
[
PositionOfCog,
AngularRoi,
ProportionMovingPixels,
]
Depth Camera
ClusterInfo_i(Depth) =
[
PositionOfCog,
AngularRoi,
ProportionMovingPixels,
MeanDistance,
RealSizeRoi,
PositionOfAssociatedPoint
]
All cameras:
? PositionOfCog = [x,y] 包含相對于相機中心的集群重心的角坐標(弧度)声邦。
? AngularRoi = [x,y,width, height] 包含關于包含集群的最小矩形(ROI)的信息。 [x摆舟,y]對應于當前深度圖像中ROI的左上角的角坐標(弧度)亥曹。 [寬度,高度]對應于ROI的角度大泻抻铡(弧度)媳瞪。
? ProportionMovingPixels = [In_Frame, In_Roi] 對應于“移動”像素的比例。 In_Frame是相對于幀中像素總數(shù)的比例照宝,In_Roi是相對于群集ROI的像素數(shù)的比例蛇受。
Depth camera only:
? MeanDistance 是相對于深度相機(僅用于3D檢測)的聚類點的平均距離。
? RealSizeRoi = [realwidth厕鹃,realheight]給出了集群ROI的實際大芯ぱ觥(以米計)(僅用于3D檢測)。
? [X熊响,Y]旨别。使用初始深度圖像的分割(參見模塊ALSegmentation3D的描述),可以提取移動的斑點汗茄。然后可以通過從其重心向上移動來找到該斑點的頂點像素。 [x铭若,y]是該像素的角坐標(弧度)洪碳。例如,這些坐標可以非常有用地觀察剛剛移動的人的頭部叼屠,而不是觀察運動的重心(僅用于3D檢測)瞳腌。
CameraPose_InTorsoFrame: 在FRAME_TORSO中描述拍攝圖像時相機的Position6D。
CameraPose_InRobotFrame: 在FRAME_ROBOT中描述拍攝圖像時相機的Position6D镜雨。
Camera_Id: 給出用于檢測的相機的ID嫂侍。