25 #define PI 3.14159265358979323846 29 const double C = abs(
A-
B) / sqrt(4*
A*
B);
43 double _px,_py,_vx,
_vy;
54 _position=pair<double,double>(x,y);
55 _velocity=pair<double,double>(vx,vy);
65 pair<double,double>
get_vector(pair<double,double> start,pair<double,double> end)
67 pair<double,double> re=pair<double,double>(0,0);
68 re.first=end.first-start.first;
69 re.second=end.second-start.second;
75 double re =
EPSILON*(v.first*v.first+v.second*v.second);
86 pair<double,double> re = pair<double,double>(0,0);
87 double scale = 1+
EPSILON*(v.first*v.first+v.second*v.second);
89 re.first = v.first / scale;
90 re.second = v.second / scale;
96 return z / sqrt(1+z*z);
110 return 0.5*(1+cos(
PI*(z-
H)/(1-
H)));
120 pair<double,double> re = pair<double,double>(0,0);
131 double a_ij(pair<double,double> j_p)
138 pair<double,double> re = pair<double,double>(0,0);
142 re.first +=
a_ij((*i)->_position) * p_ij.first;
143 re.second +=
a_ij((*i)->_position) * p_ij.second;
151 pair<double,double> re = pair<double,double>(0,0);
152 static pair<double,double> q_r = pair<double,double>(0,0);
153 pair<double,double> p_r = pair<double,double>(0.5,0.5);
155 q_r.second += p_r.second *
interval;
166 OlfatiSaberFlocking::OlfatiSaberFlocking() {}
168 OlfatiSaberFlocking::~OlfatiSaberFlocking() {}
170 void OlfatiSaberFlocking::stop() {}
172 void OlfatiSaberFlocking::init()
181 geometry_msgs:: Twist msg;
184 typename std::map<int, micros_swarm::NeighborBase>::iterator it;
185 for(it=n.
data().begin();it!=n.
data().end();it++)
202 if (msg.linear.x <-1)
206 if (msg.linear.y <-1)
213 void OlfatiSaberFlocking::baseCallback(
const nav_msgs::Odometry& lmsg)
215 float x=lmsg.pose.pose.position.x;
216 float y=lmsg.pose.pose.position.y;
218 float vx=lmsg.twist.twist.linear.x;
219 float vy=lmsg.twist.twist.linear.y;
225 void OlfatiSaberFlocking::start()
231 pub = nh.
advertise<geometry_msgs::Twist>(
"cmd_vel", 1000);
pair< double, double > my_position
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void init(const M_string &remappings)
pair< double, double > f_g()
pair< double, double > segma_epsilon(pair< double, double > v)
pair< double, double > f_d()
double segma_norm(pair< double, double > v)
pair< double, double > get_vector(pair< double, double > start, pair< double, double > end)
pair< double, double > my_velocity
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
std::map< int, Type > & data()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
pair< double, double > _velocity
NeighborHandle(int r_id, float x, float y, float vx, float vy)
double phi_alpha(double z)
double a_ij(pair< double, double > j_p)
static list< NeighborHandle * > neighbor_list
pair< double, double > f_r()
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)