33namespace path_planner
44{
55 QuinticBezierSplines::QuinticBezierSplines (visualization_helper::VisualizationHelper *visu_helper)
6- : previous_spline_(nullptr ), next_spline_(nullptr )
6+ : previous_spline_(nullptr ), next_spline_(nullptr ), start_tangent_magnitude_( 0.25 ), end_tangent_magnitude_( 0.25 )
77 {
88 this ->visu_helper_ = visu_helper;
99 this ->initVisuHelper ();
@@ -22,6 +22,7 @@ namespace path_planner
2222 {
2323 this ->previous_spline_ = previous_spline;
2424 this ->setStartTangent (this ->previous_spline_ ->getEndTangent ());
25+ this ->setStartTangentMagnitude (this ->previous_spline_ ->getEndTangentMagnitude ());
2526 }
2627
2728 void QuinticBezierSplines::setNextSpline (const std::shared_ptr<QuinticBezierSplines> &next_spline)
@@ -36,7 +37,10 @@ namespace path_planner
3637
3738 tf::Vector3 direction_vector (1 , 0 , 0 );
3839 tf::Vector3 rotated_vector = tf::quatRotate (robot_orientation, direction_vector);
39- rotated_vector = 0.5 * rotated_vector * start_to_end_length; // see setEndTangent for 0.5 explanation
40+ // In the paper a factor of 0.5 was used to shorten the tangent. This will no longer be applied directly.
41+ // The factor will now be applied through the Poperty "getMultipliedStartTangent"
42+ // (p. 32 then links to Linear Geometry with Computer Graphics page 318)
43+ rotated_vector = rotated_vector * start_to_end_length;
4044 this ->start_tangent_ << rotated_vector[0 ], rotated_vector[1 ];
4145
4246 ROS_INFO_STREAM (" start_pose_tangent:" << this ->start_tangent_ [0 ] << " | " << this ->start_tangent_ [1 ]);
@@ -47,13 +51,19 @@ namespace path_planner
4751 this ->start_tangent_ = start_tangent;
4852 }
4953
54+ // void QuinticBezierSplines::setMultipliedStartTangent(Eigen::Vector2f start_tangent, float start_tangent_magnitude)
55+ // {
56+ // this->start_tangent_ = start_tangent;
57+ // this->start_tangent_magnitude_ = start_tangent_magnitude;
58+ // }
59+
5060 void QuinticBezierSplines::setEndTangent (tf::Quaternion robot_end_orientation)
5161 {
5262 float start_to_end_length = this ->calcStartToEndLength ();
5363
5464 tf::Vector3 direction_vector (1 , 0 , 0 );
5565 tf::Vector3 rotated_vector = tf::quatRotate (robot_end_orientation, direction_vector);
56- rotated_vector = 0.5 * rotated_vector * start_to_end_length;
66+ rotated_vector = rotated_vector * start_to_end_length;
5767 this ->end_tangent_ << rotated_vector[0 ], rotated_vector[1 ];
5868
5969 ROS_INFO_STREAM (" end_pose_tangent:" << this ->end_tangent_ [0 ] << " | " << this ->end_tangent_ [1 ]);
@@ -80,9 +90,18 @@ namespace path_planner
8090 Eigen::Vector2f angular_bisector = normalized_diff_vector_end_to_next + normalized_diff_vector_start_to_end;
8191 angular_bisector.normalize ();
8292 float length_diff_vector_end_to_next = diff_vector_end_to_next.norm (); // Use length of end point and next point to calculate the length of the tangent
83- this ->end_tangent_ = 0.5 * length_diff_vector_end_to_next * angular_bisector; // This 0.5 value is taken from the paper (p. 32 then links to Linear Geometry with Computer Graphics page 318)
93+ // In the paper a factor of 0.5 was used to shorten the tangent. This will no longer be applied directly.
94+ // The factor will now be applied through the Poperty "getMultipliedEndTangent"
95+ // (p. 32 then links to Linear Geometry with Computer Graphics page 318)
96+ this ->end_tangent_ = length_diff_vector_end_to_next * angular_bisector;
8497 }
8598
99+ // void QuinticBezierSplines::setMultipliedEndTangent(Eigen::Vector2f end_tangent, float end_tangent_magnitude)
100+ // {
101+ // this->end_tangent_ = end_tangent;
102+ // this->end_tangent_magnitude_ = end_tangent_magnitude;
103+ // }
104+
86105 void QuinticBezierSplines::visualizeData ()
87106 {
88107 this ->visu_helper_ ->visualizeMarkerArray (this ->start_end_marker_identificator_ );
@@ -109,11 +128,41 @@ namespace path_planner
109128 return this ->start_tangent_ ;
110129 }
111130
131+ Eigen::Vector2f QuinticBezierSplines::getMultipliedStartTangent ()
132+ {
133+ return this ->start_tangent_magnitude_ * this ->start_tangent_ ;
134+ }
135+
112136 Eigen::Vector2f QuinticBezierSplines::getEndTangent ()
113137 {
114138 return this ->end_tangent_ ;
115139 }
116140
141+ Eigen::Vector2f QuinticBezierSplines::getMultipliedEndTangent ()
142+ {
143+ return this ->end_tangent_magnitude_ * this ->end_tangent_ ;
144+ }
145+
146+ void QuinticBezierSplines::setStartTangentMagnitude (float start_tangent_magnitude)
147+ {
148+ this ->start_tangent_magnitude_ = start_tangent_magnitude;
149+ }
150+
151+ void QuinticBezierSplines::setEndTangentMagnitude (float end_tangent_magnitude)
152+ {
153+ this ->end_tangent_magnitude_ = end_tangent_magnitude;
154+ }
155+
156+ float QuinticBezierSplines::getStartTangentMagnitude ()
157+ {
158+ return this ->start_tangent_magnitude_ ;
159+ }
160+
161+ float QuinticBezierSplines::getEndTangentMagnitude ()
162+ {
163+ return this ->end_tangent_magnitude_ ;
164+ }
165+
117166 float QuinticBezierSplines::calcStartToEndLength ()
118167 {
119168 return std::sqrt (std::pow ((this ->end_pose_ [0 ] - this ->start_pose_ [0 ]), 2 ) + std::pow ((this ->end_pose_ [1 ] - this ->start_pose_ [1 ]), 2 ));
@@ -122,8 +171,8 @@ namespace path_planner
122171 void QuinticBezierSplines::calcControlPoints ()
123172 {
124173 // This formula comes from S'(0) and S'(1). Has to be (1/5)
125- this ->cp1_ = (1.0 / 5.0 ) * this ->start_tangent_ + this ->start_pose_ ;
126- this ->cp4_ = -(1.0 / 5.0 ) * this ->end_tangent_ + this ->end_pose_ ;
174+ this ->cp1_ = (1.0 / 5.0 ) * this ->getMultipliedStartTangent () + this ->start_pose_ ;
175+ this ->cp4_ = -(1.0 / 5.0 ) * this ->getMultipliedEndTangent () + this ->end_pose_ ;
127176
128177 std::shared_ptr<path_planner::CubicBezierSplines> previous_spline = nullptr ;
129178 std::shared_ptr<path_planner::CubicBezierSplines> current_spline = nullptr ;
@@ -144,6 +193,7 @@ namespace path_planner
144193 previous_spline->setStartTangent (this ->previous_spline_ ->getStartTangent ());
145194 previous_spline->setNextSpline (current_spline);
146195 previous_spline->calcControlPoints (); // Everything is set for the previous spline. Control points can be calculated
196+
147197 current_spline->setPreviousSpline (previous_spline);
148198 }
149199 else
@@ -226,14 +276,7 @@ namespace path_planner
226276 result_vector << 0 , 0 ;
227277 for (int counter = 0 ; counter < point_matrix.size (); counter++)
228278 {
229- // ROS_INFO_STREAM("ITERATION");
230- // ROS_INFO_STREAM(bernstein_polynom_vector[counter]);
231- // ROS_INFO_STREAM(result_vector);
232- // ROS_INFO_STREAM(point_matrix[counter]);
233- // ROS_INFO_STREAM((bernstein_polynom_vector[counter] * point_matrix[counter]));
234- // ROS_INFO_STREAM(result_vector);
235-
236- result_vector = result_vector + (bernstein_polynom_vector[counter] * point_matrix[counter]);
279+ result_vector = result_vector + (bernstein_polynom_vector[counter] * point_matrix[counter]);
237280 }
238281 return result_vector;
239282 }
@@ -242,6 +285,11 @@ namespace path_planner
242285 {
243286 std::shared_ptr<path_planner::CubicBezierSplines> cubic_spline =
244287 std::make_shared<path_planner::CubicBezierSplines>(this ->visu_helper_ , this ->start_pose_ , this ->end_pose_ );
288+
289+ // Set the magnitudes as these are settings that affect the splines deeply
290+ cubic_spline->setStartTangentMagnitude (this ->start_tangent_magnitude_ );
291+ cubic_spline->setEndTangentMagnitude (this ->end_tangent_magnitude_ );
292+
245293 return cubic_spline;
246294 }
247295
@@ -311,13 +359,19 @@ namespace path_planner
311359
312360 bool QuinticBezierSplines::checkMinCurveRadiusOnSpline (int resolution, float min_curve_radius)
313361 {
314- for (int counter = 0 ; counter <= resolution; counter++)
362+ int point_of_failure_dummy = 0 ;
363+ return this ->checkMinCurveRadiusOnSpline (resolution, min_curve_radius, point_of_failure_dummy);
364+ }
365+
366+ bool QuinticBezierSplines::checkMinCurveRadiusOnSpline (int resolution, float min_curve_radius, int &point_of_failure)
367+ {
368+ for (point_of_failure = 0 ; point_of_failure <= resolution; point_of_failure++)
315369 {
316370 // ROS_INFO_STREAM("iterator: " << counter << " | " << float(counter) / float(resolution));
317371 // Eigen::Vector2f point = this->calcPointOnBezierSpline(float(counter) / float(resolution));
318372 // ROS_INFO_STREAM("x: " << point[0] << " y: " << point[1]);
319373
320- if (!this ->checkMinCurveRadiusAtPoint ((float (counter ) / float (resolution)), min_curve_radius))
374+ if (!this ->checkMinCurveRadiusAtPoint ((float (point_of_failure ) / float (resolution)), min_curve_radius))
321375 {
322376 return false ;
323377 }
0 commit comments