-
Notifications
You must be signed in to change notification settings - Fork 18k
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
base: master
Are you sure you want to change the base?
Conversation
3c18749
to
ee585ce
Compare
There was a problem hiding this 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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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?
ArduCopter/mode_guided.cpp
Outdated
uint32_t tnow = millis(); | ||
if (tnow - guided_motor_state.update_time_ms > get_timeout_ms()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t tnow = millis(); | |
if (tnow - guided_motor_state.update_time_ms > get_timeout_ms()) { | |
if (millis()- guided_motor_state.update_time_ms > get_timeout_ms()) { |
No need for the local if you only use it once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,2 @@ | |||
builtin_interfaces/Time timestamp # ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add documentation what this message is for. Something like
"Control the direct motor outputs of the vehicle"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Also I have modified the actuator array length to 32 in sync with AP_MOTORS_MAX_NUM_MOTORS.
.dw_id = uxrObjectId{.id=to_underlying(TopicIndex::MOTOR_CONTROL_SUB), .type=UXR_DATAWRITER_ID}, | ||
.dr_id = uxrObjectId{.id=to_underlying(TopicIndex::MOTOR_CONTROL_SUB), .type=UXR_DATAREADER_ID}, | ||
.topic_rw = Topic_rw::DataReader, | ||
.topic_name = "rt/ap/cmd_mot", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this an experimental topic till we've flown it on a vehicle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Done
ee585ce
to
a3cacf1
Compare
a3cacf1
to
08a5c3e
Compare
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:
param set DISARM_DELAY 0
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.