32 TestSCDSPSO::TestSCDSPSO() {}
34 TestSCDSPSO::~TestSCDSPSO() {}
36 void TestSCDSPSO::init() {}
38 void TestSCDSPSO::stop() {}
46 data.
val = get_id() + i;
47 tuple.put(
"test_scds_pso", data);
50 std::cout<<
"robot: "<<get_id()<<
", best: "<<best.
val<<std::endl;
53 void TestSCDSPSO::baseCallback(
const nav_msgs::Odometry& lmsg)
55 float x=lmsg.pose.pose.position.x;
56 float y=lmsg.pose.pose.position.y;
58 float vx=lmsg.twist.twist.linear.x;
59 float vy=lmsg.twist.twist.linear.y;
65 float TestSCDSPSO::fitness(
const std::vector<float>& vec)
69 float fitness = -(20+x*x+y*y-10*cos(2*
PI*x)-10*cos(2*
PI*y));
73 void TestSCDSPSO::start()
75 agent.set_param(1, 1.49445, 1.49445);
77 agent.set_fitness(boost::bind(&TestSCDSPSO::fitness,
this, _1));
79 std::vector<float> max_pos;
83 agent.set_max_pos(max_pos);
85 std::vector<float> min_pos;
89 agent.set_min_pos(min_pos);
91 std::vector<float> max_vel;
95 agent.set_max_vel(max_vel);
97 std::vector<float> min_vel;
101 agent.set_min_vel(min_vel);
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)