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

how to call service set_camera_info of gscam package

asked 2012-09-11 05:44:26 -0500

aldo85ita gravatar image

updated 2012-09-11 07:01:15 -0500

joq gravatar image

Hi everybody, I'd like to call set_camera_info (sensor_msgs/SetCameraInfo) of gscam (http://www.ros.org/wiki/gscam). To do this, I've built a simple application:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/SetCameraInfo.h>
#include <camera_calibration_parsers/parse_ini.h>
#include <cstdlib>
#include <vector>
using namespace std;
int main(int argc, char **argv)
{
  ros::init(argc, argv, "set_camera_info");
  if (argc != 2)
  {
    ROS_INFO("usage: set_camera_info gscam/set_camera_info");
    return 1;
  }

  ros::NodeHandle n;
  ros::ServiceClient client = n.serviceClient<sensor_msgs::SetCameraInfo>("gscam/set_camera_info");
  sensor_msgs::SetCameraInfo srv;
  srv.request.camera_info.width = 1344;
  srv.request.camera_info.height =372;
  boost::array<double, 9>  K1 ={894.1981 ,0.0, 660.1406, 0.0, 892.7151, 261.1004, 0.0, 0.0, 1.0};
  srv.request.camera_info.K=K1;
  if (client.call(srv))
  {
    ROS_INFO("service called");
  }
  else
  {
    ROS_ERROR("Failed to call service gscam/set_camera_info");
    return 1;
  }

  return 0;
}

But if I try to execute I'll get the following error:

[ERROR] [1347377843.117168101]: Failed to call service gscam/set_camera_info

What's going wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-09-11 06:21:44 -0500

dornhege gravatar image
  1. Is the service actually up and running and thus does your call arrive at gscam? (you can check with serviceclient::exists)

  2. If that worked, something failed. You'll probably get some helpful output from gscam itself.

edit flag offensive delete link more

Comments

I used the following instruction to fix the problem: camera_calibration_parsers::readCalibrationIni("gscam/camera_parameters_2010_03_09_calib.txt", camera_name,camera_info) So,reading camera info from file I can create a right CameraInfo structure.

aldo85ita gravatar image aldo85ita  ( 2012-09-11 07:01:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-09-11 05:44:26 -0500

Seen: 657 times

Last updated: Sep 11 '12