franka_combined_control_node.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Franka Emika GmbH
2 // Use of this source code is governed by the Apache-2.0 license, see LICENSE
3 
6 #include <ros/ros.h>
7 
8 #include <franka/control_tools.h>
9 #include <sched.h>
10 #include <string>
11 
12 int main(int argc, char** argv) {
13  ros::init(argc, argv, "franka_combined_control_node");
14 
16  spinner.start();
17 
18  ros::NodeHandle private_node_handle("~");
20  if (!franka_control.init(private_node_handle, private_node_handle)) {
21  ROS_ERROR("franka_combined_control_node:: Initialization of FrankaCombinedHW failed!");
22  return 1;
23  }
24 
25  // set current thread to real-time priority
26  std::string error_message;
28  ROS_ERROR("franka_combined_control_node: Failed to set thread priority to real-time. Error: %s",
29  error_message.c_str());
30  return 1;
31  }
32 
33  controller_manager::ControllerManager cm(&franka_control, private_node_handle);
34  ros::Duration period(0.001);
35  ros::Rate rate(period);
36 
37  while (ros::ok()) {
38  rate.sleep();
39  ros::Time now = ros::Time::now();
40  franka_control.read(now, period);
41  cm.update(now, period, franka_control.controllerNeedsReset());
42  franka_control.write(now, period);
43  }
44 
45  return 0;
46 }
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void spinner()
bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh) override
ROSCPP_DECL bool ok()
int main(int argc, char **argv)
bool sleep()
bool setCurrentThreadToHighestSchedulerPriority(std::string *error_message)
static Time now()
virtual void write(const ros::Time &time, const ros::Duration &period)
void update(const ros::Time &time, const ros::Duration &period, bool reset_controllers=false)
void read(const ros::Time &time, const ros::Duration &period) override
#define ROS_ERROR(...)


franka_control
Author(s): Franka Emika GmbH
autogenerated on Fri Oct 23 2020 03:47:10