SliderModule
robodyno.components.can_bus.slider_module
Slider module.
This module provides functions to control slider module. The slider module is a lead screw driven linear module with a robodyno motor.
Examples:
>>> from robodyno.components import SliderModule
>>> from robodyno.interfaces import CanBus
>>> can_bus = CanBus()
>>> slider = SliderModule(can_bus, 0x10)
>>> slider.enable()
>>> slider.set_pos(0.1)
>>> slider.get_pos()
0.1
>>> slider.disable()
>>> can_bus.disconnect()
SliderModule
Bases: object
Slider module.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
motor |
Motor
|
Motor object of the slider module. |
__init__(can, id_=16, type_=None, max_vel=0.02, lead=0.01)
Inits SliderModule with can bus object and device id.
This function initializes the slider module by creating a motor object and configuring the motor to position track mode with max velocity.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
can
|
CanBus
|
CanBus object. |
必需 |
id_
|
int
|
Motor id of the slider module. |
16
|
type_
|
string
|
Motor type of the slider module. |
None
|
max_vel
|
float
|
Max velocity of the slider module in m/s. |
0.02
|
lead
|
float
|
Lead of the slider module in m/round. |
0.01
|
set_max_vel(max_vel)
Sets max velocity of the slider module.
This function configures the motor to position track mode with max velocity.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
max_vel
|
float
|
Max velocity of the slider module in m/s. |
必需 |
enable()
Enables the slider module.
disable()
Disables the slider module.
init_pos(initial_pos=0)
Initializes position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
initial_pos
|
float
|
Initial position of the slider module in m. |
0
|
init_abs_pos(initial_pos=0, save=True)
Initializes absolute position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
initial_pos
|
float
|
Initial absolute position of the slider module in m. |
0
|
save
|
bool
|
Whether to save the configuration. |
True
|
set_pos(pos)
Sets position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
pos
|
float
|
Position of the slider module in m. |
必需 |
set_abs_pos(pos)
Sets absolute position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
pos
|
float
|
Absolute position of the slider module in m. |
必需 |
get_pos(timeout=None)
Reads position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
timeout
|
float
|
Timeout in seconds. |
None
|
返回:
| 类型 | 描述 |
|---|---|
float | None
|
Position of the slider module in m. Returns None if the read times out. |
get_abs_pos(timeout=None)
Reads absolute position of the slider module.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
timeout
|
float
|
Timeout in seconds. |
None
|
返回:
| 类型 | 描述 |
|---|---|
float | None
|
Absolute position of the slider module in m. Returns None if the read times out. |