Jaeyoung-Lim / mavros_controllers

Aggressive trajectory tracking using mavros for PX4 enabled vehicles
BSD 3-Clause "New" or "Revised" License
412 stars 166 forks source link

Edit Trajectory #169

Closed dedyebhi closed 3 years ago

dedyebhi commented 3 years ago

how do you edit the trajectory circle program, sir? because my final project in college I used a square trajectory. Thank you sir

Jaeyoung-Lim commented 3 years ago

@dedyebhi The trajectory shapes are defined in https://github.com/Jaeyoung-Lim/mavros_controllers/blob/393242d0a42904383b5bb93e09b5dc620eab1d43/trajectory_publisher/src/shapetrajectory.cpp#L70

You can add a square trajectory as another "shape"

dedyebhi commented 3 years ago

@dedyebhi The trajectory shapes are defined in

https://github.com/Jaeyoung-Lim/mavros_controllers/blob/393242d0a42904383b5bb93e09b5dc620eab1d43/trajectory_publisher/src/shapetrajectory.cpp#L70

You can add a square trajectory as another "shape"

Can you help me create a program to add a squere trajectory?

Jaeyoung-Lim commented 3 years ago

@dedyebhi Is there more information that you need? where are you stuck?

dedyebhi commented 3 years ago

@dedyebhi Is there more information that you need? where are you stuck?

I don't understand how to add a square trajectory, Can you help me create a program to add a squere trajectory?

Jaeyoung-Lim commented 3 years ago

@dedyebhi What part do you not understand? You just need to add a case for a square in

https://github.com/Jaeyoung-Lim/mavros_controllers/blob/393242d0a42904383b5bb93e09b5dc620eab1d43/trajectory_publisher/src/shapetrajectory.cpp#L70-L99

dedyebhi commented 3 years ago

@dedyebhi What part do you not understand? You just need to add a case for a square in

https://github.com/Jaeyoung-Lim/mavros_controllers/blob/393242d0a42904383b5bb93e09b5dc620eab1d43/trajectory_publisher/src/shapetrajectory.cpp#L70-L99

can you reason me for example?

Jaeyoung-Lim commented 3 years ago

@dedyebhi You can use the circle trajectory as an example. I specifically linked the code as an example

dedyebhi commented 3 years ago

Eigen::Vector3d shapetrajectory::getPosition(double time) { Eigen::Vector3d position; double theta;

switch (type_) { case TRAJ_ZERO:

  position << 0.0, 0.0, 0.0;
  break;

case TRAJ_CIRCLE:

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_LAMNISCATE:  // Lemniscate of Genero

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * std::cos(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_SQUERE:

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * std::cos(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_STATIONARY:  // Lemniscate of Genero

  position = traj_origin_;
  break;

} return position; }

dedyebhi commented 3 years ago

Eigen::Vector3d shapetrajectory::getPosition(double time) { Eigen::Vector3d position; double theta;

switch (type_) { case TRAJ_ZERO:

  position << 0.0, 0.0, 0.0;
  break;

case TRAJ_CIRCLE:

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_LAMNISCATE:  // Lemniscate of Genero

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * std::cos(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_SQUERE:

  theta = traj_omega_ * time;
  position = std::cos(theta) * traj_radial_ + std::sin(theta) * std::cos(theta) * traj_axis_.cross(traj_radial_) +
             (1 - std::cos(theta)) * traj_axis_.dot(traj_radial_) * traj_axis_ + traj_origin_;
  break;

case TRAJ_STATIONARY:  // Lemniscate of Genero

  position = traj_origin_;
  break;

} return position; }

Is it like this ?

Jaeyoung-Lim commented 3 years ago

@dedyebhi Yes, but you would need to write the square part

dedyebhi commented 3 years ago

@dedyebhi Yes, but you would need to write the square part

Can you help me, what is squere part like?

Jaeyoung-Lim commented 3 years ago

@dedyebhi I have pointed you to the relevant places where you can modify this package. Drawing the square trajectory seems to be part of what you are doing, and not related to this package. Therefore, unfortunately I think that is the part that you need to figure out yourself.

dedyebhi commented 3 years ago

@dedyebhi I have pointed you to the relevant places where you can modify this package. Drawing the square trajectory seems to be part of what you are doing, and not related to this package. Therefore, unfortunately I think that is the part that you need to figure out yourself.

please, i need your help

Jaeyoung-Lim commented 3 years ago

@dedyebhi I have already helped you!

I cannot implement your project for you. Since the feature you are requesting is not something relevant to this package, you would need to figure how to implement a square yourself.

Please feel free to ask if you have any questions regarding this package.

dedyebhi commented 3 years ago

@dedyebhi I have already helped you!

I cannot implement your project for you. Since the feature you are requesting is not something relevant to this package, you would need to figure how to implement a square yourself.

Please feel free to ask if you have any questions regarding this package.

can you send me a reference regarding the square trajectory quadcopter?