00001 #ifndef STARMAC_ROBOTS_ASCTEC_MISC_H 00002 #define STARMAC_ROBOTS_ASCTEC_MISC_H 00003 00004 #include <algorithm> 00005 00006 namespace starmac_robots_asctec 00007 { 00008 template<typename Tx, typename Tt> 00009 void limitSlewRate(Tx x, Tx x_prev, Tt dt, Tx rate_limit, Tx& x_limited) 00010 { 00011 Tx limit = rate_limit * dt; 00012 x_limited = max(x_prev - limit, min(x_prev + limit, x)); 00013 } 00014 } 00015 #endif