25 #define BARRIER_VSTIG 1 55 epsilon_nonkin = 1000;
58 float App2::force_mag_kin(
float dist)
60 return -(epsilon_kin/(dist+0.1)) *(pow(delta_kin/(dist+0.1), 4) - pow(delta_kin/(dist+0.1), 2));
63 float App2::force_mag_nonkin(
float dist)
65 return -(epsilon_nonkin/(dist+0.1)) *(pow(delta_nonkin/(dist+0.1), 4) - pow(delta_nonkin/(dist+0.1), 2));
77 float dist = sqrt(pow((xl-xn),2)+pow((yl-yn),2));
79 float fm = force_mag_kin(dist)/1000;
84 float fx = (fm/(dist+0.1))*(xn-xl);
85 float fy = (fm/(dist+0.1))*(yn-yl);
101 float dist = sqrt(pow((xl-xn),2)+pow((yl-yn),2));
103 float fm = force_mag_nonkin(dist)/1000;
108 float fx = (fm/(dist+0.1))*(xn-xl);
109 float fy = (fm/(dist+0.1))*(yn-yl);
116 XY App2::direction_red()
123 boost::function<XY(micros_swarm::NeighborBase, XY &)> bf_kin = boost::bind(&App2::force_sum_kin,
this, _1, _2);
124 boost::function<XY(micros_swarm::NeighborBase, XY &)> bf_nonkin = boost::bind(&App2::force_sum_nonkin,
this, _1, _2);
131 XY App2::direction_blue()
138 boost::function<XY(micros_swarm::NeighborBase, XY &)> bf_kin = boost::bind(&App2::force_sum_kin,
this, _1, _2);
139 boost::function<XY(micros_swarm::NeighborBase, XY &)> bf_nonkin = boost::bind(&App2::force_sum_nonkin,
this, _1, _2);
146 bool App2::red(
int id)
154 bool App2::blue(
int id)
164 XY v = direction_red();
165 geometry_msgs::Twist t;
174 XY v = direction_blue();
175 geometry_msgs::Twist t;
182 void App2::motion_red()
188 void App2::motion_blue()
194 void App2::baseCallback(
const nav_msgs::Odometry& lmsg)
196 float x = lmsg.pose.pose.position.x;
197 float y = lmsg.pose.pose.position.y;
199 float vx = lmsg.twist.twist.linear.x;
200 float vy = lmsg.twist.twist.linear.y;
212 pub = nh.
advertise<geometry_msgs::Twist>(
"cmd_vel", 1000);
215 boost::function<bool()> bfred = boost::bind(&App2::red,
this, get_id());
216 boost::function<bool()> bfblue = boost::bind(&App2::blue,
this, get_id());
221 blue_swarm.
select(bfblue);
226 red_swarm.
execute(boost::bind(&App2::motion_red,
this));
227 blue_swarm.
execute(boost::bind(&App2::motion_blue,
this));
Neighbors< Type > nonkin(int swarm_id)
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)
void execute(const boost::function< void()> &f)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void select(const boost::function< bool()> &bf)
Neighbors< Type > kin(int swarm_id)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)