Hi
I have inserted a shortened version of my files below, but first i'll try to explain my problem. My problem is that I want to define a MoveTo() function within skills.cpp, which uses actionlib client acUR5. I can't define the MoveTo() function without defining acUr5 before the definition of the MoveTo() function in skills.cpp. The acUr5 needs ros::init(), which first have been defined in the main() function. Thus then I run execute_actionlib_client.cpp. I get the error showed in the bottom of this post.
execute_actionlib_client.cpp:
#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <rq3_proxy/rq3Action.h>
#include <ur5_proxy/ur5Action.h>
#include "skills/skills.hpp"
int main (int argc, char **argv){
ros::init(argc, argv, "skills_node");
actionlib::SimpleActionClient<rq3_proxy::rq3Action> acRq3("rq3proxynode", true);
actionlib::SimpleActionClient<ur5_proxy::ur5Action> acUr5("ur5Node", true);
rq3_proxy::rq3Goal goalRq3;
ur5_proxy::ur5Goal goalUr5;
MoveTo();
Skills.cpp:
#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <rq3_proxy/rq3Action.h>
#include <ur5_proxy/ur5Action.h>
#include "skills.hpp"
actionlib::SimpleActionClient<rq3_proxy::rq3Action> acRq3("rq3proxynode", true);
actionlib::SimpleActionClient<ur5_proxy::ur5Action> acUr5("ur5Node", true); // PROBLEM
rq3_proxy::rq3Goal goalRq3;
ur5_proxy::ur5Goal goalUr5;
void MoveTo(){
//Viapoint, becore place
acUr5.sendGoalAndWait(move("j", "car", 60,-508, 212, 1.7574, 0.7509, 1.714, 2, 0, 0, goalUr5),ros::Duration(30.0),ros::Duration(30.0));
ROS_INFO("Viapoint 2 finished");
}
Problem when run:
private@pc:~/ros_ws/devel_ws$ rosrun skills execute_actionlib_client
[FATAL] [1384343030.296120354]: You must call ros::init() before creating the first NodeHandle
[FATAL] [1384343030.296325757]: BREAKPOINT HIT
file = /tmp/buildd/ros-groovy-roscpp-1.9.50-0precise-20131015-2117/src/libros/node_handle.cpp
line=151
Trace/breakpoint trap (core dumped)
I hope you understand the problem and that you can help
Originally posted by mortenpj on ROS Answers with karma: 70 on 2013-11-13
Post score: 1