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

Full review #2

Closed
wants to merge 251 commits into from
Closed

Full review #2

wants to merge 251 commits into from

Conversation

Timple
Copy link
Member

@Timple Timple commented Aug 16, 2021

PR for commenting on the complete codebase.

@Timple Timple mentioned this pull request Jan 24, 2022
Copy link
Contributor

@rokusottervanger rokusottervanger left a comment

Choose a reason for hiding this comment

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

See the comments. Additionally, I'm curious as to what the rationale is behind the separation between the controller.cpp file and the path_tracking_pid.cpp file. Could you elaborate?

cfg/Pid.cfg Show resolved Hide resolved
include/path_tracking_pid/controller.hpp Outdated Show resolved Hide resolved
<rosparam file="$(find path_tracking_pid)/test/local_costmap_params.yaml" command="load" />
</node>

</launch>
Copy link
Contributor

Choose a reason for hiding this comment

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

This file tries to launch mbf_costmap_nav from move_base_flex, but it is not a dependency. You may not want to add a dependency on move_base_flex to this package. But instead, you could make a separate package in this repo containing this applied example and its configuration, with dependencies on path_tracking_pid and mbf_costmap_nav. But I'm open to alternatives.

Choose a reason for hiding this comment

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

Or perhaps add it as a test dependency?

Copy link
Member Author

Choose a reason for hiding this comment

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

This should have been tackled by the roslaunch checker.
Should be an exec_depend

Copy link
Contributor

Choose a reason for hiding this comment

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

This type of errors will be caught by a proper CI. Reason to set this up?

src/path_tracking_pid_local_planner.cpp Show resolved Hide resolved
// 'Project' plan by removing z-component
pose_stamped.pose.position.z = 0.0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The function above checks for compatibility of the plan's frame and the frame the controller is running in. This makes assumptions about the application. Does the user want you to control in the plan's frame, or do they want the controller to convert the plan to the controller's frame? There's no way of knowing.

Keep the the controller (and the entire ROS system) clean by assuming you're running in the standardized frames (map, odom, or maybe utm or something). In this case you're using the frame specified for move_base_flex. If the user wants to be flexible with respect to the reference frames of navigation plans, they should transform any incoming plans to the move_base_flex global frame in a separate rosnode with the isolated functionality of providing this flexible interface.

Choose a reason for hiding this comment

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

There seems to be a discussion about this topic on ROS2. We will check this and decide later on how to proceed.

src/path_tracking_pid_local_planner.cpp Show resolved Hide resolved
src/path_tracking_pid_local_planner.cpp Show resolved Hide resolved
src/path_tracking_pid_local_planner.cpp Show resolved Hide resolved
src/path_tracking_pid_local_planner.cpp Outdated Show resolved Hide resolved
controller_state_.current_x_vel = new_x_vel;
controller_state_.current_yaw_vel = new_yaw_vel;
return output_combined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This single function is nearly 470 lines of code. Split this up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. We should probably enable sonarcloud on this repository as well. It gives indications like cyclomatic-complexity of the code. And maximum number of seperate statements in functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

This refactor is in progress. Should I raise an issue about CI missing?

@Timple
Copy link
Member Author

Timple commented Jan 25, 2022

As I'm not the original (nor the main) author here, I didn't address all comments 🙂

Copy link
Contributor

@rokusottervanger rokusottervanger left a comment

Choose a reason for hiding this comment

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

I'm losing confidence in the viability of this controller for the long term... It takes a complete reimplementation to fix this.

src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
Comment on lines 205 to 211
// When velocity error is too big reset current_x_vel
if (fabs(odom_twist.linear.x - controller_state_.current_x_vel) > max_error_x_vel_)
{
// TODO(clopez/mcfurry/nobleo): Give feedback to higher level software here
ROS_WARN("Large control error. Current_x_vel %f / odometry %f",
controller_state_.current_x_vel, odom_twist.linear.x);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

"reset current_x_vel"? I don't see this happening...

Choose a reason for hiding this comment

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

There was a reset at some point, but then it introduced a undesired behavior in one of the applications, we should remove or rewrite the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can get rid of this condition and warning, because it is doesn't do anything functionally, and a similar check is performed in the update method here:

// When velocity error is too big reset current_x_vel
if (
fabs(odom_twist.linear.x) < fabs(current_target_x_vel_) &&
fabs(odom_twist.linear.x - new_x_vel) > config_.max_error_x_vel) {
// TODO(clopez/mcfurry/nobleo): Give feedback to higher level software here
ROS_WARN_THROTTLE(
1.0, "Large tracking error. Current_x_vel %f / odometry %f", new_x_vel, odom_twist.linear.x);
}


// Cutoff frequency for the derivative calculation in Hz.
// Negative -> Has not been set by the user yet, so use a default.
double cutoff_frequency_long_ = -1.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused private field

double feedforward_ang_ = 0.0;
double xvel_ = 0.0;
double yvel_ = 0.0;
double thvel_ = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused private fields xvel_, yvel_ and thvel_

{
std::vector<polygon_t> output_vec;
boost::geometry::union_(polygon1, polygon2, output_vec);
return output_vec.at(0); // Only first vector element is filled
Copy link
Contributor

Choose a reason for hiding this comment

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

The union of two polygons can be two polygons if there is no overlap. So this funciton always throws away the second

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good point. We expect them to overlap though, so we should probably warn on size > 1

nh.param<std::string>("base_link_frame", base_link_frame_, "base_link");

nh.param<bool>("use_tricycle_model", use_tricycle_model_, false);
nh.param<std::string>("steered_wheel_frame", steered_wheel_frame_, "steer");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these parameters not part of the dynamic reconfigure set?

Copy link
Member Author

Choose a reason for hiding this comment

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

Vehicles rarely get a fourth wheel on runtime 🙂

And frame-names are assumed to be static in ROS mostly?

Copy link
Contributor

Choose a reason for hiding this comment

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

For me the cfg file is very useful to get a quick look at which parameters are available. It would be nice if all parameters would be described in it. Even if some parameters won't change on runtime

Copy link
Member Author

Choose a reason for hiding this comment

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

Can be done, but then the code should cope with changing them.

lewie-donckers and others added 26 commits March 15, 2022 11:51
Replaced path pose parameter with return value.
…onst

Made Controller::findPositionOnPlan() const.
…-data-member

Replaced distance_to_goal_ data member with local.
…ndex

Moved last visited pose index to find result.
…-parameter

Replaced controller_state parameter of findPositionOnPlan().
Renamed position to pose for findPositionOnPlan.
Replaced Controller::getControllerState().
…g-backwards

fix: Use absolute stopping time to calculate end phase distance
ros-dynamic_reconfigure  1.7.2
ros-path_tracking_pid    2.19.0  ff653a6
ros-roslint              0.12.0
fmessmer added a commit to fmessmer/path_tracking_pid that referenced this pull request May 5, 2022
The old gpl license might make us vulnerable to oudside contributers, as
discussed in the tech share meeting. Let's relicense under Apache-2.0 to
also address some potential patent related issues.

Relicensing requires the consent of all copyright holders. I’ve tracked
down all contributions, and they were all done by people working at
Nobleo. This means Nobleo is the sole copyright holder.
Relicense the code under Apache-2.0
@Timple Timple closed this Jan 10, 2023
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.

None yet

7 participants