dmp_server.cpp
Go to the documentation of this file.
00001 #include "dmp/dmp.h"
00002 using namespace dmp;
00003 
00004 std::vector<DMPData> active_dmp_list;
00005 
00006 bool lfdCallback(LearnDMPFromDemo::Request  &req,
00007                              LearnDMPFromDemo::Response &res )
00008 {
00009         learnFromDemo(req.demo, req.k_gains, req.d_gains, req.num_bases, res.dmp_list);
00010         res.tau = req.demo.times[req.demo.times.size()-1];
00011         return true;
00012 }
00013 
00014 bool planCallback(GetDMPPlan::Request  &req,
00015                               GetDMPPlan::Response &res )
00016 {
00017         generatePlan(active_dmp_list, req.x_0, req.x_dot_0, req.t_0, req.goal, req.goal_thresh,
00018                              req.seg_length, req.tau, req.dt, req.integrate_iter, res.plan, res.at_goal);
00019         return true;
00020 }
00021 
00022 bool activeCallback(SetActiveDMP::Request &req,
00023                                         SetActiveDMP::Response &res )
00024 {
00025         active_dmp_list = req.dmp_list;
00026         res.success = true;
00027         return true;
00028 }
00029 
00030 int main(int argc, char **argv)
00031 {
00032         ros::init(argc, argv, "dmp_server");
00033         ros::NodeHandle n;
00034 
00035         ros::ServiceServer service1 = n.advertiseService("learn_dmp_from_demo", lfdCallback);
00036         ros::ServiceServer service2 = n.advertiseService("get_dmp_plan", planCallback);
00037         ros::ServiceServer service3 = n.advertiseService("set_active_dmp", activeCallback);
00038         ROS_INFO("DMP services now ready");
00039         ros::spin();
00040 
00041         return 0;
00042 }


dmp
Author(s): Scott Niekum
autogenerated on Fri Jan 3 2014 11:19:23