-
Notifications
You must be signed in to change notification settings - Fork 5
/
PandaControlServer.cpp
135 lines (122 loc) · 4.63 KB
/
PandaControlServer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//============================================================================
/// \file PandaControllerServer.cpp
/// \authors Florian Bauer <[email protected]>
/// \date 2021-01-26
/// \brief PandaController server
/// \note Code generated by sila2codegenerator 0.3.3-dev
//============================================================================
#include <iostream>
#include <ros/ros.h>
#include <sila_cpp/common/FeatureID.h>
#include <sila_cpp/common/ServerAddress.h>
#include <sila_cpp/common/ServerInformation.h>
#include <sila_cpp/common/logging.h>
#include <sila_cpp/server/SiLAServer.h>
#include <QCommandLineParser>
#include <QCoreApplication>
#include "Config.h"
#include "SiteManager/SiteManagerImpl.h"
#include "PlateTypeManager/PlateTypeManagerImpl.h"
#include "RobotController/RobotControllerImpl.h"
using namespace sila2::de::fau::robot::sitemanager::v1;
using namespace sila2::de::fau::robot::platetypemanager::v1;
using namespace sila2::de::fau::robot::robotcontroller::v1;
/**
* Prints some information about the current build.
*/
static void printBuildInfo() {
std::cout << EXECUTABLE_NAME << "\n"
<< "Version: "
<< VERSION_MAJOR << "."
<< VERSION_MINOR << "."
<< VERSION_PATCH << "-"
<< GIT_COMMIT_SHORT << "\n"
<< "Build Type: " << BUILD_TYPE << "\n"
<< "Build Timestamp: " << BUILD_TIMESTAMP << "\n"
<< "Compiler: " << COMPILER_ID << " " << COMPILER_VERSION << "\n";
}
/**
* @brief A SiLA 2 service to control a Panda robot arm from Franka Emika.
*/
class PandaControllerServer : public SiLA2::CSiLAServer {
public:
/**
* @brief C'tor
*/
PandaControllerServer(
const SiLA2::CServerInformation& ServerInfo,
const SiLA2::CServerAddress& Address)
: SiLA2::CSiLAServer{ServerInfo, Address}
{
qDebug() << "Registering features...";
registerFeature(plateTypeManagerPtr.get(), SiLA2::CFeatureID{PlateTypeManager::service_full_name()},
CPlateTypeManagerImpl::featureDefinition());
registerFeature(siteManagerPtr.get(), SiLA2::CFeatureID{SiteManager::service_full_name()},
CSiteManagerImpl::featureDefinition());
registerFeature(robotControllePtr.get(), SiLA2::CFeatureID{RobotController::service_full_name()},
CRobotControllerImpl::featureDefinition());
}
private:
const std::shared_ptr<CPlateTypeManagerImpl> plateTypeManagerPtr{new CPlateTypeManagerImpl
{this}};
const std::shared_ptr<CSiteManagerImpl> siteManagerPtr{new CSiteManagerImpl
{this, plateTypeManagerPtr}};
const std::shared_ptr<CRobotControllerImpl> robotControllePtr{new CRobotControllerImpl
{this, siteManagerPtr}};
};
/**
* @brief Looking for command line arguments
*
* @return pair<CServerInformation, CServerAddress> A pair with the server
* information (name, type, ...) and the server's address (IP and port)
*/
std::pair<SiLA2::CServerInformation, const SiLA2::CServerAddress> parseCommandLine() {
auto Parser = PandaControllerServer::commandLineParser();
Parser->setApplicationDescription("A SiLA2 service: PandaController");
Parser->addOptions({
{
{"s", "server-name"},
"The name of the SiLA server",
"name",
"Panda Controller"
},
{
{"t", "server-type"},
"The type of the SiLA server",
"type",
"PandaRobotController"
},
{
{"d", "description"},
"The description of the SiLA server",
"description text",
"A SiLA 2 service to control a Panda robot arm from Franka Emika."
},
{
{"p", "server-port"},
"The port on which the SiLA server should run",
"port",
"50054"
}
});
Parser->process(QCoreApplication::arguments());
return {
{Parser->value("server-name"), Parser->value("server-type"),
Parser->value("description"), QCoreApplication::applicationVersion()},
{"[::]", Parser->value("server-port")}};
}
int main(int argc, char* argv[]) {
printBuildInfo();
QCoreApplication App{argc, argv};
QCoreApplication::setApplicationName("PandaControllerServer");
QCoreApplication::setApplicationVersion("0.0.1");
int rosArgc = 0;
ros::init(rosArgc, nullptr, "panda_controller");
ros::NodeHandle nh;
ros::AsyncSpinner spinner(1);
spinner.start();
const auto [ServerInfo, ServerAddress] = parseCommandLine();
auto SiLAServer = PandaControllerServer{ServerInfo, ServerAddress};
SiLAServer.run();
return 0;
}