primary_pipeline.cpp
Go to the documentation of this file.
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 // -- END LICENSE BLOCK ------------------------------------------------
18 
19 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 
32 
33 #ifdef ROS_BUILD
34 #include <console_bridge/console.h>
35 #endif
36 
37 using namespace urcl;
38 
39 // In a real-world example it would be better to get those values from command line parameters / a better configuration
40 // system such as Boost.Program_options
41 const std::string ROBOT_IP = "192.168.56.101";
42 
43 int main(int argc, char* argv[])
44 {
45 #ifdef ROS_BUILD
46  // When compiled with ROS support we have to set the logging level in order to see output with a
47  // lower level than WARNING
48  console_bridge::setLogLevel(console_bridge::CONSOLE_BRIDGE_LOG_DEBUG);
49 #endif
50 
51  // First of all, we need a stream that connects to the robot
53 
54  // This will parse the primary packages
56 
57  // The producer needs both, the stream and the parser to fully work
58  comm::URProducer<primary_interface::PrimaryPackage> prod(primary_stream, parser);
59  prod.setupProducer();
60 
61  // The shell consumer will print the package contents to the shell
62  std::unique_ptr<comm::IConsumer<primary_interface::PrimaryPackage>> consumer;
64 
65  // The notifer will be called at some points during connection setup / loss. This isn't fully
66  // implemented atm.
67  comm::INotifier notifier;
68 
69  // Now that we have all components, we can create and start the pipeline to run it all.
70  comm::Pipeline<primary_interface::PrimaryPackage> pipeline(prod, consumer.get(), "Pipeline", notifier);
71  pipeline.run();
72 
73  // Package contents will be printed while not being interrupted
74  // Note: Packages for which the parsing isn't implemented, will only get their raw bytes printed.
75  while (true)
76  {
77  std::this_thread::sleep_for(std::chrono::seconds(1));
78  }
79  return 0;
80 }
The ShellConsumer class is a simple consumer that writes a readable representation to the logging inf...
void setupProducer() override
Triggers the stream to connect to the robot.
Definition: producer.h:63
void run()
Starts the producer and, if existing, the consumer in new threads.
Definition: pipeline.h:284
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
Definition: stream.h:42
The primary specific parser. Interprets a given byte stream as serialized primary packages and parses...
void setLogLevel(LogLevel level)
Set log level this will disable messages with lower log level.
Definition: log.cpp:100
Parent class for notifiers.
Definition: pipeline.h:209
int main(int argc, char *argv[])
const std::string ROBOT_IP
The Pipepline manages the production and optionally consumption of packages. Cyclically the producer ...
Definition: pipeline.h:234
A general producer for URPackages. Implements funcionality to produce packages by reading and parsing...
Definition: producer.h:40


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26