Rosservice without arguments

asked 2021-09-27 05:58:55 -0500

ros_max gravatar image

updated 2021-09-27 06:48:11 -0500

Hallo,

i want to establish a server without any arguments, so i call it like that: rosservice call /InputVoltage and just receive some output.

my code looks like that:

bool InputVoltage(ros_dc2412_upsd::InputVoltage::Response &req,
                  ros_dc2412_upsd::InputVoltage::Response &res)
{
  std::string string_var;
  ros::param::get("/string_a", string_var);

  DC2412 First(string_var);
  res.sum = First.InputVoltage();
  return true;
}


int main(int argc, char **argv)
{

  ros::init(argc, argv, "InputVoltage_server");
  ros::NodeHandle n;

  ros::ServiceServer service1 = n.advertiseService("InputVoltage", InputVoltage);


  ROS_INFO("Ready to deliver Inputvoltage");
  ros::spin();

  return 0;
}

my srv code:

---
int64 sum

if i run my code i recieve:

ERROR: Incompatible arguments to call service:

thanks for helping

edit retag flag offensive close merge delete

Comments

This is just a comment, but: reading from the parameter server as part of a service request is not really considered best-practice. Is string_a in reality a (set of) parameter(s) which could be part of the service request? That would perhaps be a more correct usage of the service API.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-27 06:30:08 -0500 )edit