Program Listing for File rtde_writer.h
↰ Return to documentation for file (/tmp/ws/src/ur_client_library/include/ur_client_library/rtde/rtde_writer.h
)
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
// -- BEGIN LICENSE BLOCK ----------------------------------------------
// Copyright 2019 FZI Forschungszentrum Informatik
// Created on behalf of Universal Robots A/S
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// -- END LICENSE BLOCK ------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
#ifndef UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
#define UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED
#include "ur_client_library/rtde/package_header.h"
#include "ur_client_library/rtde/rtde_package.h"
#include "ur_client_library/rtde/data_package.h"
#include "ur_client_library/comm/stream.h"
#include "ur_client_library/queue/readerwriterqueue.h"
#include <thread>
#include <mutex>
namespace urcl
{
namespace rtde_interface
{
class RTDEWriter
{
public:
RTDEWriter() = delete;
RTDEWriter(comm::URStream<RTDEPackage>* stream, const std::vector<std::string>& recipe);
~RTDEWriter()
{
running_ = false;
if (writer_thread_.joinable())
{
writer_thread_.join();
}
}
void init(uint8_t recipe_id);
void run();
bool sendSpeedSlider(double speed_slider_fraction);
bool sendStandardDigitalOutput(uint8_t output_pin, bool value);
bool sendConfigurableDigitalOutput(uint8_t output_pin, bool value);
bool sendToolDigitalOutput(uint8_t output_pin, bool value);
bool sendStandardAnalogOutput(uint8_t output_pin, double value);
bool sendInputBitRegister(uint32_t register_id, bool value);
bool sendInputIntRegister(uint32_t register_id, int32_t value);
bool sendInputDoubleRegister(uint32_t register_id, double value);
private:
uint8_t pinToMask(uint8_t pin);
comm::URStream<RTDEPackage>* stream_;
std::vector<std::string> recipe_;
uint8_t recipe_id_;
moodycamel::BlockingReaderWriterQueue<std::unique_ptr<DataPackage>> queue_;
std::thread writer_thread_;
bool running_;
DataPackage package_;
std::mutex package_mutex_;
};
} // namespace rtde_interface
} // namespace urcl
#endif // UR_CLIENT_LIBRARY_RTDE_WRITER_H_INCLUDED