Skip to content

Commit d41a48b

Browse files
committed
Added a draft version for a primary client
1 parent c80040d commit d41a48b

File tree

4 files changed

+199
-5
lines changed

4 files changed

+199
-5
lines changed

ur_robot_driver/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ include_directories(
8282
add_library(ur_robot_driver
8383
src/comm/tcp_socket.cpp
8484
src/comm/server.cpp
85-
#src/ros/service_stopper.cpp
86-
#src/ur/commander.cpp
87-
#src/ur/master_board.cpp
88-
#src/ur/messages.cpp
89-
#src/ur/robot_mode.cpp
85+
src/primary/primary_client.cpp
9086
src/primary/primary_package.cpp
9187
src/primary/robot_message.cpp
9288
src/primary/robot_state.cpp
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2+
3+
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4+
// Copyright 2019 FZI Forschungszentrum Informatik
5+
//
6+
// Licensed under the Apache License, Text 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// -- END LICENSE BLOCK ------------------------------------------------
18+
19+
//----------------------------------------------------------------------
20+
/*!\file
21+
*
22+
* \author Felix Exner [email protected]
23+
* \date 2020-04-30
24+
*
25+
*/
26+
//----------------------------------------------------------------------
27+
#ifndef UR_ROBOT_DRIVER_PRIMARY_CLIENT_H_INCLUDED
28+
#define UR_ROBOT_DRIVER_PRIMARY_CLIENT_H_INCLUDED
29+
30+
#include <ur_robot_driver/primary/primary_parser.h>
31+
#include <ur_robot_driver/comm/producer.h>
32+
#include <ur_robot_driver/comm/stream.h>
33+
#include <ur_robot_driver/comm/pipeline.h>
34+
35+
namespace ur_driver
36+
{
37+
namespace primary_interface
38+
{
39+
class PrimaryClient
40+
{
41+
public:
42+
PrimaryClient() = delete;
43+
PrimaryClient(const std::string& robot_ip);
44+
virtual ~PrimaryClient() = default;
45+
46+
private:
47+
std::string robot_ip_;
48+
PrimaryParser parser_;
49+
std::unique_ptr<comm::IConsumer<PrimaryPackage>> consumer_;
50+
comm::INotifier notifier_;
51+
std::unique_ptr<comm::URProducer<PrimaryPackage>> producer_;
52+
std::unique_ptr<comm::URStream<PrimaryPackage>> stream_;
53+
std::unique_ptr<comm::Pipeline<PrimaryPackage>> pipeline_;
54+
};
55+
56+
} // namespace primary_interface
57+
} // namespace ur_driver
58+
59+
#endif // ifndef UR_ROBOT_DRIVER_PRIMARY_CLIENT_H_INCLUDED
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2+
3+
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4+
// Copyright 2020 FZI Forschungszentrum Informatik
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// -- END LICENSE BLOCK ------------------------------------------------
19+
20+
//----------------------------------------------------------------------
21+
/*!\file
22+
*
23+
* \author Felix Exner [email protected]
24+
* \date 2020-04-30
25+
*
26+
*/
27+
//----------------------------------------------------------------------
28+
29+
#ifndef UR_ROBOT_DRIVER_PRIMARY_SHELL_CONSUMER_H_INCLUDED
30+
#define UR_ROBOT_DRIVER_PRIMARY_SHELL_CONSUMER_H_INCLUDED
31+
32+
#include "ur_robot_driver/log.h"
33+
#include "ur_robot_driver/primary/abstract_primary_consumer.h"
34+
35+
namespace ur_driver
36+
{
37+
namespace primary_interface
38+
{
39+
class PrimaryShellConsumer : public AbstractPrimaryConsumer
40+
{
41+
public:
42+
PrimaryShellConsumer() = default;
43+
virtual ~PrimaryShellConsumer() = default;
44+
45+
virtual bool consume(RobotMessage& msg) override
46+
{
47+
LOG_INFO("---RobotMessage:---\n%s", msg.toString().c_str());
48+
return true;
49+
}
50+
virtual bool consume(RobotState& msg) override
51+
{
52+
LOG_INFO("---RobotState:---\n%s", msg.toString().c_str());
53+
return true;
54+
}
55+
virtual bool consume(ErrorCodeMessage& msg) override
56+
{
57+
LOG_INFO("---ErrorCodeMessage---%s", msg.toString().c_str());
58+
return true;
59+
}
60+
virtual bool consume(KeyMessage& msg) override
61+
{
62+
LOG_INFO("---KeyMessage---%s", msg.toString().c_str());
63+
return true;
64+
}
65+
virtual bool consume(RuntimeExceptionMessage& msg) override
66+
{
67+
LOG_INFO("---RuntimeExceptionMessage---%s", msg.toString().c_str());
68+
return true;
69+
}
70+
virtual bool consume(TextMessage& msg) override
71+
{
72+
LOG_INFO("---TextMessage---%s", msg.toString().c_str());
73+
return true;
74+
}
75+
virtual bool consume(VersionMessage& msg) override
76+
{
77+
LOG_INFO("---VersionMessage---%s", msg.toString().c_str());
78+
return true;
79+
}
80+
virtual bool consume(KinematicsInfo& msg) override
81+
{
82+
LOG_INFO("%s", msg.toString().c_str());
83+
return true;
84+
}
85+
86+
private:
87+
/* data */
88+
};
89+
} // namespace primary_interface
90+
} // namespace ur_driver
91+
92+
#endif // ifndef UR_ROBOT_DRIVER_PRIMARY_SHELL_CONSUMER_H_INCLUDED
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2+
3+
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4+
// Copyright 2019 FZI Forschungszentrum Informatik
5+
//
6+
// Licensed under the Apache License, Text 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// -- END LICENSE BLOCK ------------------------------------------------
18+
19+
//----------------------------------------------------------------------
20+
/*!\file
21+
*
22+
* \author Felix Exner [email protected]
23+
* \date 2020-04-30
24+
*
25+
*/
26+
//----------------------------------------------------------------------
27+
28+
#include <ur_robot_driver/primary/primary_client.h>
29+
#include <ur_robot_driver/primary/primary_shell_consumer.h>
30+
31+
namespace ur_driver
32+
{
33+
namespace primary_interface
34+
{
35+
PrimaryClient::PrimaryClient(const std::string& robot_ip) : robot_ip_(robot_ip)
36+
{
37+
stream_.reset(new comm::URStream<PrimaryPackage>(robot_ip_, UR_PRIMARY_PORT));
38+
producer_.reset(new comm::URProducer<PrimaryPackage>(*stream_, parser_));
39+
producer_->setupProducer();
40+
41+
consumer_.reset(new PrimaryShellConsumer());
42+
43+
pipeline_.reset(new comm::Pipeline<PrimaryPackage>(*producer_, consumer_.get(), "primary pipeline", notifier_));
44+
pipeline_->run();
45+
}
46+
} // namespace primary_interface
47+
} // namespace ur_driver

0 commit comments

Comments
 (0)