ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I tried it but getting the same error as below during build

homing_sequence_server.cpp.o /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:7:8: error: expected ‘,’ or ‘...’ before ‘biclops’ /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp: In function ‘int main(int, char)’: /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:20:11: warning: deprecated conversion from string constant to ‘char’ [-Wwrite-strings] /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:21:74: error: no matching function for call to ‘ros::NodeHandle::advertiseService(const char [16], bool (&)(biclops::HomingSequence::Request&))’ /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:21:74: note: candidates are: /opt/ros/groovy/include/ros/node_handle.h:821:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(MReq&, MRes&), T) /opt/ros/groovy/include/ros/node_handle.h:859:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(ros::ServiceEvent<mreq, mres="">&), T) /opt/ros/groovy/include/ros/node_handle.h:898:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(MReq&, MRes&), const boost::shared_ptr<x>&) /opt/ros/groovy/include/ros/node_handle.h:938:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(ros::ServiceEvent<mreq, mres="">&), const boost::shared_ptr<x>&) /opt/ros/groovy/include/ros/node_handle.h:975:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool ()(MReq&, MRes&)) /opt/ros/groovy/include/ros/node_handle.h:1011:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool ()(ros::ServiceEvent<mreq, mres="">&)) /opt/ros/groovy/include/ros/node_handle.h:1045:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, const boost::function<bool(mreq&amp;, mres&amp;)&gt;&amp;,="" const="" voidconstptr&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1083:17:="" note:="" template<class="" s=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, const boost::function<bool(s&amp;)&gt;&amp;, const="" voidconstptr&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1111:17:="" note:="" ros::serviceserver="" ros::nodehandle::advertiseservice(ros::advertiseserviceoptions&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1111:17:="" note:="" candidate="" expects="" 1="" argument,="" 2="" provided="" make[2]:="" *<="" strong=""> [CMakeFiles/homing_sequence_server.dir/src/homing_sequence_server.cpp.o] Error 1 make[1]: [CMakeFiles/homing_sequence_server.dir/all] Error 2 make: * [all] Error 2

In fact my srv file has only input argument for request, just string path .

I tried Thank you it but getting the same error as below during buildworked

homing_sequence_server.cpp.o /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:7:8: error: expected ‘,’ or ‘...’ before ‘biclops’ /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp: In function ‘int main(int, char)’: /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:20:11: warning: deprecated conversion from string constant to ‘char’ [-Wwrite-strings] /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:21:74: error: no matching function for call to ‘ros::NodeHandle::advertiseService(const char [16], bool (&)(biclops::HomingSequence::Request&))’ /home/yeshi/catkin_ws/src/biclops/src/homing_sequence_server.cpp:21:74: note: candidates are: /opt/ros/groovy/include/ros/node_handle.h:821:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(MReq&, MRes&), T) /opt/ros/groovy/include/ros/node_handle.h:859:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(ros::ServiceEvent<mreq, mres="">&), T) /opt/ros/groovy/include/ros/node_handle.h:898:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(MReq&, MRes&), const boost::shared_ptr<x>&) /opt/ros/groovy/include/ros/node_handle.h:938:17: note: template<class t,="" class="" mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::)(ros::ServiceEvent<mreq, mres="">&), const boost::shared_ptr<x>&) /opt/ros/groovy/include/ros/node_handle.h:975:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool ()(MReq&, MRes&)) /opt/ros/groovy/include/ros/node_handle.h:1011:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool ()(ros::ServiceEvent<mreq, mres="">&)) /opt/ros/groovy/include/ros/node_handle.h:1045:17: note: template<class mreq,="" class="" mres=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, const boost::function<bool(mreq&amp;, mres&amp;)&gt;&amp;,="" const="" voidconstptr&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1083:17:="" note:="" template<class="" s=""> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, const boost::function<bool(s&amp;)&gt;&amp;, const="" voidconstptr&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1111:17:="" note:="" ros::serviceserver="" ros::nodehandle::advertiseservice(ros::advertiseserviceoptions&amp;)="" opt="" ros="" groovy="" include="" ros="" node_handle.h:1111:17:="" note:="" candidate="" expects="" 1="" argument,="" 2="" provided="" make[2]:="" *<="" strong=""> [CMakeFiles/homing_sequence_server.dir/src/homing_sequence_server.cpp.o] Error 1 make[1]: [CMakeFiles/homing_sequence_server.dir/all] Error 2 make: * [all] Error 2

In fact my srv file has only input argument for request, just string path .

Thank you it worked

worked. Now when I launch the server.cpp node I could able to see the service in rosnode info or service list but if i put the service inside the main node.cpp file I cannot see the service being advertised

include <ros ros.h="">

include <cstdio> // for FILE defn

include <iostream> // for cout, etc

include <time.h> // for clock_t and clock

include <list>

include <string>

include <cstring>

include <sensor_msgs jointstate.h="">

include "turtlesim/Velocity.h"

include <biclops homingsequence.h="">

using namespace std; using namespace ros;

include <biclops.h>

include <pmdutils.h>

// Defines which axes we want to use. int axisMask=Biclops::PanMask + Biclops::TiltMask;;

// Pointers to each axis (populated once controller is initialized). PMDAxisControl *panAxis = NULL; PMDAxisControl *tiltAxis = NULL;

// THE interface to Biclops Biclops biclops_obj;

ros::Subscriber key_sub; ros::Publisher joint_pub; sensor_msgs::JointState joint_state;

bool Homing(biclops::HomingSequence::Request &req, biclops::HomingSequence::Request &res){

ROS_INFO("Performing Homing Sequence");
//biclops.Initialize(&req.path);
return true;

}

//---------------------------------------------------------------------------- int main (int argc, char *argv[]) {

ros::init(argc,argv,"Biclops"); ROS_INFO("node creation"); ros::NodeHandle nh; ros::Rate loop_rate(10);

  // ROS_INFO("ARGV : %s ",argv[1]);
argv[1]="/home/yeshi/catkin_ws/src/biclops/BiclopsDefault.cfg";

ROS_INFO( "\n\nBasic Biclops Running Example\n\n" );
//Initializing

    cout<<"Initialization Routine"<<biclops_obj.Initialize(argv[1])<<endl;

if (!biclops_obj.Initialize(argv[1]))
{

    ROS_INFO( "Failed to open Biclops Communication\n" );
    ROS_INFO( "Press Enter key to terminate...\n" );
    getchar();
    //return 0;
}
else
        ROS_INFO( "Succeed to open Biclops Communication\n" );





//Homing sequence Service
ros::ServiceServer service =nh.advertiseService("homing_sequence",Homing);



// Get shortcut references to each axis.
panAxis = biclops_o
while(ros::ok() ){

spin();


loop_rate.sleep();

}


return 0;

}

What am I missing. I made the same changes as needed for the server.cpp file in the CMakeLists.txt. Please help me