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

AP_DDS: Added direct actuator control #29179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

snktshrma
Copy link
Contributor

@snktshrma snktshrma commented Jan 29, 2025

This adds a new topic /ap/cmd_mot to allow external controllers control actuators directly. This adds support for external controller and planners (MPC, etc) to handle actuator control directly.

To run:

  1. Run Copter SITL
  2. On mavproxy, param set DISARM_DELAY 0
  3. Switch to Guided and arm.
  4. Publish:
ros2 topic pub /ap/experimental/cmd_mot ardupilot_msgs/msg/MotorControl "{timestamp: {sec: 0, nanosec: 0}, actuator: [0.7, 0.7, 0.7, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}"

This addition currently doesn't support case where publisher stops and switches the vehicle to a stable mode. In that case, the actuator output just resets to 0 (Min PWM) if no updates are received.

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Overall looking good. We'll need a review from a copter maintainer such as Randy or Pete Hall.

}

guided_motor_state.update_time_ms = millis();
memcpy(guided_motor_state.actuator, actuator, AP_MOTORS_MAX_NUM_MOTORS * sizeof(float));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
memcpy(guided_motor_state.actuator, actuator, AP_MOTORS_MAX_NUM_MOTORS * sizeof(float));
memcpy(guided_motor_state.actuator, actuator, ARRAY_SIZE(guided_motor_state.actuator));

If you changed to double in the actuators, then this would not require a change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Ryanf55 ! So ARRAY_SIZE gives number of elements and because of that it will not copy anything after 8th element(32bytes). Either way you suggest using double(float64) instead of float32?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think double precision would be coverkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright Ryan! Then I'll keep it float32 then

@Ryanf55 Ryanf55 added ROS WikiNeeded needs wiki update labels Jan 29, 2025
@snktshrma snktshrma force-pushed the dds/ind_motor branch 2 times, most recently from a3cacf1 to 08a5c3e Compare January 30, 2025 06:54
@snktshrma snktshrma requested a review from Ryanf55 January 30, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ROS WikiNeeded needs wiki update
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants