Skip to content

Feature/sequential homing#6

Draft
jperraud wants to merge 12 commits intomainfrom
feature/sequential_homing
Draft

Feature/sequential homing#6
jperraud wants to merge 12 commits intomainfrom
feature/sequential_homing

Conversation

@jperraud
Copy link
Contributor

Implements 2 features:

  • sequential homing: home one motor after another. order follows the list of motor blocks
  • pre-homing: feature for safe homing. This means motor is moving to a defined end point (BACKWARD or FORWARD) and then starts with homing. If this flag is set, sequential homing will always be used.

@jperraud jperraud requested review from sergachev and sjanuth January 26, 2022 13:00
@sergachev
Copy link
Contributor

Will test on hardware in the next days.

self.pre_homing: bool = pre_homing
"""Moves motors to safe position before homing."""

self.pre_homing_direction: float = pre_homing_direction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this direction be specified per motor?

for motor in self.motors:
motor.pre_home(self.pre_homing_direction)
elif self.sequential_homing:
next(self.motors_unhomed).home()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to recreate the motors_unhomed iterator here? Homing can be called more than once per Being lifetime.


def next_homing(self):
"""Controls one by one homing."""
if any(motor.homing_state() is HomingState.ONGOING for motor in self.motors):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you may want to pass the motor instance (and probably the event type too) to this method in subscribe() like it's done in server.py - then you know directly which event you are reacting to and don't need to scan all motors.

try:
next(self.motors_unhomed).home()
except StopIteration:
self.logger.debug('All motors are homed.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message may deserve level 'info'.

self.logger.debug('pre_home()')
if self.homing.ongoing:
self.homing.stop()
self.wasEnabled = False # Do not re-enable motor since not homed anymore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see a use of this variable anywhere.

self.logger.info('home_motors()')
for motor in self.motors:
motor.home()
if self.pre_homing:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interaction of pre-homing with homing is not totally clear, for instance here it looks like you either use pre-homing or sequential homing or parallel homing - whereas in fact pre_homing apparently will trigger homing internally. I'm wondering if there is a better place for all pre-homing-related as an extension of existing methods in homing.py.

@sergachev
Copy link
Contributor

Additional observations after testing:

  • Yes, it is sequential, but order is purely random from run to run. If you don't want to implement order groups as discussed yet - at least make motors_unhomed iterator sorted by id to make it reproducible.

@sergachev
Copy link
Contributor

  • enable_motors() on start is applied to all motors at once even before anything homing-related and makes them jump to the last position where they were unless they were power-cycled. Seems like at least MCLM 3002 controllers remember last position and we do not clear it properly. I'd probably propose to disable them all on start and enable one by one if sequential homing is used.

@jperraud jperraud marked this pull request as draft January 31, 2022 07:11
@sergachev sergachev mentioned this pull request Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants