SPIKE-RT C API Reference [Japanese]
An RTOS-based software platform for LEGO® Education SPIKE™.
|
モータのAPI. [詳解]
型定義 | |
typedef pbio_servo_t | pup_motor_t |
列挙型 | |
enum | pup_direction_t { PUP_DIRECTION_CLOCKWISE = PBIO_DIRECTION_CLOCKWISE , PUP_DIRECTION_COUNTERCLOCKWISE = PBIO_DIRECTION_COUNTERCLOCKWISE } |
関数 | |
pup_motor_t * | pup_motor_get_device (pbio_port_id_t port) |
ポートIDで指定されたモータへのPUPモータデバイスポインタを取得する. [詳解] | |
pbio_error_t | pup_motor_setup (pup_motor_t *motor, pup_direction_t positive_direction, bool reset_count) |
モータを初期化する. [詳解] | |
pbio_error_t | pup_motor_reset_count (pup_motor_t *motor) |
エンコーダをリセットする. [詳解] | |
int32_t | pup_motor_get_count (pup_motor_t *motor) |
エンコーダの値を取得する. [詳解] | |
int32_t | pup_motor_get_speed (pup_motor_t *motor) |
モータの回転速度を取得する. [詳解] | |
pbio_error_t | pup_motor_set_speed (pup_motor_t *motor, int speed) |
モータの回転速度を設定する. [詳解] | |
int32_t | pup_motor_get_power (pup_motor_t *motor) |
モータのパワー値を取得する. [詳解] | |
pbio_error_t | pup_motor_set_power (pup_motor_t *motor, int power) |
モータのパワー値を設定する. [詳解] | |
pbio_error_t | pup_motor_stop (pup_motor_t *motor) |
モータを止める. [詳解] | |
pbio_error_t | pup_motor_brake (pup_motor_t *motor) |
ブレーキをかけてモータを止める. [詳解] | |
pbio_error_t | pup_motor_hold (pup_motor_t *motor) |
モータを止めて角度を維持する. [詳解] | |
bool | pup_motor_is_stalled (pup_motor_t *motor) |
モータがストールしているか調べる. \detail モータを動かす前にpup_motor_set_duty_limitを呼んで最大トルクを下げておくと感度を調整することができる. [詳解] | |
int32_t | pup_motor_set_duty_limit (pup_motor_t *motor, int duty_limit) |
モータのデューティ値を下げる. \detail 元の状態に戻すにはこの関数の戻り値を使ってpup_motor_restore_duty_limitを呼ぶ.. [詳解] | |
void | pup_motor_restore_duty_limit (pup_motor_t *motor, int old_value) |
モータのデューティ値を元に戻す.. [詳解] | |
モータのAPI.
pbio_error_t pup_motor_brake | ( | pup_motor_t * | motor | ) |
ブレーキをかけてモータを止める.
motor | PUPモータデバイスポインタ. |
int32_t pup_motor_get_count | ( | pup_motor_t * | motor | ) |
エンコーダの値を取得する.
motor | PUPモータデバイスポインタ. |
pup_motor_t * pup_motor_get_device | ( | pbio_port_id_t | port | ) |
ポートIDで指定されたモータへのPUPモータデバイスポインタを取得する.
失敗した場合,エラーログを出力し,NULLを返す.
port | PUPポートID. |
int32_t pup_motor_get_power | ( | pup_motor_t * | motor | ) |
モータのパワー値を取得する.
motor | PUPモータデバイスポインタ. |
int32_t pup_motor_get_speed | ( | pup_motor_t * | motor | ) |
モータの回転速度を取得する.
motor | PUPモータデバイスポインタ. |
pbio_error_t pup_motor_hold | ( | pup_motor_t * | motor | ) |
モータを止めて角度を維持する.
motor | PUPモータデバイスポインタ. |
bool pup_motor_is_stalled | ( | pup_motor_t * | motor | ) |
モータがストールしているか調べる. \detail モータを動かす前にpup_motor_set_duty_limitを呼んで最大トルクを下げておくと感度を調整することができる.
motor | PUPモータデバイスポインタ. |
pbio_error_t pup_motor_reset_count | ( | pup_motor_t * | motor | ) |
エンコーダをリセットする.
motor | PUPモータデバイスポインタ. |
void pup_motor_restore_duty_limit | ( | pup_motor_t * | motor, |
int | old_value | ||
) |
モータのデューティ値を元に戻す..
motor | PUPモータデバイスポインタ. |
old_value | pup_motor_set_duty_limitの戻り値. |
int32_t pup_motor_set_duty_limit | ( | pup_motor_t * | motor, |
int | duty_limit | ||
) |
モータのデューティ値を下げる. \detail 元の状態に戻すにはこの関数の戻り値を使ってpup_motor_restore_duty_limitを呼ぶ..
motor | PUPモータデバイスポインタ. |
duty_limit | 新しいデューティ値(0-100) |
pbio_error_t pup_motor_set_power | ( | pup_motor_t * | motor, |
int | power | ||
) |
モータのパワー値を設定する.
motor | PUPモータデバイスポインタ. |
power | モータのパワー値(-100 ~ +100). |
pbio_error_t pup_motor_set_speed | ( | pup_motor_t * | motor, |
int | speed | ||
) |
モータの回転速度を設定する.
motor | PUPモータデバイスポインタ. |
speed | モータの回転速度 [°/秒]. |
pbio_error_t pup_motor_setup | ( | pup_motor_t * | motor, |
pup_direction_t | positive_direction, | ||
bool | reset_count | ||
) |
モータを初期化する.
PBIO_ERROR_AGAINが返ってき場合は時間をおいてもう一度この関数を呼ぶこと.その他のエラーで失敗した場合は エラーログに出力する.
motor | PUPモータデバイスポインタ. |
positive_direction | モータの正回転方向をPUP_DIRECTION_CLOCKWISEまたはPUP_DIRECTION_COUNTERCLOCKWISEで示す. |
reset_count | trueかfalseでエンコーダの値をリセットするか示す. |
pbio_error_t pup_motor_stop | ( | pup_motor_t * | motor | ) |
モータを止める.
motor | PUPモータデバイスポインタ. |