23 priv_node_handle_(
"~"),
49 file = YAML::LoadFile(yaml_file.c_str());
54 YAML::Node joint = file[
"joint"];
55 uint8_t joint_size = joint[
"names"].size();
57 for (uint8_t index = 0; index < joint_size; index++)
59 std::string joint_name = joint[
"names"][index].as<std::string>();
60 jnt_tra_msg->joint_names.push_back(joint[
"names"][index].as<std::string>());
63 YAML::Node motion = file[
"motion"];
64 uint8_t motion_size = motion[
"names"].size();
66 for (uint8_t index = 0; index < motion_size; index++)
68 trajectory_msgs::JointTrajectoryPoint jnt_tra_point;
70 std::string name = motion[
"names"][index].as<std::string>();
71 YAML::Node motion_name = motion[name];
72 for (uint8_t size = 0; size < joint_size; size++)
74 if (joint_size != motion_name[
"step"].size())
76 ROS_ERROR(
"Please check motion step size. It must be equal to joint size");
80 jnt_tra_point.positions.push_back(motion_name[
"step"][size].as<double>());
82 ROS_INFO(
"motion_name : %s, step : %f", name.c_str(), motion_name[
"step"][size].as<
double>());
85 if (motion_name[
"time_from_start"] == NULL)
87 ROS_ERROR(
"Please check time_from_start. It must be set time_from_start each step");
91 jnt_tra_point.time_from_start.fromSec(motion_name[
"time_from_start"].as<double>());
93 ROS_INFO(
"time_from_start : %f", motion_name[
"time_from_start"].as<double>());
95 jnt_tra_msg->points.push_back(jnt_tra_point);
102 std_srvs::Trigger::Response &res)
107 res.message =
"Success to publish joint trajectory";
112 int main(
int argc,
char **argv)
118 ROS_INFO(
"For now, you can use publish joint trajectory msgs by triggering service(/execution)");
120 if (joint_operator.
isLoop())
124 std_srvs::Trigger trig;
ros::Publisher joint_trajectory_pub_
void publish(const boost::shared_ptr< M > &message) const
trajectory_msgs::JointTrajectory * jnt_tra_msg_
ros::NodeHandle node_handle_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool getTrajectoryInfo(const std::string yaml_file, trajectory_msgs::JointTrajectory *jnt_tra_msg)
int main(int argc, char **argv)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::ServiceServer move_command_server_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool moveCommandMsgCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
ros::NodeHandle priv_node_handle_