411 reset_profile_tracking();
415 const double effective_master_offset =
master_offset + selected_master_origin_;
416 const double effective_slave_offset =
417 slave_offset + selected_slave_origin_ + relative_slave_bias_;
420 effective_slave_offset,
426 profile_master_offset_ = effective_master_offset;
431 update_end_of_profile();
449 axis::CamInCommand command{};
456 selected_master_origin_ = 0.0;
457 selected_slave_origin_ = 0.0;
458 relative_slave_bias_ = 0.0;
460 const rt::Result<axis::CamTableSelection>
selected =
466 const axis::CamTableSelection selection =
selected.value();
467 command.table = selection.table;
468 if(!selection.master_absolute) {
469 selected_master_origin_ = selection.master_origin;
470 command.master_offset += selected_master_origin_;
472 if(!selection.slave_absolute) {
473 selected_slave_origin_ = selection.slave_origin;
474 command.slave_offset += selected_slave_origin_;
478 if(!
command.table.valid() || !std::isfinite(
command.master_scaling) ||
479 command.master_scaling == 0.0 || !std::isfinite(
command.slave_scaling)) {
483 const axis::AxisSnapshot &master_snapshot =
master_ref->snapshot();
484 const double master_position =
486 ? master_snapshot.actual_position
487 : master_snapshot.command_position;
488 const double table_input =
489 (master_position -
command.master_offset) /
command.master_scaling;
490 const rt::Result<double> sampled =
command.table.sample(table_input);
496 command.slave_scaling * sampled.value();
497 relative_slave_bias_ =
507 profile_table_ =
command.table;
508 profile_master_offset_ =
command.master_offset;
509 profile_master_scaling_ =
command.master_scaling;
510 profile_source_ =
command.source;
515 void reset_profile_tracking()
518 profile_period_valid_ =
false;
522 void update_end_of_profile()
526 profile_master_scaling_ == 0.0) {
527 profile_period_valid_ =
false;
530 const axis::AxisSnapshot &snapshot =
master_ref->snapshot();
532 ? snapshot.actual_position
533 : snapshot.command_position;
535 (master_position - profile_master_offset_) / profile_master_scaling_;
536 const double first = profile_table_.points[0].master;
537 const double last = profile_table_.points[profile_table_.size - 1].master;
538 if(!profile_table_.periodic) {
543 const std::int64_t period =
static_cast<std::int64_t
>(std::floor((input - first) / span));
544 if(profile_period_valid_) {
547 profile_period_ = period;
548 profile_period_valid_ =
true;
551 exec::CamTableView profile_table_{};
552 double profile_master_offset_ = 0.0;
553 double profile_master_scaling_ = 1.0;
555 double selected_master_origin_ = 0.0;
556 double selected_slave_origin_ = 0.0;
557 double relative_slave_bias_ = 0.0;
558 std::int64_t profile_period_ = 0;
559 bool profile_period_valid_ =
false;