00001 00025 #include <ros/ros.h> 00026 #include <controller_manager/controller_manager.h> 00027 #include "denso_robot_control/denso_robot_hw.h" 00028 00029 int main(int argc, char *argv[]) 00030 { 00031 ros::init(argc, argv, "denso_robot_control"); 00032 ros::NodeHandle nh; 00033 00034 denso_robot_control::DensoRobotHW drobo; 00035 HRESULT hr = drobo.Initialize(); 00036 if(SUCCEEDED(hr)) { 00037 controller_manager::ControllerManager cm(&drobo, nh); 00038 00039 ros::Rate rate(1.0 / drobo.getPeriod().toSec()); 00040 ros::AsyncSpinner spinner(1); 00041 spinner.start(); 00042 00043 ros::Time start = drobo.getTime(); 00044 while(ros::ok()) 00045 { 00046 ros::Time now = drobo.getTime(); 00047 ros::Duration dt = drobo.getPeriod(); 00048 00049 drobo.read(now, dt); 00050 00051 cm.update(now, dt); 00052 00053 ros::Duration diff = now - start; 00054 if(diff.toSec() > 5) { 00055 drobo.write(now, dt); 00056 } 00057 00058 rate.sleep(); 00059 } 00060 spinner.stop(); 00061 } 00062 00063 return 0; 00064 }