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.
Attributes:
Name | Type | Description |
---|---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
can |
CanBus
|
CanBus object. |
required |
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_vel |
float
|
Max velocity of the slider module in m/s. |
required |
enable()
Enables the slider module.
disable()
Disables the slider module.
init_pos(initial_pos=0)
Initializes position of the slider module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
float
|
Position of the slider module in m. |
required |
set_abs_pos(pos)
Sets absolute position of the slider module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
float
|
Absolute position of the slider module in m. |
required |
get_pos(timeout=None)
Reads position of the slider module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Timeout in seconds. |
None
|
Returns:
Type | Description |
---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Timeout in seconds. |
None
|
Returns:
Type | Description |
---|---|
float | None
|
Absolute position of the slider module in m. Returns None if the read times out. |