LoginSignup
14
14

More than 3 years have passed since last update.

Pepperが疲れる前に休憩するボックスを作ったよ

Last updated at Posted at 2016-01-15

アプリの連続再生や開発時にアニメーションを作ってる途中にモーターが熱を持ってしまって途中で開発が止まってしまう事があるので、疲れてしまう前に勝手に休憩してくれるボックスを作りました。
アプリのInitやMainに入れておくと再生中に熱を持ってしまっても途中で止まる事なく、熱を持ったパーツだけ勝手に休憩して熱が冷めたらまた動き出す感じにしてみます。

使ったAPI

ALMotionProxy

使ったMethod

getIdlePostureEnabled(const std::string& pChainName)
setIdlePostureEnabled(const std::string& pChainName, const bool& pEnable)

変数

  • Monitor cycle (s)
    タイマーで一定の間隔でモーターの温度をチェックします。
    1秒〜5000秒間隔まで指定出来ます。
  • Motion stop temperature(or more)
    ここで指定した温度になったらPepperが休憩します。
    40度〜70度まで設定出来ます。休憩から戻る時はこの温度未満の値になった時となります。 スクリーンショット 2016-01-15 14.36.47.png

仕組み

管理・監視系のボックスに入れて、この機能を止めたい時はイベントを発火させて止めます。
スクリーンショット 2016-01-15 14.47.24.png

Example.py
    def onLoad(self):
        self.timer = None
        self.memory = ALProxy("ALMemory")
        self.motion = ALProxy("ALMotion")
        self.parts = ["Head", "LArm", "RArm", "Legs"]

    def onTimer(self):
        partList = []
        tempList = []
        partCount = { "Head":False, "LArm":False, "RArm":False, "Legs":False }
        sNameList = ["HeadPitch", "HeadYaw", "LElbowRoll", "LElbowYaw", "LHand", "LShoulderPitch", "LShoulderRoll", "LWristYaw", "RElbowRoll", "RElbowYaw", "RHand", "RShoulderPitch", "RShoulderRoll", "RWristYaw", "KneePitch", "HipRoll", "HipPitch"]

        for sName in sNameList:
            sKeyName = "Device/SubDeviceList/%s/Temperature/Sensor/Value" % sName
            try:
                partList.append(sName)
                tempList.append(int( self.memory.getData(sKeyName) ))
            except:
                self.logger.error("No temperature found for this hardware: " + str(sName))

        for pName in partList:
            if ( "Head" in pName ):
                act = "Head"
            elif ( "LElbow" in pName or "LHand" in pName or "LShoulder" in pName or "LWrist" in pName ):
                act = "LArm"
            elif ( "RElbow" in pName or "RHand" in pName or "RShoulder" in pName or "RWrist" in pName ):
                act = "RArm"
            elif ( "Ankle" in pName or "Hip" in pName or "Knee"):
                act = "Legs"

            i = tempList[partList.index(pName)]

            if i >= int(self.getParameter("Motion stop temperature(or more)")):
                if partCount[act] == False:
                   partCount[act] = True

        for part in self.parts:
            if partCount[part] and self.motion.getIdlePostureEnabled(part) == False:
                self.logger.warn("%s Motion Stopped" % part)
                self.motion.setIdlePostureEnabled(part, True)
            elif partCount[part] == False and self.motion.getIdlePostureEnabled(part):
                self.logger.info("%s Motion Start" % part)
                self.motion.setIdlePostureEnabled(part, False)

最後に

ソース汚いですが、許してください。

サンプル

ロボットスタートさんのロボットライブラリ
https://robo-lib.com/repositories/summary/49

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14