Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(can): Hardware 32 bit move vals #8662

Merged
merged 4 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,15 @@ class AddToMoveGroupRequestPayload(MoveGroupRequestPayload):
"""Base of add to move group request to a message group."""

seq_id: utils.UInt8Field
# TODO (al, 2021-10-2021): this should be 32 bits
duration: utils.UInt16Field
duration: utils.UInt32Field


@dataclass
class AddLinearMoveRequestPayload(AddToMoveGroupRequestPayload):
"""Add a linear move request to a message group."""

# TODO (al, 2021-10-2021): this should be 32 bits
acceleration: utils.Int16Field
# TODO (al, 2021-10-2021): this should be 32 bits
velocity: utils.Int16Field
# TODO (al, 2021-10-2021): this should be present and 32 bits
# position: utils.UInt32Field
acceleration: utils.Int32Field
velocity: utils.Int32Field


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from typing_extensions import Final


interrupts_per_sec: Final = 8500000
interrupts_per_sec: Final = 850000
"""The number of motor interrupts per second."""
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from opentrons_hardware.hardware_control.constants import interrupts_per_sec
from opentrons_hardware.hardware_control.motion import MoveGroups
from opentrons_hardware.utils import UInt8Field, UInt16Field, Int16Field
from opentrons_hardware.utils import UInt8Field, UInt32Field, Int32Field


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -68,11 +68,11 @@ async def _send_groups(self, can_messenger: CanMessenger) -> None:
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(group_i),
seq_id=UInt8Field(seq_i),
duration=UInt16Field(
duration=UInt32Field(
int(step.duration_sec * interrupts_per_sec)
),
acceleration=Int16Field(0),
velocity=Int16Field(
acceleration=Int32Field(0),
velocity=Int32Field(
int(interrupts_per_sec * step.velocity_mm_sec)
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
message_definitions as md,
MessageDefinition,
)
from opentrons_hardware.utils import UInt8Field, Int16Field, UInt16Field
from opentrons_hardware.utils import UInt8Field, Int32Field, UInt32Field


@pytest.fixture
Expand Down Expand Up @@ -129,14 +129,14 @@ async def test_single_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(0),
seq_id=UInt8Field(0),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_single[0][0][NodeId.head].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_single[0][0][NodeId.head].duration_sec
* interrupts_per_sec
Expand All @@ -161,14 +161,14 @@ async def test_multi_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(0),
seq_id=UInt8Field(0),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_multiple[0][0][NodeId.head].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_multiple[0][0][NodeId.head].duration_sec
* interrupts_per_sec
Expand All @@ -185,14 +185,14 @@ async def test_multi_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(1),
seq_id=UInt8Field(0),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_multiple[1][0][NodeId.gantry_x].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_multiple[1][0][NodeId.gantry_x].duration_sec
* interrupts_per_sec
Expand All @@ -208,14 +208,14 @@ async def test_multi_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(1),
seq_id=UInt8Field(0),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_multiple[1][0][NodeId.gantry_y].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_multiple[1][0][NodeId.gantry_y].duration_sec
* interrupts_per_sec
Expand All @@ -232,14 +232,14 @@ async def test_multi_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(2),
seq_id=UInt8Field(0),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_multiple[2][0][NodeId.pipette].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_multiple[2][0][NodeId.pipette].duration_sec
* interrupts_per_sec
Expand All @@ -255,14 +255,14 @@ async def test_multi_send_setup_commands(
payload=AddLinearMoveRequestPayload(
group_id=UInt8Field(2),
seq_id=UInt8Field(1),
velocity=Int16Field(
velocity=Int32Field(
int(
move_group_multiple[2][1][NodeId.pipette].velocity_mm_sec
* interrupts_per_sec
)
),
acceleration=Int16Field(0),
duration=UInt16Field(
acceleration=Int32Field(0),
duration=UInt32Field(
int(
move_group_multiple[2][1][NodeId.pipette].duration_sec
* interrupts_per_sec
Expand Down