xarm_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_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 
19  xarm_control::XArmHW xarm_hw;
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  xarm_hw.write(ts, elapsed);
39  r.sleep();
40  }
41  spinner.stop();
42  return 0;
43 }
int main(int argc, char **argv)
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void spinner()
ROSCPP_DECL bool ok()
bool sleep()
static Time now()
void update(const ros::Time &time, const ros::Duration &period, bool reset_controllers=false)
virtual void write(const ros::Time &time, const ros::Duration &period)
Definition: xarm_hw.cpp:255
virtual bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh)
Definition: xarm_hw.cpp:142


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