Skip to content
Snippets Groups Projects
Commit 368c38b8 authored by Johannes Mey's avatar Johannes Mey
Browse files

switch to mqtt connection for communication with main controller

parent ac0d49eb
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ccf/controller/DummyRobotArmController.h" #include "ccf/controller/DummyRobotArmController.h"
#include "ccf/connection/NngConnection.h" #include "ccf/connection/NngConnection.h"
#include "ccf/connection/MqttConnection.h"
#include "ccf/util/NodeUtil.h" #include "ccf/util/NodeUtil.h"
std::string NODE_NAME = "dummy_sorting_controller"; std::string NODE_NAME = "dummy_sorting_controller";
...@@ -43,14 +44,12 @@ int main(int argc, char **argv) { ...@@ -43,14 +44,12 @@ int main(int argc, char **argv) {
auto clientControllers = getPrivateParameter<std::vector<std::string>>("client_controllers"); auto clientControllers = getPrivateParameter<std::vector<std::string>>("client_controllers");
ROS_INFO_STREAM("Connecting to " << clientControllers.size() << " client controllers."); auto mqttServer = getPrivateParameter<std::string>("mqtt_server", "localhost:1883");
for (const auto &client: clientControllers) { std::unique_ptr<MqttConnection> mqtt_connection = std::make_unique<MqttConnection>(mqttServer, ros::this_node::getName());
ROS_INFO_STREAM("Connecting to client at " << client << "."); mqtt_connection->listen(getParameter<std::string>(n, "topics/selection", "selection"));
std::unique_ptr<NngConnection> client_connection = std::make_unique<NngConnection>(client, false); connector.addConnection(std::move(mqtt_connection));
client_connection->setSendTopic(getParameter<std::string>(n, "topics/selection", "selection"));
client_connection->setReceiveTopic("client_scene"); ros::WallDuration(5).sleep(); // wait 5 secs to init scene (to give moveit time to load)
connector.addConnection(std::move(client_connection));
}
connector.loadScene(getPrivateParameter<std::string>("scene", ros::package::getPath("ccf_immersive_sorting") + connector.loadScene(getPrivateParameter<std::string>("scene", ros::package::getPath("ccf_immersive_sorting") +
"/config/config_scene.yaml")); "/config/config_scene.yaml"));
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ccf/controller/MoveItRobotArmController.h" #include "ccf/controller/MoveItRobotArmController.h"
#include "ccf/connection/NngConnection.h" #include "ccf/connection/NngConnection.h"
#include "ccf/connection/MqttConnection.h"
#include "ccf/util/NodeUtil.h" #include "ccf/util/NodeUtil.h"
std::string NODE_NAME = "moveit_sorting_controller"; std::string NODE_NAME = "moveit_sorting_controller";
...@@ -43,14 +44,8 @@ int main(int argc, char **argv) { ...@@ -43,14 +44,8 @@ int main(int argc, char **argv) {
auto clientControllers = getPrivateParameter<std::vector<std::string>>("client_controllers"); auto clientControllers = getPrivateParameter<std::vector<std::string>>("client_controllers");
ROS_INFO_STREAM("Connecting to " << clientControllers.size() << " client controllers."); auto mqttServer = getPrivateParameter<std::string>("mqtt_server", "localhost:1883");
for (const auto &client: clientControllers) { std::unique_ptr<MqttConnection> mqtt_connection = std::make_unique<MqttConnection>(mqttServer, ros::this_node::getName());
ROS_INFO_STREAM("Connecting to client at " << client << ".");
std::unique_ptr<NngConnection> client_connection = std::make_unique<NngConnection>(client, false);
client_connection->setSendTopic(getParameter<std::string>(n, "topics/selection", "selection"));
client_connection->setReceiveTopic("client_scene");
connector.addConnection(std::move(client_connection));
}
ros::WallDuration(5).sleep(); // wait 5 secs to init scene (to give moveit time to load) ros::WallDuration(5).sleep(); // wait 5 secs to init scene (to give moveit time to load)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment