diff --git a/rtabmap/launch/all_tr_learning.launch b/rtabmap/launch/all_tr_learning.launch index 8309ec04..4c6528ed 100644 --- a/rtabmap/launch/all_tr_learning.launch +++ b/rtabmap/launch/all_tr_learning.launch @@ -17,6 +17,6 @@ - + \ No newline at end of file diff --git a/rtabmap/launch/cameraOpenCV.launch b/rtabmap/launch/cameraOpenCV.launch index c155fb78..e70330eb 100644 --- a/rtabmap/launch/cameraOpenCV.launch +++ b/rtabmap/launch/cameraOpenCV.launch @@ -1,7 +1,7 @@ - + diff --git a/rtabmap/launch/rtabmap_sm.launch b/rtabmap/launch/rtabmap_sm.launch index 913871b8..82f7c84b 100644 --- a/rtabmap/launch/rtabmap_sm.launch +++ b/rtabmap/launch/rtabmap_sm.launch @@ -12,6 +12,7 @@ + @@ -24,13 +25,14 @@ + - + diff --git a/rtabmap/src/InputNode.cpp b/rtabmap/src/InputNode.cpp index fdd954f3..dd6e08d7 100644 --- a/rtabmap/src/InputNode.cpp +++ b/rtabmap/src/InputNode.cpp @@ -18,6 +18,7 @@ rtabmap::SensoryMotorStatePtr state; bool stateUpdated = false; bool actionsUpdated = false; +int nbCommands = 10; void publish() { @@ -78,14 +79,14 @@ void velocityReceivedCallback(const geometry_msgs::TwistConstPtr & msg) commands.push_back(v); // 10 Hz max - while(commands.size() > 10) + while(commands.size() > nbCommands) { - ROS_WARN("Too many commands (%zu) > 10, removing the oldest...", commands.size()); + ROS_WARN("Too many commands (%zu) > %d, removing the oldest...", commands.size(), nbCommands); //remove the oldest commands.pop_front(); } - if(commands.size() == 10) + if(commands.size() == nbCommands) { actionsUpdated = true; publish(); @@ -95,7 +96,12 @@ void velocityReceivedCallback(const geometry_msgs::TwistConstPtr & msg) int main(int argc, char** argv) { ros::init(argc, argv, "input_node"); - ros::NodeHandle n; + ros::NodeHandle n("~"); + + n.param("nb_commands", nbCommands, nbCommands); + ROS_INFO("nb_commands=%d", nbCommands); + + rosPublisher = n.advertise("/sm_state", 1); ros::Subscriber image_sub = n.subscribe("/camera_data", 1, smReceivedCallback); ros::Subscriber velocity_sub = n.subscribe("/cmd_vel", 1, velocityReceivedCallback); diff --git a/rtabmap/src/OutputNode.cpp b/rtabmap/src/OutputNode.cpp index d71b73b7..867d7a12 100644 --- a/rtabmap/src/OutputNode.cpp +++ b/rtabmap/src/OutputNode.cpp @@ -14,6 +14,7 @@ std::vector commands; int commandSize = 0; int commandIndex = 0; ros::Publisher rosPublisher; +int commandsHz = 10; //10 Hz void infoReceivedCallback(const rtabmap::RtabmapInfoConstPtr & msg) { @@ -35,14 +36,16 @@ void infoExReceivedCallback(const rtabmap::RtabmapInfoExConstPtr & msg) int main(int argc, char** argv) { ros::init(argc, argv, "output_node"); - ros::NodeHandle n; + ros::NodeHandle n("~"); + n.param("commands_hz", commandsHz, commandsHz); + ROS_INFO("commands_hz=%d", commandsHz); ros::Subscriber infoTopic; ros::Subscriber infoExTopic; - infoTopic = n.subscribe("rtabmap_info", 1, infoReceivedCallback); - infoExTopic = n.subscribe("rtabmap_info_x", 1, infoExReceivedCallback); - rosPublisher = n.advertise("rtabmap/cmd_vel", 1); + infoTopic = n.subscribe("/rtabmap_info", 1, infoReceivedCallback); + infoExTopic = n.subscribe("/rtabmap_info_x", 1, infoExReceivedCallback); + rosPublisher = n.advertise("/rtabmap/cmd_vel", 1); - ros::Rate loop_rate(10); // 10 Hz + ros::Rate loop_rate(commandsHz); // Hz while(ros::ok()) { if(commandIndex>=0 &&