SPIKE-RT C API Reference [Japanese]
An RTOS-based software platform for LEGO® Education SPIKE™.
読み取り中…
検索中…
一致する文字列を見つけられません
motor.h
[詳解]
1// SPDX-License-Identifier: MIT
2/*
3 * API for motors
4 *
5 * Copyright (c) 2022 Embedded and Real-Time Systems Laboratory,
6 * Graduate School of Information Science, Nagoya Univ., JAPAN
7 */
8
32#ifndef _PUP_MOTOR_H_
33#define _PUP_MOTOR_H_
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include <pbio/port.h>
40#include <pbio/servo.h>
41
42typedef pbio_servo_t pup_motor_t;
43typedef enum {
44 PUP_DIRECTION_CLOCKWISE = PBIO_DIRECTION_CLOCKWISE,
45 PUP_DIRECTION_COUNTERCLOCKWISE = PBIO_DIRECTION_COUNTERCLOCKWISE,
46} pup_direction_t;
47
61pup_motor_t *pup_motor_get_device(pbio_port_id_t port);
62
84pbio_error_t pup_motor_setup(pup_motor_t *motor, pup_direction_t positive_direction, bool reset_count);
85
97pbio_error_t pup_motor_reset_count(pup_motor_t *motor);
98
110int32_t pup_motor_get_count(pup_motor_t *motor);
111
123int32_t pup_motor_get_speed(pup_motor_t *motor);
124
138pbio_error_t pup_motor_set_speed(pup_motor_t *motor, int speed);
139
151int32_t pup_motor_get_power(pup_motor_t *motor);
152
166pbio_error_t pup_motor_set_power(pup_motor_t *motor, int power);
167
179pbio_error_t pup_motor_stop(pup_motor_t *motor);
180
192pbio_error_t pup_motor_brake(pup_motor_t *motor);
193
205pbio_error_t pup_motor_hold(pup_motor_t *motor);
206
220bool pup_motor_is_stalled(pup_motor_t *motor);
221
237int32_t pup_motor_set_duty_limit(pup_motor_t *motor, int duty_limit);
238
250void pup_motor_restore_duty_limit(pup_motor_t *motor, int old_value);
251
252#ifdef __cplusplus
253}
254#endif
255
256#endif // _PUP_MOTOR_H_
257
pbio_error_t pup_motor_reset_count(pup_motor_t *motor)
エンコーダをリセットする.
Definition motor.c:66
void pup_motor_restore_duty_limit(pup_motor_t *motor, int old_value)
モータのデューティ値を元に戻す..
Definition motor.c:156
pup_motor_t * pup_motor_get_device(pbio_port_id_t port)
ポートIDで指定されたモータへのPUPモータデバイスポインタを取得する.
Definition motor.c:34
pbio_error_t pup_motor_setup(pup_motor_t *motor, pup_direction_t positive_direction, bool reset_count)
モータを初期化する.
Definition motor.c:57
int32_t pup_motor_get_power(pup_motor_t *motor)
モータのパワー値を取得する.
Definition motor.c:116
pbio_error_t pup_motor_hold(pup_motor_t *motor)
モータを止めて角度を維持する.
Definition motor.c:108
int32_t pup_motor_get_count(pup_motor_t *motor)
エンコーダの値を取得する.
Definition motor.c:74
bool pup_motor_is_stalled(pup_motor_t *motor)
モータがストールしているか調べる. \detail モータを動かす前にpup_motor_set_duty_limitを呼んで最大トルクを下げておくと感度を調整することができる.
Definition motor.c:142
pbio_error_t pup_motor_stop(pup_motor_t *motor)
モータを止める.
Definition motor.c:92
int32_t pup_motor_set_duty_limit(pup_motor_t *motor, int duty_limit)
モータのデューティ値を下げる. \detail 元の状態に戻すにはこの関数の戻り値を使ってpup_motor_restore_duty_limitを呼ぶ..
Definition motor.c:148
pbio_error_t pup_motor_brake(pup_motor_t *motor)
ブレーキをかけてモータを止める.
Definition motor.c:100
int32_t pup_motor_get_speed(pup_motor_t *motor)
モータの回転速度を取得する.
Definition motor.c:83
pbio_error_t pup_motor_set_power(pup_motor_t *motor, int power)
モータのパワー値を設定する.
Definition motor.c:126
pbio_error_t pup_motor_set_speed(pup_motor_t *motor, int speed)
モータの回転速度を設定する.
Definition motor.c:134