@@ -156,9 +156,55 @@ TrajRef Temporal_Traj::getDefaultReference( rclcpp::Duration cur_time )
156156 return ref_state;
157157}
158158
159+ /* * LEMISCATE OF BERNOULLI / Figure-8:
160+ * pn = A*cos(wt)/(1+sin^2(wt))
161+ * pe = A*sin(wt*)cos(wt)/(1+sin^2(wt))
162+ * vn = {A*w*sin(wt)(sin^2(wt)−3)}/{(sin^2(wt)+1)^2}
163+ * ve = {2*A*w*(3*cos(2*wt)−1)}/{(cos(2*wt)−3)^2}
164+ */
165+ TrajRef Temporal_Traj::getLemiscateReference ( rclcpp::Duration cur_time, const int agg_level)
159166{
167+ // A is amplitude (radius); w angular rate such that 2pi/w = (seconds for one rev)
168+ float A = 0.5 ;
169+ float w = 0.5 ;
160170
171+ // Set A and w based on agg_level
172+ switch (agg_level)
173+ {
174+ case 1 :
175+ break ;
176+ case 2 :
177+ A = 0.5 ;
178+ w = 1 ;
179+ break ;
180+ case 3 :
181+ A = 1 ;
182+ w = 3 ;
183+ break ;
184+ default :
185+ RCLCPP_WARN (get_logger (), " Lemiscate aggression %d not supported, defaulting to agg_level 1" , agg_level);
186+ }
187+
188+ float t = cur_time.seconds ();
189+
190+ // Create reference state
191+ TrajRef ref_state;
192+ ref_state.header .stamp = now ();
193+
194+ ref_state.pn = A * std::cos (w*t)/(1 +pow (std::sin (w*t),2 ));
195+ ref_state.pe = A * std::sin (w*t)*std::cos (w*t)/(1 +pow (std::sin (w*t),2 ));
196+ ref_state.pd = -4.0 ;
161197
198+ ref_state.vn = ( A * w * std::sin (w*t)*( pow (std::sin (w*t),2 )-3 )) / ( pow ( pow ( std::sin (w*t),2 )+1 ,2 ));
199+ ref_state.ve = ( 2 * A * w * (3 *std::cos (2 *w*t)-1 )) / ( pow ( std::cos (2 *w*t)-3 , 2 ) );
200+ ref_state.vd = 0.0 ;
201+
202+ ref_state.yaw = 0.0 ;
203+
204+ // set an, ae, ad to second derivatives if needed for FF..
205+ return ref_state;
206+
207+ }
162208
163209int main (int argc, char * argv[])
164210{
0 commit comments