oscillation.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Locus Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef DWB_CRITICS_OSCILLATION_H_
36 #define DWB_CRITICS_OSCILLATION_H_
37 
39 #include <vector>
40 #include <string>
41 
42 namespace dwb_critics
43 {
44 
80 {
81 public:
82  void onInit() override;
83  bool prepare(const geometry_msgs::Pose2D& pose, const nav_2d_msgs::Twist2D& vel,
84  const geometry_msgs::Pose2D& goal, const nav_2d_msgs::Path2D& global_plan) override;
85  double scoreTrajectory(const dwb_msgs::Trajectory2D& traj) override;
86  void reset() override;
87  void debrief(const nav_2d_msgs::Twist2D& cmd_vel) override;
88 
89 protected:
95  {
96  public:
97  CommandTrend();
98  void reset();
99 
105  bool update(double velocity);
106 
112  bool isOscillating(double velocity);
113 
118  bool hasSignFlipped();
119 
120  protected:
121  // Simple Enum for Tracking
122  enum class Sign { ZERO, POSITIVE, NEGATIVE };
123 
126  };
127 
133  bool setOscillationFlags(const nav_2d_msgs::Twist2D& cmd_vel);
134 
138  bool resetAvailable();
139 
143 
144  // Cached square parameter
146 
147  // Saved positions
148  geometry_msgs::Pose2D pose_, prev_stationary_pose_;
149  // Saved timestamp
151 };
152 
153 } // namespace dwb_critics
154 #endif // DWB_CRITICS_OSCILLATION_H_
bool hasSignFlipped()
Check whether we are currently tracking a flipped sign.
Definition: oscillation.cpp:89
bool update(double velocity)
update internal flags based on the commanded velocity
Definition: oscillation.cpp:60
void debrief(const nav_2d_msgs::Twist2D &cmd_vel) override
Checks to see whether the sign of the commanded velocity flips frequently.
Definition: oscillation.h:79
bool isOscillating(double velocity)
Check to see whether the proposed velocity would be considered oscillating.
Definition: oscillation.cpp:84
bool setOscillationFlags(const nav_2d_msgs::Twist2D &cmd_vel)
Given a command that has been selected, track each component&#39;s sign for oscillations.
geometry_msgs::Pose2D prev_stationary_pose_
Definition: oscillation.h:148
geometry_msgs::Pose2D pose_
Definition: oscillation.h:148
bool resetAvailable()
Return true if the robot has travelled far enough or waited long enough.
Helper class for performing the same logic on the x,y and theta dimensions.
Definition: oscillation.h:94
double scoreTrajectory(const dwb_msgs::Trajectory2D &traj) override
bool prepare(const geometry_msgs::Pose2D &pose, const nav_2d_msgs::Twist2D &vel, const geometry_msgs::Pose2D &goal, const nav_2d_msgs::Path2D &global_plan) override


dwb_critics
Author(s): David V. Lu!!
autogenerated on Sun Jan 10 2021 04:08:44