Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "youbot_driver_ros_interface/YouBotOODLWrapper.h"
00041
00042 int main(int argc, char **argv)
00043 {
00044
00045 youbot::Logger::toConsole = false;
00046 youbot::Logger::toFile = false;
00047 youbot::Logger::toROS = true;
00048 ros::init(argc, argv, "youbot_oodl_driver");
00049 ros::NodeHandle n;
00050 youBot::YouBotOODLWrapper youBot(n);
00051 std::vector<std::string> armNames;
00052
00053
00054
00055 bool youBotHasBase;
00056 bool youBotHasArms;
00057 double youBotDriverCycleFrequencyInHz;
00058 n.param("youBotHasBase", youBotHasBase, true);
00059 n.param("youBotHasArms", youBotHasArms, true);
00060 n.param("youBotDriverCycleFrequencyInHz", youBotDriverCycleFrequencyInHz, 50.0);
00061 n.param<std::string>("youBotConfigurationFilePath", youBot.youBotConfiguration.configurationFilePath, mkstr(YOUBOT_CONFIGURATIONS_DIR));
00062 n.param<std::string>("youBotBaseName", youBot.youBotConfiguration.baseConfiguration.baseID, "youbot-base");
00063
00064
00065
00066 int i = 1;
00067 std::stringstream armNameParam;
00068 armNameParam << "youBotArmName" << i;
00069 while (n.hasParam(armNameParam.str())) {
00070 std::string armName;
00071 n.getParam(armNameParam.str(), armName);
00072 armNames.push_back(armName);
00073 armNameParam.str("");
00074 armNameParam << "youBotArmName" << (++i);
00075 }
00076
00077 ros::ServiceServer reconnectService = n.advertiseService("reconnect", &youBot::YouBotOODLWrapper::reconnectCallback, &youBot);
00078
00079 ROS_INFO("Configuration file path: %s", youBot.youBotConfiguration.configurationFilePath.c_str());
00080 try {
00081 youbot::EthercatMaster::getInstance("youbot-ethercat.cfg", youBot.youBotConfiguration.configurationFilePath);
00082 } catch (std::exception& e) {
00083 ROS_ERROR("No EtherCAT connection:");
00084 ROS_FATAL("%s", e.what());
00085 return 0;
00086 }
00087
00088 ROS_ASSERT((youBotHasBase == true) || (youBotHasArms == true));
00089 if (youBotHasBase == true)
00090 {
00091 youBot.initializeBase(youBot.youBotConfiguration.baseConfiguration.baseID);
00092 }
00093
00094 if (youBotHasArms == true) {
00095 std::vector<std::string>::iterator armNameIter;
00096 for (armNameIter = armNames.begin(); armNameIter != armNames.end(); ++armNameIter) {
00097 youBot.initializeArm(*armNameIter);
00098 }
00099 }
00100
00101
00102
00103 ros::Rate rate(youBotDriverCycleFrequencyInHz);
00104 while (n.ok())
00105 {
00106 ros::spinOnce();
00107 youBot.computeOODLSensorReadings();
00108 youBot.publishOODLSensorReadings();
00109 youBot.publishArmAndBaseDiagnostics(2.0);
00110 rate.sleep();
00111 }
00112
00113 youBot.stop();
00114
00115 return 0;
00116 }
00117