アンオフィシャル - Aldebaran Robotics NAO とそのほかロボットについて

NAO とそのほかロボットについての情報を発信。ここの情報はアルデバラン非公式です。内容に誤りがあった場合はごめんなさい。

Aldebaran Robotics 社の NAO、そのほかロボットに関連する情報を発信します。

Pepper 狭いところを通れるように

Pepper はレーザーセンサー、3D深度センサーなどで周囲を確認、移動中ぶつかりそうになると自動停止します。
この限界距離 40センチですが、この距離が原因で狭い場所を通れない場合があります。
解決方法の一つはこの限界距離を短くするということ。こんな感じの Python ボックスを作ってあげることで簡単に変えることができます。

class MyClass(GeneratedClass):
    def __init__(self):
        GeneratedClass.__init__(self)
        self.initialized = False

    def _resetTheSecurityDistance(self):
        if self.initialized :
            self.logger.info("セキュリティー距離を元にもどします")
            self.motion.setOrthogonalSecurityDistance(self.od)
            self.motion.setTangentialSecurityDistance(self.td)


    def onLoad(self):
        self.motion = ALProxy("ALMotion")
        self.od = self.motion.getOrthogonalSecurityDistance()
        self.td = self.motion.getTangentialSecurityDistance()
        self.initialized = True

    def onUnload(self):
        self.logger.info("Unloading script box")
        #put clean-up code here
        self._resetTheSecurityDistance()

    def onInput_onStart(self):
        msg = "変更前:直行安全距離 %.2f  接線安全距離 %.2f" % (self.od,self.td)
        self.logger.info(msg)

        self.motion.setOrthogonalSecurityDistance(float(self.getParameter("Orthogonal Security Distance")))
        self.motion.setTangentialSecurityDistance(float(self.getParameter("Tangental Security Distance")))

        newod = self.motion.getOrthogonalSecurityDistance()
        newtd = self.motion.getTangentialSecurityDistance()
        msg = "変更後:直行安全距離 %.2f  接線安全距離 %.2f" % (newod,newtd)
        self.logger.info(msg)

        self.ready()


    def onInput_onStop(self):
        self._resetTheSecurityDistance()
        self.onStopped() #activate the output of the box

ボックスには 「Orthogonal Security Distance」、と「Tangental Security Distance」というパラメータを持たせます。
ボックスへのパラメータの追加の仕方は
http://tkawata.hatenablog.com/entries/2015/04/02
を参考に。
「Orthogonal Security Distance」は前方の障害物までの距離でデフォルト 0.4、「Tangental Security Distance」は周辺の障害物までの距離でデフォルト 0.1。
なお、上記ボックスはアンロードされる時に元の設定値に距離を戻すようにしています。