iiwa_stack icon indicating copy to clipboard operation
iiwa_stack copied to clipboard

‘ConfigureControlMode’ is not a member of ‘iiwa_msgs’

Open PavanMantripragada opened this issue 1 year ago • 1 comments

Hi,

I'm trying to run a "ConfigureControlMode" service to change my control mode. I've written a cpp code to call the service. However, my code doesn't compile. The error I get is : ‘ConfigureControlMode’ is not a member of ‘iiwa_msgs’. Isn't this a member of iiwa_msgs class? Do I need to add any extra header files? please let me know. I'm attaching my code for your reference.


#include "iiwa_ros/conversions.hpp"
#include "iiwa_ros/service/iiwa_services.hpp"

int main(int argc, char **argv)
{
  ros::init(argc, argv, "tool_gc");

  ros::NodeHandle nh;
  ros::ServiceClient client = nh.serviceClient<iiwa_msgs::ConfigureControlMode>("/iiwa/configuration/configureControlMode");
  iiwa_msgs::ConfigureControlMode config;

  config.control_mode = iiwa_msgs::ControlMode::DESIRED_FORCE; // This is equal to config.control_mode = 3.
  config.desired_force. cartesian_dof = iiwa_msgs::DOF::Z; // This is equal to config.desired_force.cartesian_dof = 3.
  config.desired_force.desired_force = 2.0; // 2 Newtons
  config.desired_force. desired_stiffness = 100; // stiffness to 100 N/m

  if (client.call(config)) {
      if(!config.response.success)
          ROS_ERROR_STREAM("Config failed, Java error: " << config.response.error);
      else
          ROS_INFO_STREAM("SmartServo Service successfully called.");
  }
  else {
      ROS_ERROR_STREAM("Config failed - service could not be called - QUITTING NOW !");
  }
}

PavanMantripragada avatar Jul 21 '22 22:07 PavanMantripragada

Hi @PavanMantripragada, you need to add header file generated from the ConfigureControlMode.srv file. At the top of the file, simply add

#include "iiwa_msgs/ConfigureControlMode.hpp"

jkaniuka avatar Jun 11 '23 10:06 jkaniuka