diff --git a/driver_templates/CMakeLists.txt b/driver_templates/CMakeLists.txt index a5982ede66b7201ae7b8aa55856f1c7a89e50dc6..b86d8fb79786bcfc5918cdbe1efe53a966d75119 100644 --- a/driver_templates/CMakeLists.txt +++ b/driver_templates/CMakeLists.txt @@ -94,6 +94,8 @@ target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES}) # Add message headers dependencies # ******************************************************************** # add_dependencies(${PROJECT_NAME} <msg_package_name>_generate_messages_cpp) +add_dependencies(${PROJECT_NAME} iri_base_driver_generate_messages_cpp) +add_dependencies(${PROJECT_NAME}_gencfg iri_base_driver_generate_messages_cpp) # ******************************************************************** # Add dynamic reconfigure dependencies # ******************************************************************** diff --git a/driver_templates/template_driver.cfg b/driver_templates/template_driver.cfg index a6e770487e344f24f450b6b3fb1d3056cc64809e..e3f3bae720f4628831127f6b4e2388f21d1bf3e7 100644 --- a/driver_templates/template_driver.cfg +++ b/driver_templates/template_driver.cfg @@ -33,7 +33,7 @@ PACKAGE='template' -from driver_base.msg import SensorLevels +from iri_base_driver.msg import SensorLevels from dynamic_reconfigure.parameter_generator_catkin import * gen = ParameterGenerator() diff --git a/driver_templates/template_driver.cpp b/driver_templates/template_driver.cpp index 2a1a2c8905b4c237cb337e6446a9cd3cdb23524f..16f03be85e440cf298b73edd89c9e57e50326a9b 100644 --- a/driver_templates/template_driver.cpp +++ b/driver_templates/template_driver.cpp @@ -35,13 +35,13 @@ void TemplateDriver::config_update(Config& new_cfg, uint32_t level) // update driver with new_cfg data switch(this->getState()) { - case TemplateDriver::CLOSED: + case iri_base_driver::CLOSED: break; - case TemplateDriver::OPENED: + case iri_base_driver::OPENED: break; - case TemplateDriver::RUNNING: + case iri_base_driver::RUNNING: break; } diff --git a/driver_templates/template_driver_node.cpp b/driver_templates/template_driver_node.cpp index 5347b09267cd24e31ad538565d471d5fd6c9aed0..091ae6985974cca2f100290596100982c3b2bd9c 100644 --- a/driver_templates/template_driver_node.cpp +++ b/driver_templates/template_driver_node.cpp @@ -4,7 +4,7 @@ TemplateNode::TemplateNode(ros::NodeHandle &nh) : iri_base_driver::IriBaseNodeDriver<TemplateDriver>(nh) { //init class attributes if necessary - //this->loop_rate_ = 2;//in [Hz] + //this->setRate(10);//in [Hz] // [init publishers] @@ -50,23 +50,15 @@ void TemplateNode::postNodeOpenHook(void) { } -void TemplateNode::addNodeDiagnostics(void) -{ -} - -void TemplateNode::addNodeOpenedTests(void) +void TemplateNode::preNodeCloseHook(void) { } -void TemplateNode::addNodeStoppedTests(void) -{ -} - -void TemplateNode::addNodeRunningTests(void) +void TemplateNode::addNodeDiagnostics(void) { } -void TemplateNode::reconfigureNodeHook(int level) +void TemplateNode::node_config_update(Config& new_cfg, uint32_t level) { } @@ -78,5 +70,5 @@ TemplateNode::~TemplateNode(void) /* main function */ int main(int argc,char *argv[]) { - return driver_base::main<TemplateNode>(argc, argv, "template_node"); + return iri_base_driver::main<TemplateNode>(argc, argv, "template_node"); } diff --git a/driver_templates/template_driver_node.h b/driver_templates/template_driver_node.h index 6841b516407606db0768a6c35dbee5efbb3217b2..2b81b8f54eb04a2de1269b92d7b44da91b7d0552 100644 --- a/driver_templates/template_driver_node.h +++ b/driver_templates/template_driver_node.h @@ -75,6 +75,8 @@ class TemplateNode : public iri_base_driver::IriBaseNodeDriver<TemplateDriver> */ void postNodeOpenHook(void); + void preNodeCloseHook(void); + public: /** * \brief constructor @@ -134,39 +136,6 @@ class TemplateNode : public iri_base_driver::IriBaseNodeDriver<TemplateDriver> // [driver test functions] - /** - * \brief open status driver tests - * - * In this function tests checking driver's functionallity when driver_base - * status=open can be added. Common use tests for all nodes are already called - * from IriBaseNodeDriver tests methods. For more details on how ROS tests work, - * please refer to the Self Test example in: - * http://www.ros.org/wiki/self_test/ - */ - void addNodeOpenedTests(void); - - /** - * \brief stop status driver tests - * - * In this function tests checking driver's functionallity when driver_base - * status=stop can be added. Common use tests for all nodes are already called - * from IriBaseNodeDriver tests methods. For more details on how ROS tests work, - * please refer to the Self Test example in: - * http://www.ros.org/wiki/self_test/ - */ - void addNodeStoppedTests(void); - - /** - * \brief run status driver tests - * - * In this function tests checking driver's functionallity when driver_base - * status=run can be added. Common use tests for all nodes are already called - * from IriBaseNodeDriver tests methods. For more details on how ROS tests work, - * please refer to the Self Test example in: - * http://www.ros.org/wiki/self_test/ - */ - void addNodeRunningTests(void); - /** * \brief specific node dynamic reconfigure * @@ -174,7 +143,7 @@ class TemplateNode : public iri_base_driver::IriBaseNodeDriver<TemplateDriver> * * \param level integer */ - void reconfigureNodeHook(int level); + void node_config_update(Config& new_cfg, uint32_t level); }; diff --git a/libraries/create_action_client.sh b/libraries/create_action_client.sh index 347a22d19926ce75e8412f7890b8ac2f1b5c5e21..a6ed38f571cdd17abe0f0962038ddc7a85372786 100644 --- a/libraries/create_action_client.sh +++ b/libraries/create_action_client.sh @@ -203,7 +203,8 @@ function create_action_client old_string="iri_base_algorithm" fi new_string="${old_string}\ ${actionlib_pkg}" - sed -i "s/${old_string}/${new_string}/g" "CMakeLists.txt" + sed -i -e "/find_package/ s/${old_string}/${new_string}/g" "CMakeLists.txt" + sed -i -e "/CATKIN_DEPENDS/ s/${old_string}/${new_string}/g" "CMakeLists.txt" fi add_cmake_dependencies "${driver_alg}" "${ros_pkg}" "${act_pkg}" @@ -245,7 +246,7 @@ function create_action_client ################################################################################ #modify Node.cpp - line="${client_name}(\"${topic_name}\", true)" + line="${client_name}(private_node_handle_,\"${topic_name}\", true)" # comment="${class_name}::${class_name}(" # sed -i "/${comment}/s|$|,|" "${node_c}" # add_line_to_file "\ \ ${line}" "${comment}" "${node_c}" diff --git a/libraries/create_action_server.sh b/libraries/create_action_server.sh index 7005269cbf77fcbe94b43b481521d531ff955b11..ccb4be139ceeb0a068cd68d31f9831abc1b5a5df 100644 --- a/libraries/create_action_server.sh +++ b/libraries/create_action_server.sh @@ -141,7 +141,7 @@ function check_action_server_attributes_functions fi # check the node.cpp file - aux_line="${server_name}(public_node_handle_, \"${topic_name}\")" + aux_line="${server_name}(private_node_handle_, \"${topic_name}\")" find_comment_in_file "${aux_line}" "${node_c}" if [[ "${comment_found}" = "true" ]] then @@ -341,7 +341,7 @@ function create_action_server ################################################################################ #modify Node.cpp - line="${server_name}(public_node_handle_, \"${topic_name}\")" + line="${server_name}(private_node_handle_, \"${topic_name}\")" #check if ':' are needed comment="${class_name}::${class_name}(" @@ -549,7 +549,8 @@ function create_action_server old_string="iri_base_algorithm" fi new_string="${old_string}\ iri_action_server" - sed -i "s/${old_string}/${new_string}/g" "CMakeLists.txt" + sed -i -e "/find_package/ s/${old_string}/${new_string}/g" "CMakeLists.txt" + sed -i -e "/CATKIN_DEPENDS/ s/${old_string}/${new_string}/g" "CMakeLists.txt" fi ################################################################################ diff --git a/libraries/create_client.sh b/libraries/create_client.sh index b89ccfd3c8d08a1a6b874fedc7671a93ec05ad4d..dd8f10049700b1cd3069243d0f7f7a929b0e90de 100755 --- a/libraries/create_client.sh +++ b/libraries/create_client.sh @@ -71,7 +71,7 @@ function check_client_attributes_functions fi # check the node.cpp file - line="${client_name} = this->public_node_handle_.serviceClient<${srv_pkg}::${srv_file}>(\"${topic_name}\");" + line="${client_name} = this->private_node_handle_.serviceClient<${srv_pkg}::${srv_file}>(\"${topic_name}\");" echo "${line}" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "true" ]] @@ -134,7 +134,7 @@ function create_client ################################################################################ #modify Node.cpp - line="${client_name} = this->public_node_handle_.serviceClient<${srv_pkg}::${srv_file}>(\"${topic_name}\");" + line="${client_name} = this->private_node_handle_.serviceClient<${srv_pkg}::${srv_file}>(\"${topic_name}\");" comment="\[init clients\]" add_line_to_file "\ \ ${line}\n" "${comment}" "${node_c}" diff --git a/libraries/create_publisher.sh b/libraries/create_publisher.sh index 0592145343190c902b539439cd15932593698d97..39645fccec23367c08dfdb58f0cb26eb7fce1856 100755 --- a/libraries/create_publisher.sh +++ b/libraries/create_publisher.sh @@ -136,7 +136,7 @@ function check_publisher_attributes_functions kill_exit "A message with the same name is already published in file ${node_c} line ${line_number}" fi else - line="this->${publisher_name} = this->public_node_handle_.advertise<${msg_pkg}::${msg_file}>(\"${topic_name}\", ${buffer});" + line="this->${publisher_name} = this->private_node_handle_.advertise<${msg_pkg}::${msg_file}>(\"${topic_name}\", ${buffer});" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "true" ]] then @@ -251,7 +251,7 @@ function create_publisher # modify Node.cpp # if [[ "${msg_file}" = "Image" ]] then - line="it(this->public_node_handle_)" + line="it(this->private_node_handle_)" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "false" ]] then @@ -317,7 +317,7 @@ function create_publisher line="${line}${aux_line}\n" aux_line="\ \ //std::string ${topic_name}_cal_file;" line="${line}${aux_line}\n" - aux_line="\ \ //public_node_handle_.param<std::string>(\"<cal_file_param>\",${topic_name}_cal_file,\"\");" + aux_line="\ \ //private_node_handle_.param<std::string>(\"<cal_file_param>\",${topic_name}_cal_file,\"\");" line="${line}${aux_line}\n" aux_line="\ \ //if(this->${topic_name}_camera_manager.validateURL(${topic_name}_cal_file))" line="${line}${aux_line}\n" @@ -359,7 +359,7 @@ function create_publisher comment="\[publish messages\]" add_line_to_file "\ \ ${line}" "${comment}" "${node_c}" else - line="this->${publisher_name} = this->public_node_handle_.advertise<${msg_pkg}::${msg_file}>(\"${topic_name}\", ${buffer});" + line="this->${publisher_name} = this->private_node_handle_.advertise<${msg_pkg}::${msg_file}>(\"${topic_name}\", ${buffer});" comment="\[init publishers\]" add_line_to_file " ${line}" "${comment}" "${node_c}" aux_line="// Uncomment the following line to publish the topic message" diff --git a/libraries/create_server.sh b/libraries/create_server.sh index 2bd88752eba7e3b64f4ac7871fe0ebea927e936c..fc7782fec1d81180182ebf9817134c0afa21d23b 100755 --- a/libraries/create_server.sh +++ b/libraries/create_server.sh @@ -99,7 +99,7 @@ function check_server_attributes_functions fi # check the node.cpp file - line="this->${server_name} = this->public_node_handle_.advertiseService(\"${topic_name}\", &${class_name}::${callback}, this);" + line="this->${server_name} = this->private_node_handle_.advertiseService(\"${topic_name}\", &${class_name}::${callback}, this);" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "true" ]] then @@ -192,7 +192,7 @@ function create_server ################################################################################ #modify Node.cpp - aux_line="this->${server_name} = this->public_node_handle_.advertiseService(\"${topic_name}\", &${class_name}::${callback}, this);" + aux_line="this->${server_name} = this->private_node_handle_.advertiseService(\"${topic_name}\", &${class_name}::${callback}, this);" line="\ \ ${aux_line}\n" aux_line="pthread_mutex_init(&this->${mutex_name},NULL);\n" line="${line}\ \ ${aux_line}" diff --git a/libraries/create_subscriber.sh b/libraries/create_subscriber.sh index 325f418ed2402f4d96e2079d22e6860b91600c77..892ad25face028db6f2443568c65159857268a7e 100755 --- a/libraries/create_subscriber.sh +++ b/libraries/create_subscriber.sh @@ -129,7 +129,7 @@ function check_subscriber_attributes_functions kill_exit "A subscriber with the same name is already subscribed in file ${node_c} line ${line_number}" fi else - line="this->${subscriber_name} = this->public_node_handle_.subscribe(\"${topic_name}\", ${buffer}, &${class_name}::${callback}, this);" + line="this->${subscriber_name} = this->private_node_handle_.subscribe(\"${topic_name}\", ${buffer}, &${class_name}::${callback}, this);" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "true" ]] then @@ -282,7 +282,7 @@ function create_subscriber # modify Node.cpp # if [[ "${msg_file}" = "Image" ]] then - line="it(this->public_node_handle_)" + line="it(this->private_node_handle_)" find_comment_in_file "${line}" "${node_c}" if [[ "${comment_found}" = "false" ]] then @@ -316,7 +316,7 @@ function create_subscriber aux_line="this->${subscriber_name} = this->it.subscribeCamera(\"${topic_name}/image_raw\", ${buffer}, &${class_name}::${callback}, this);" line="${aux_line}\n" else - aux_line="this->${subscriber_name} = this->public_node_handle_.subscribe(\"${topic_name}\", ${buffer}, &${class_name}::${callback}, this);" + aux_line="this->${subscriber_name} = this->private_node_handle_.subscribe(\"${topic_name}\", ${buffer}, &${class_name}::${callback}, this);" line="${aux_line}\n" fi aux_line="\ \ pthread_mutex_init(&this->${mutex_name},NULL);"