Source code for genericroboticarm.robo_APIs.precise_flex.movement_profiles
"""
The movement profiles of a Precise Flex and the ways to switch between them.
A profile bundles the speed and the path properties of a movement and is referenced by its index,
which is sent along with every move command.
"""
from dataclasses import dataclass
[docs]
@dataclass
class MoveProfile:
Speed: int
Speed2: int = 0
Accel: int = 50
AccRamp: float = .1
Decel: int = 50
DecRamp: float = .1
InRange: int = 0 # -1 is the smoothest and quickest movement possible, but cuts corners which can cause crashes
Straight: int = 0 # -1 means straight line, 0 means joint-based path. Settings to -1 can cause Error 1042
# profile_index: the profile that is configured on the robot for that index
movement_profiles: dict[int, MoveProfile] = {
1: MoveProfile(Speed = 10),
2: MoveProfile(Speed = 50),
3: MoveProfile(Speed = 50, InRange=-1),
4: MoveProfile(Speed = 50, Straight=-1),
5: MoveProfile(Speed = 50, InRange=-1, Straight=-1),
}
slow_profile = 1
normal_profile = 2
smooth_profile = 3
straight_profile = 4
straight_smooth_profile = 5
[docs]
def smoothen_profile(current_profile: int) -> int:
if current_profile == normal_profile:
return smooth_profile
elif current_profile == straight_profile:
return straight_smooth_profile
else:
return current_profile
[docs]
def straighten_profile(current_profile: int) -> int:
if current_profile == smooth_profile:
return straight_smooth_profile
elif current_profile == normal_profile:
return straight_profile
else:
return current_profile