Skip to content

RMD first position control cmd not working #41

@Kirthika-Ashokkumar

Description

@Kirthika-Ashokkumar

The RMD ignores the first position control message but when the position but when a dummy message is placed at the begging then the RMD works as coded.

Code:

hal::degrees stop_angle;
  auto& mc_x_1 = steering_modules[0].steer;

//DUMMY MESSAGE AT THE BEGINNING THAT IS IGNORED
  mc_x_1.value()->feedback_request(
    hal::actuator::rmd_mc_x_v2::read::multi_turns_angle);
  stop_angle = mc_x_1.value()->feedback().angle();
  hal::print<128>(console, "Read angle: %f\n", stop_angle);
  mc_x_1.value()->position_control(stop_angle +90, 20);
  hal::delay(clock, 2s);
  
  while (true) {
    hal::print<128>(console, "Motor: %d\n", 1);
    mc_x_1.value()->feedback_request(
      hal::actuator::rmd_mc_x_v2::read::multi_turns_angle);
    stop_angle = mc_x_1.value()->feedback().angle();
    hal::print<128>(console, "Starting angle: %f\n", stop_angle);
    hal::delay(clock, 2s);
    mc_x_1.value()->position_control(stop_angle + 90, 20);
    hal::delay(clock, 2s);

    mc_x_1.value()->feedback_request(
      hal::actuator::rmd_mc_x_v2::read::multi_turns_angle);
    stop_angle = mc_x_1.value()->feedback().angle();
    hal::print<128>(console, "Middle angle: %f\n", stop_angle);
    hal::delay(clock, 2s);

    mc_x_1.value()->position_control(stop_angle - 90, 20);
    hal::delay(clock, 2s);

    hal::print(console, "motor stopped\n");

    mc_x_1.value()->feedback_request(
      hal::actuator::rmd_mc_x_v2::read::multi_turns_angle);
    stop_angle = mc_x_1.value()->feedback().angle();
    hal::print<128>(console, "Final angle (afterstop): %f\n\n", stop_angle);
    hal::delay(clock, 2s);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions