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

Updated AMC BLDC Application 03 to use generated code with nonvirtual buses #203

Merged
merged 1 commit into from
Sep 21, 2021

Conversation

GrmanRodriguez
Copy link
Contributor

@GrmanRodriguez GrmanRodriguez commented Sep 21, 2021

This PR updates application 03 from MVP 0.2 to the recent change in using nonvirtual buses (from this PR in study-amc-bldc).

C++ code was re-generated using nonvirtual buses and added as part of the project files. The theMBDagent class has been updated to use the new code.

As expected, adapting the new code was significantly easier and required less variables than before. Here is an example in the previous code:

-               can_decoder.step(&decoder_available, &packet_CLS, &packet_SRC, &packet_DST_TYP, &packet_LEN, &packet_M, &packet_OPC, &packet_ARG[0],
-                                &rtb_motor, &rtb_mode, &rtb_motor_e, &rtb_nominal, &rtb_peak, &rtb_overload, &rtb_current_o, &rtb_control_mode, &rtb_current_limit, &rtb_desired_current, &rtb_event, &rtb_type);
+               can_decoder.step(bus_can_rx, bus_messages_rx, bus_events_rx, bus_can_rx_errors);

-    supervisor_rx.step((const BoardState*)board_state_gnd, (const BoardCommand*)board_command_gnd,
-                       &iabc[0], &angle, &omega, &temperature, &motor_sensors_voltage,
-                       &current_threshold, &cu_k_threshold, &voltage_threshold, &vo_k_threshold, &temperature_threshold, &te_c_threshold,
-                       &motor_sensors_current,
-                       &rtb_event, &rtb_control_mode, &rtb_current_limit, &rtb_desired_current,
-                       &rtb_motor, &rtb_mode, &rtb_motor_e, &rtb_nominal, &rtb_peak, &rtb_overload, &rtb_current_o,
-                       &supervisor_control_mode, &pid_reset, &position, &velocity, &current, &voltage);
+    supervisor_rx.step(internal_messages, motor_sensors, bus_events_rx, bus_messages_rx, bus_can_rx_errors, flags, targets);

The application has been tested using CANReal and the behavior remains identical to before. Particularly when using the scan, set control mode idle and set control mode speedvoltage commands.

This PR addresses #747.

cc @sgiraz @valegagge @pattacini

@pattacini
Copy link
Member

Happy to read that 🚀

Copy link
Contributor

@marcoaccame marcoaccame left a comment

Choose a reason for hiding this comment

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

the PR is ok, we can merge it.

just two very very minor suggestions for future contributions:

  • use 4 spaces instead of one tab. if you do so, the visualization stays invariant on any IDE.
  • in C++ code prefer C++ casts (static_cast<>, etc.) vs old-style casts.

@marcoaccame marcoaccame merged commit 702d27d into robotology:devel Sep 21, 2021
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