xarm_combined_control_node.cpp
Go to the documentation of this file.
1 /* Copyright 2020 UFACTORY Inc. All Rights Reserved.
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Author: Jason Peng <jason@ufactory.cc>
6  ============================================================================*/
7 
8 #include "xarm_combined_hw.h"
9 
10 int main(int argc, char**argv)
11 {
12  ros::init(argc, argv, "xarm_controller");
13  ros::NodeHandle nh;
14  double ctrl_rate = 100;
15  ros::Rate r(ctrl_rate);
16 
17  ros::Duration(1.0).sleep();
18 
20  if(!xarm_hw.init(nh, nh)) exit(-1);
21 
23 
25  spinner.start();
26 
27  // IMPORTANT: DO NOT REMOVE THIS DELAY !!!
28  /* Wait for correct initial position to be updated to ros_controller */
29  ros::Duration(2.0).sleep();
30 
32  while (ros::ok())
33  {
34  ros::Duration elapsed = ros::Time::now() - ts;
35  ts = ros::Time::now();
36  // xarm_hw.read(ts, elapsed);
37  cm.update(ts, elapsed, xarm_hw.need_reset()); // reset_controllers=true: preempt and cancel current goal
38 
39  xarm_hw.write(ts, elapsed);
40  r.sleep();
41  }
42  spinner.stop();
43  return 0;
44 }
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
virtual bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh)
void spinner()
int main(int argc, char **argv)
ROSCPP_DECL bool ok()
bool sleep()
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)


xarm_controller
Author(s):
autogenerated on Sat May 8 2021 02:51:38