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

How to enable stiffness using C++

asked 2014-03-03 05:57:24 -0600

borghetti gravatar image

updated 2016-10-24 09:02:45 -0600

ngrennan gravatar image

Hello,

I want to enable/disable the stiffness using C++ API. But I don't know how to instantiate a service variable. I am not sure about what should I put between "<>". The code is attached bellow. Anyone can help me?

  ros::init(argc, argv, "controller");
  ros::NodeHandle n;
  ros::Publisher controller_pub = n.advertise<geometry_msgs::Twist>("/cmd_vel", 1000);
  ros::Rate loop_rate(10);
  int count = 0;

  ros::ServiceClient client = n.serviceClient<??>("/body_stiffness/enable");
  while (ros::ok())
  {
      geometry_msgs::Twist control;
      control.linear.x = 1;
      control.linear.y = 0;
      control.angular.z = 0;
      controller_pub.publish(control);  
      ros::spinOnce();

      loop_rate.sleep();
      ++count;
  }
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2014-03-03 06:09:50 -0600

According to the nao_driver wiki page, it's an empty service, so you would use std_srvs::Empty:

ros::ServiceClient client = n.serviceClient<std_srvs::Empty>("/body_stiffness/enable");
edit flag offensive delete link more
0

answered 2014-03-03 06:09:17 -0600

dornhege gravatar image

The type of service that you are calling. I don't know what that is for what you're asking, but you should have an idea about it. After all you want to put in or get back some specific data.

edit flag offensive delete link more

Comments

Hi, This code is just to make the robot walk in a straight line. But to do that I must enable the stiffness before. I've changed the code and it compiled and ran successfully. Thank you!

borghetti gravatar image borghetti  ( 2014-03-03 20:22:24 -0600 )edit

Question Tools

Stats

Asked: 2014-03-03 05:57:24 -0600

Seen: 209 times

Last updated: Mar 03 '14