MIRSMG5 管理台帳へ戻る

名称 RaspberryPi ソフトウェア 関数レファレンス(カメラなし版)<
番号 MIRSMG5D-SOFT-0012
版数 最終更新日 作成 承認 改訂記事
A01 2026.10.27 牛丸真司 小谷進 初版

はじめに

本ドキュメントは、MIRSMG5D-SOFT-0006 RaspberryPi ソフトウェア 関数レファレンス からカメラ、サーバ通信、自己位置認識の関係のモジュールを取り除いたものである。

Raspberry Pi関数レファレンス


io.c

GPIO読み取りモジュール

int io_open()

GPIOをオープンし、各種デバイスに使用するピンの設定を行う
戻り値0(成功) or それ以外(失敗)

void io_get_sw(int *sw_f, int *sw_l, int *sw_r)

タッチスイッチの状態を取得する
sw_f前スイッチの測定値(LOW or HIGH)
sw_l左スイッチの測定値(LOW or HIGH)
sw_r右スイッチの測定値(LOW or HIGH)

uss.c

超音波センサ読み取りモジュール

int uss_open_l()

左の超音波センサをオープンする
戻り値0(成功) or それ以外(失敗)

int uss_open_r()

右の超音波センサをオープンする
戻り値0(成功) or それ以外(失敗)

long uss_get_l()

左の超音波センサの測定値を取得する
戻り値測定値[cm] (不正な値を得た場合は-1)

long uss_get_r()

右の超音波センサの測定値を取得する
戻り値測定値[cm] (不正な値を得た場合は-1)

arduino.c

Arduinoとシリアル通信を行うモジュール

int arduino_open()

シリアル通信を開始する
戻り値0(成功) or それ以外(失敗)

void arduino_close()

シリアル通信を終了する

void arduino_clear()

Arduinoからの受信バッファをクリアする

int arduino_read(serial_data_t *serial_data)

シリアル通信で受信したデータをserial_data_t型で取得する
serial_data受信データ
戻り値0(成功) or それ以外(失敗)

void arduino_write(serial_data_t serial_data)

serial_data_t型のデータをシリアル通信で送信する
serial_data送信データ

int arduino_receive(command_data_t *command_data)

シリアル通信で受信したデータをcommand_data_t型で取得する
command_data受信データ
戻り値0(成功) or それ以外(失敗)

void arduino_send(command_data_t command_data)

serial_data_t型のデータをシリアル通信で送信する
command_data送信データ

middle_data_t arduino_decode1(serial_data_t serial_data)

serial_data_t型のデータをmiddle_data_t型に変換する
serial_data入力データ
戻り値出力データ

command_data_t arduino_decode2(middle_data_t middle_data)

middle_data_t型のデータをcommand_data_t型に変換する
middle_data入力データ
戻り値出力データ

serial_data_t arduino_encode1(middle_data_t middle_data)

middle_data_t型のデータをserial_data_t型に変換する
middle_data入力データ
戻り値出力データ

middle_data_t arduino_encode2(command_data_t command_data)

command_data_t型のデータをmiddle_data_t型に変換する
command_data入力データ
戻り値出力データ

request.c

Arduinoへ命令を送るモジュール

void request_set_runmode(run_state_t state, int speed, int dist)

Arduinoへ走行モードと速度・距離指令値を与える
state走行モード
speed直進速度[cm/s] or 回転速度[deg/s]
dist直進距離[cm] or 回転角度[deg]

int request_get_runmode(run_state_t *state, int *speed, int *dist)

Arduinoから現在の走行モードと速度・距離を取得する
state走行モード
speed直進速度[cm/s] or 回転速度[deg/s]
dist直進距離[cm] or 回転角度[deg]
戻り値0(成功) or それ以外(失敗)

int request_get_dist(int *dist_l, int *dist_r)

Arduinoから左右のタイヤの走行距離を取得する
dist_l左タイヤ走行距離[cm]
dist_r右タイヤ走行距離[cm]
戻り値0(成功) or それ以外(失敗)

int request_get_batt(double *volt)

Arduinoからバッテリ電圧を取得する
volt電圧[V]
戻り値0(成功) or それ以外(失敗)

direction.c

正対補正モジュール

int dirrection_correct(int dist)

正対補正を実行する
dist正対補正距離[cm]
戻り値0(成功) or それ以外(失敗)