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

Estimate velocity #1

Open
wants to merge 3 commits into
base: estimate_velocity
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,29 @@
class VelocityEstimator {
double overflow_;
double overflow_twice_;
double last_pos_;
double last_pos_, last_val_;
double norm(double val){
while(val >= overflow_){
/*********HACK***********/
if(std::abs(val)>overflow_) {
const double tmp = last_val_;
last_val_ = 0
return tmp;
}

/*while(val >= overflow_){
val -= overflow_twice_;
}
while(val < -overflow_){
val += overflow_twice_;
}
return val;
}*/

return last_val_ = val;
}
public:
VelocityEstimator(double overflow) : overflow_(overflow), overflow_twice_(overflow*2) { reset(); }
VelocityEstimator(double overflow) : overflow_(overflow), overflow_twice_(overflow*2), last_pos_(0.), last_val_(0.) { reset(); }
double estimateVelocity(double pos, double vel, double period) {
if(overflow_ > 0 && period > 0 && !std::isnan(last_pos_)) vel = norm( pos - last_pos_) / period;
else if(overflow_ < 0 && period > 0 && !std::isnan(last_pos_)) vel = ( pos - last_pos_) / period;
else if(overflow_ <= 0 && period > 0 && !std::isnan(last_pos_)) vel = ( pos - last_pos_) / period;
last_pos_ = pos;
return vel;
}
Expand Down
1 change: 1 addition & 0 deletions cob_twist_controller/src/augmented_solver.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ros/ros.h"

#include "cob_twist_controller/augmented_solver.h"
#include <Eigen/Geometry>


augmented_solver::augmented_solver(const KDL::Chain& chain, double eps, int maxiter):
Expand Down