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

ros2: set bit mask in global position setpoint #54

Merged

Conversation

srmainwaring
Copy link
Collaborator

Set the POSITION_TARGET_TYPEMASK field in the global position setpoint. This is required by the flight controller to select the appropriate control behaviour.

For example in ArduPilot Plane there is a separate handler to respond to an off-board change altitude request.

For path following we mark lat_int, lon_int, alt, vx, vy, vz, ax, ay, az as not ignored.

using namespace mavros_msgs;
// Publishes position setpoints sequentially as trajectory setpoints
mavros_msgs::msg::GlobalPositionTarget msg;
msg.header.stamp = this->get_clock()->now();
msg.coordinate_frame = mavros_msgs::msg::GlobalPositionTarget::FRAME_GLOBAL_REL_ALT;
msg.type_mask = 0.0;
msg.type_mask = path_mask;
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim Feb 26, 2024

Choose a reason for hiding this comment

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

Might be better to directly use the enums in the message definitions,

Suggested change
msg.type_mask = path_mask;
msg.type_mask = mavros_msgs::msg::GlobalPositionTarget::IGNORE_YAW | IGNORE_YAW_RATE;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion @Jaeyoung-Lim - I need to check what happens to the highest bits in the mask using this approach - may need to update AP's handling as well to ensure a match.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, this is part of the mavlink standard no? Or is it something special to the ardupilot dialect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AP does not use the POSITION_TARGET_TYPEMASK flags to construct the checks, instead uses a hardcoded unint16_t bit pattern (as was done here). Just need to check the AND logic used in the case evaluation there works as expected.

@Jaeyoung-Lim
Copy link
Member

@srmainwaring Are there any updates regarding this?

@srmainwaring
Copy link
Collaborator Author

Are there any updates regarding this?

Sorry @Jaeyoung-Lim, got sidetracked with getting DDS integration to work for AP (it now is). Your suggestion is the right way to do this. I'll make the corresponding changes in ArduPilot, where some additional work is required in any case.

@srmainwaring srmainwaring force-pushed the prs/pr-set-global-position-bitmask branch from 1dc324e to eb2af50 Compare March 12, 2024 20:14
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@Jaeyoung-Lim Jaeyoung-Lim merged commit 0c6d734 into ethz-asl:ros2 Mar 13, 2024
3 checks passed
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.

2 participants