dslclib.src.body_controller module#
- class dslclib.src.body_controller.BodyController(ip: str | None = None, port: int = 21000)#
ベースクラス:
dslclib.src.base.BaseClient
Ericaの身体をコントロールするクライアント. ソケットにコマンドを送ることでEricaを動かす.
- パラメータ:
ip (str, optional) --
ipアドレス.
デフォルトはNoneであり,Noneが与えられた時,127.0.0.1(ローカルホスト)を指定し, もし,docker内でこのモジュールが立ち上がっていた場合,自動でそれが認識され,host.docker.internalを指定する.
host.docker.internalは,docker内からローカルホストのポートに接続するために必要である.
port (int = 21000) -- ソケット通信を行うポート.
サンプル
>>> client = BodyController() ipがNoneだったため、127.0.0.1をipアドレスとして設定します。 >>> client Socket( ip = 127.0.0.1 port = 21000 ) >>>
- _create_command(controller: str, obj: str, direction: tuple[float, float, float]) str #
- gaze(obj: str | None = None, direction: tuple[float, float, float] | None = None, eye: tuple[float, float, float] | None = None, head: tuple[float, float, float] | None = None) None #
Ericaの目線または顔の向きを指示するメソッド. GazeObject,GazeDirectionを用いることで,簡単に指示を行うことができる.
obj, direction, eye, headのいずれかは引数として入力しなければならない.
目線と顔の向きの両方を,同じ向きに動かす場合はdirectionに座標を与える.
目線のみならばeye,顔の向きのみならばheadに座標を与える.
また,目線と顔の向きを動かすが,別の座標をそれぞれ指示したい場合は,eyeとheadにそれぞれ座標を与える.
- パラメータ:
obj (str, optional) -- 見るオブジェクトの名前.指定したオブジェクトの方向に目線と顔を向ける. ここではデータクラスGazeObjectを用いることができる. 直接文字列を与えることも可能.
direction (tuple, optional) -- 指定した座標に対して目線と顔を向ける. ここではデータクラスGazeDirectionを用いることができる. 直接座標をタプルで与えることも可能.
eye (tuple, optional) -- 指定した座標に対して目線のみを向ける. ここではデータクラスGazeDirectionを用いることができる. 直接座標をタプルで与えることも可能.
head (tuple, optional) -- 指定した座標に対して顔のみを向ける. ここではデータクラスGazeDirectionを用いることができる. 直接座標をタプルで与えることも可能.
サンプル
>>> client.gaze(obj=GazeObject.Sofa) >>> client.gaze(direction=GazeDirection.Right) # 目線と顔の向きを右に >>> client.gaze(eye=GazeDirection.Right) # 目線のみを右に >>> client.gaze(eye=GazeDirection.Right, head=(0.0, 1.0, 2.0)) # 目線と顔の向きを別にできる.また,座標を直接与えられる. >>> client.gaze() # 何も引数を与えないとエラー ValueError("いずれかの引数に正しい引数を入力してください。")
- play_motion(motion: str) None #
モーション名に対応するモーションをEricaに指示するメソッド
- パラメータ:
motion (str) -- モーション名.MotionTypeのデータクラスを使うことで,簡単に指示を行うことができる. MotionTypeでサポートしていないモーション名もたくさんあり,これらはCGEricaの画面左上で確認することができる. より詳細なモーションを指示したい場合は,直接strを引数に与えること.
サンプル
>>> client.play_motion(MotionType.Greeting) >>> client.play_motion(motion=MotionType.Greeting) >>> client.play_motion("greeting") >>>
- class dslclib.src.body_controller.ControllerType(Eye: Literal['EyeController'] = 'EyeController', Head: Literal['HeadController'] = 'HeadController')#
ベースクラス:
object
Ericaのどの部分をコントロールするかを指定するデータクラス. ControllerType()とインスタンス化する必要はない.
EyeControllerはEricaの目線のコントロールを指定し,HeadControllerはEricaの頭の向きのコントロールを指定する. 指定する文字列が長いため,このデータクラスを使うことを推奨する.
サンプル
>>> ControllerType.Eye EyeController >>> ControllerType.Head HeadController
- Eye: Literal['EyeController'] = 'EyeController'#
- Head: Literal['HeadController'] = 'HeadController'#
- class dslclib.src.body_controller.GazeDirection(Front: tuple[float, float, float] = (0.0, 1.2, 1.5), Right: tuple[float, float, float] = (1.0, 1.2, 1.5), Left: tuple[float, float, float] = (-1.0, 1.2, 1.5))#
ベースクラス:
object
Ericaの目線の方向を事前定義したデータクラス. GazeDirection()とインスタンス化する必要はない.
FrontとRightとLeftを用意している. この3方向以外の向きを指定する場合,BodyController.gazeに直接数値を入力することができる.
サンプル
>>> GazeDirection.Front (0.0, 1.2, 1.5) >>> GazeDirection.Right (1.0, 1.2, 1.5) >>> GazeDirection.Left (-1.0, 1.2, 1.5)
- Front: tuple[float, float, float] = (0.0, 1.2, 1.5)#
- Left: tuple[float, float, float] = (-1.0, 1.2, 1.5)#
- Right: tuple[float, float, float] = (1.0, 1.2, 1.5)#
- class dslclib.src.body_controller.GazeObject(Monitor: Literal['monitor'] = 'monitor', Desk: Literal['desk'] = 'desk', Sofa: Literal['Sofa'] = 'Sofa')#
ベースクラス:
object
Ericaの目線の対象を事前定義したデータクラス. GazeObject()とインスタンス化する必要はない.
Desk,Monitor,Sofaを用意している.
サンプル
>>> GazeObject.Monitor monitor >>> GazeObject.Desk desk >>> GazeObject.Sofa Sofa
- Desk: Literal['desk'] = 'desk'#
- Monitor: Literal['monitor'] = 'monitor'#
- Sofa: Literal['Sofa'] = 'Sofa'#
- class dslclib.src.body_controller.MotionType(Default: Literal['DefaultMotion'] = 'DefaultMotion', Greeting: Literal['greeting'] = 'greeting', Nono: Literal['nono'] = 'nono', NodDeep: Literal['nod_deep'] = 'nod_deep', Nod: Literal['nod'] = 'nod', RightHandBasePosition: Literal['righthandbaseposition'] = 'righthandbaseposition', LeftHandBasePositin: Literal['lefthandbaseposition'] = 'lefthandbaseposition')#
ベースクラス:
object
MotinonType Ericaのモーションの命令を一部事前定義している. MotionType()とインスタンス化する必要はない.
ここでは,Default, Greeting, Nono, NodDeep, Nod, RightHandBasePosition, LeftHandBasePositionを用意している.
以下のプロパティ以外は、Erica@CGのMotionを参照されたい. CGEricaの画面の左上のウィンドウに全てのモーションの命令が書かれている.
サンプル
>>> MotionType.Default DefaultMotion >>> MotionType.Nod nod >>> MotionType.RightHandBasePosition righthandbaseposition
- Default: Literal['DefaultMotion'] = 'DefaultMotion'#
- Greeting: Literal['greeting'] = 'greeting'#
- LeftHandBasePositin: Literal['lefthandbaseposition'] = 'lefthandbaseposition'#
- Nod: Literal['nod'] = 'nod'#
- NodDeep: Literal['nod_deep'] = 'nod_deep'#
- Nono: Literal['nono'] = 'nono'#
- RightHandBasePosition: Literal['righthandbaseposition'] = 'righthandbaseposition'#