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

Yaw in flat target.msg #189

Closed
wants to merge 13 commits into from
Closed

Yaw in flat target.msg #189

wants to merge 13 commits into from

Conversation

brunopinto900
Copy link

@brunopinto900 brunopinto900 commented Jul 20, 2021

Problem Description:

This PR adds yaw field to the FlatTarget.msg and any necessary modifications. The circle trajectory now sets yaw to point to the center of the circle at all time.

Additional Context:

This PR is related with #153.

To discuss:

  1. The polynomial trajectory getYaw returns 0
float polynomialtrajectory::getYaw(double time) {
  float yaw = 0.0;
  return yaw;
}
  1. Yaw is a float (Float32) not a double (Float64)

Copy link
Owner

@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.

Thanks for the contribution!

All looks good except some minor points

  • I think we need to add the case where yaw can be ignored. Could you add this case to the message definition and handle it in the callback?
  • The polynomial trajectory is now set to yaw=0. I think this is a unnecessary restriction and basically disables the case for velocity yaw
  • How does velocity_yaw option work with this case?

As far as I am concerned this does not add the reduced attitude controller for yaw control. From the discussion we had in #186 Are you planning to add this?

.gitignore Outdated
@@ -5,3 +5,6 @@

#Artifacts from vscode
.vscode/*

#Rviz config
geometric_controller/launch/config_file.rviz
Copy link
Owner

Choose a reason for hiding this comment

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

Why would you want to ignore the rviz config?

Copy link
Author

Choose a reason for hiding this comment

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

Because i am always configuring rviz. So need always to commit. I can remove this condition on .gitignore if you like.

Copy link
Owner

Choose a reason for hiding this comment

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

Please remove it from the gitignore. You just need to not commit the rviz changes you did when you commit

@@ -147,6 +147,7 @@ void geometricCtrl::flattargetCallback(const controller_msgs::FlatTarget &msg) {

targetPos_ = toEigen(msg.position);
targetVel_ = toEigen(msg.velocity);
mavYaw_ = double(msg.yaw.data);
Copy link
Owner

Choose a reason for hiding this comment

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

This means that we always need to define yaw, which I think is not what we want. Can you add a case where we can specify ignoring yaw option and handle the case here?

Copy link
Author

Choose a reason for hiding this comment

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

You are right. We can solve this by using a mask (IGNORE_YAW) in the message definition. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

That sounds great

@@ -128,6 +128,10 @@ Eigen::VectorXd polynomialtrajectory::getCoefficients(int dim) {
}
}

float polynomialtrajectory::getYaw(double time) {
float yaw = 0.0;
Copy link
Owner

Choose a reason for hiding this comment

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

Where does yaw=0.0 come from? This needs to configurable, and probably belongs to the ignore yaw case

@brunopinto900
Copy link
Author

  • I think we need to add the case where yaw can be ignored. Could you add this case to the message definition and handle it in the callback?

What do you mean? Using the already defined mask? something like IGNORE_MASK = some number?

  • The polynomial trajectory is now set to yaw=0. I think this is a unnecessary restriction and basically disables the case for velocity yaw
  • How does velocity_yaw option work with this case?

Great question, i still have to think more about this.

As far as I am concerned this does not add the reduced attitude controller for yaw control. From the discussion we had in #186 Are you planning to add this?

Yes, it doesn't add, i am currently working on it.

@Jaeyoung-Lim
Copy link
Owner

What do you mean? Using the already defined mask? something like IGNORE_MASK = some number?

Yes, preferably a bitmask

As far as I am concerned this does not add the reduced attitude controller for yaw control. From the discussion we had in #186 Are you planning to add this?
Yes, it doesn't add, i am currently working on it.

Awesome!

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900 Any updates?

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900 Have you made any progress here?

@brunopinto900
Copy link
Author

Hey, not yet. I am going on a vacation and have to finnish work stuff.

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900 Any updates regarding this work?

@brunopinto900
Copy link
Author

brunopinto900 commented Aug 16, 2021

Hello,

Not yet. Since i am going a vacation, i am finnishing work stuff. By the way i sent you an e-mail.

@Jaeyoung-Lim
Copy link
Owner

Jaeyoung-Lim commented Aug 16, 2021

@brunopinto900 Since this PR has been open for almost a month, could you provide an approximate ETA on when this will be addressed?

@brunopinto900
Copy link
Author

brunopinto900 commented Aug 16, 2021

Since its a small thing, i can finnish tomorrow.

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900 Great, thanks

@brunopinto900
Copy link
Author

I think we need to add the case where yaw can be ignored. Could you add this case to the message definition and handle it in the callback? This means that we always need to define yaw, which I think is not what we want. Can you add a case where we can specify ignoring yaw option and handle the case here?

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900
Copy link
Author

brunopinto900 commented Aug 16, 2021

  • I think we need to add the case where yaw can be ignored. Could you add this case to the message definition and handle it in the callback?

I added "std::msgs/bool IGNORE_YAW" in the message definition? Much simpler than a bit mask. What do you think? Or want to have as the AttitudeTarget.msg?

  • The polynomial trajectory is now set to yaw=0. I think this is a unnecessary restriction and basically disables the case for velocity yaw

The polynomial trajectory now sets yaw to the direction of drone [ atan2f(velocity(1),velocity(0)); ]. But already added logic to ignore yaw.

  • Please remove it from the gitignore. You just need to not commit the rviz changes you did when you commit

Removed rviz from .gitignore


I have two questions. Shouldn't mavYaw_ be targetYaw_? Because its the target orientation and not the current drone yaw

  1. In this function:

Eigen::Vector3d geometricCtrl::controlPosition(const Eigen::Vector3d &target_pos, const Eigen::Vector3d &target_vel,
const Eigen::Vector3d &target_acc) {
/// Compute BodyRate commands using differential flatness
/// Controller based on Faessler 2017
const Eigen::Vector3d a_ref = target_acc;
if (velocity_yaw_) {
mavYaw_ = getVelocityYaw(mavVel_);
}

  1. mavYaw_ is being computed from the current velocity, shouldn't be from target_vel? Although in practice, the drone's velocity will closely match the target velocity.

@brunopinto900
Copy link
Author

brunopinto900 commented Aug 16, 2021

Using the bit mask to ignore yaw. Its a cleaner interface.

@brunopinto900
Copy link
Author

Hello @Jaeyoung-Lim Did you the chance to review the pull request?

Copy link
Owner

@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.

Sorry for the late review.

I think the yaw ignore implementation looks good on the geometric_controller side, but on the trajectory_publisher it seems like the yaw is assumed to be in the direction of velocity. I don't think this is a generally applicable assumption to make and usually not the behavior we want.

@@ -147,7 +147,11 @@ void geometricCtrl::flattargetCallback(const controller_msgs::FlatTarget &msg) {

targetPos_ = toEigen(msg.position);
targetVel_ = toEigen(msg.velocity);

if( (msg.type_mask & 8) == 8) // Ignore yaw
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if( (msg.type_mask & 8) == 8) // Ignore yaw
if( (msg.type_mask == controller_msgs::IGNORE_YAW) // Ignore yaw

@@ -147,7 +147,11 @@ void geometricCtrl::flattargetCallback(const controller_msgs::FlatTarget &msg) {

targetPos_ = toEigen(msg.position);
targetVel_ = toEigen(msg.velocity);

if( (msg.type_mask & 8) == 8) // Ignore yaw
mavYaw_ = 0.0;
Copy link
Owner

Choose a reason for hiding this comment

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

If you are ignoring yaw, you should not set the yaw to zero. Otherwise this is resetting the yaw setpoint to zero

msg.acceleration.z = a_targ(2);

if(ignore_yaw_) {
msg.type_mask |= 8;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
msg.type_mask |= 8;
msg.type_mask |=controller_msgs::IGNORE_YAW

@@ -70,6 +70,7 @@ trajectoryPublisher::trajectoryPublisher(const ros::NodeHandle& nh, const ros::N
nh_private_.param<int>("trajectory_type", trajectory_type_, 0);
nh_private_.param<int>("number_of_primitives", num_primitives_, 7);
nh_private_.param<int>("reference_type", pubreference_type_, 2);
nh_private_.param<bool>("ignore_yaw", ignore_yaw_, false);
Copy link
Owner

Choose a reason for hiding this comment

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

I think the flag is a bit inaccurate. The trajectory publisher not ignoring yaw but more whether you want to publish yaw.

Eigen::Vector3d velocity = getVelocity(time); // Yaw is set in the direction of the vehicle
float yaw = atan2f(velocity(1),velocity(0));
return yaw;
}
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think yaw should be always aligned with the velocity for polynomial trajectories.

@Jaeyoung-Lim
Copy link
Owner

@brunopinto900 I am closing this PR as stale. Please reopen if you are willing to continue 😄

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