# Server-Class Install ## 必要なファイル (尾原件が作成したソースコード) 1. [x_logger](https://github.com/ohara-lab-su/x_logger.git): ログファイル管理 2. [ese774_frame](https://github.com/ohara-lab-su/ese774_frame.git): コボッタ制御サーバーとの通信するためのフレームワーク(似非774版) 3. [cobotta2](https://github.com/ohara-lab-su/cobotta2.git): ORiN2 を用いたコボッタ制御サーバープログラム 4. [cobotta2_client](https://github.com/shimane-dev/cobotta2_client.git): コボッタサーバーと通信して、コボッタを制御するプログラムサンプル集 5. [cobotta_joypad](https://github.com/ohara-lab-su/cobotta2_joypad.git): JoyPad を用いてcobotta制御 (gRPCを用いた高速通信用) ## x_logger - [x_logger](https://github.com/ohara-lab-su/x_logger.git): ログファイル管理 x_logger.zip 解凍後。解凍ディレクトリに移動し ``` pip install x_logger ``` ## ese774_frame - [ese774_frame](https://github.com/ohara-lab-su/ese774_frame.git): コボッタ制御サーバーとの通信するためのフレームワーク(似非774版) fastapi_frame.zip 解凍後。解凍ディレクトリに移動し ``` pip install ese774_frame ``` ## cbotta2 - [cobotta2](https://github.com/ohara-lab-su/cobotta2.git): ORiN2 を用いたコボッタ制御サーバープログラム cobotta2制御プログラム ``` pip install cobotta2 ``` ## server 起動 (pythonからの直接起動) ```python #!/usr/bin/env python from cobotta2.config import Config from cobotta2.cobotta_ctrl_state import CobottaState from cobotta2.server_fastapi import CobottaRouterState from cobotta2.server_fastapi import cobotta_state_api_spec from ese774_frame.api_server import FastApiServer from x_logger.x_logger import XLogger if __name__ == "__main__": Config.load_yaml("config_cobotta2_state.yaml") logger = XLogger( log_level="debug", logger_name=Config.SERVER_LOGGER_NAME, log_mode="rotate", # log_mode="file", log_name=f"c:/opt/log/{Config.SERVER_LOGGER_NAME}.log", ) logger.info(f"COBOTTA IP = {Config.COBOTTA_IP}") logger.info(f"SERVER IP = {Config.SERVER_IP}") logger.info(f"SERVER PORT = {Config.SERVER_PORT}") server = FastApiServer( device_cls=CobottaState, # 制御クラス router_cls=CobottaRouterState, # 継承でつくった router config=Config, api_spec=cobotta_state_api_spec, device_kwargs={ "cobotta_ip": Config.COBOTTA_IP }, # COBOTTA制御Classのコンストラクタ引数) logger=logger, logger_name=Config.SERVER_LOGGER_NAME, lifespan_msg_prefix="COBOTTA", ) server.run(host=Config.SERVER_IP, port=Config.SERVER_PORT) ``` ### ローカルクライアントでのテスト ### fastapi での通信テスト ## サーバーログディレクトリ作成とサービス用フォルダ作成 - サーバーログ保存の場所作成 - サーバープログラム起動場所の作成 ## windows のサービスとして python の cobotta-server 起動を登録する ## windows のサービスとして python の aandd-server 起動を登録する --- ## 作者 - Kengo NAKADA