Program Listing for File script_command_interface.h
↰ Return to documentation for file (include/ur_client_library/control/script_command_interface.h
)
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
// -- BEGIN LICENSE BLOCK ----------------------------------------------
// Copyright 2021 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_SCRIPT_COMMAND_INTERFACE_H_INCLUDED
#define UR_CLIENT_LIBRARY_SCRIPT_COMMAND_INTERFACE_H_INCLUDED
#include "ur_client_library/control/reverse_interface.h"
#include "ur_client_library/ur/tool_communication.h"
namespace urcl
{
namespace control
{
enum class ToolContactResult : int32_t
{
UNTIL_TOOL_CONTACT_RESULT_SUCCESS = 0,
UNTIL_TOOL_CONTACT_RESULT_CANCELED = 1,
};
class ScriptCommandInterface : public ReverseInterface
{
public:
ScriptCommandInterface() = delete;
ScriptCommandInterface(uint32_t port);
bool zeroFTSensor();
bool setPayload(const double mass, const vector3d_t* cog);
bool setToolVoltage(const ToolVoltage voltage);
bool startForceMode(const vector6d_t* task_frame, const vector6uint32_t* selection_vector, const vector6d_t* wrench,
const unsigned int type, const vector6d_t* limits);
bool endForceMode();
bool startToolContact();
bool endToolContact();
bool clientConnected();
void setToolContactResultCallback(std::function<void(ToolContactResult)> callback)
{
handle_tool_contact_result_ = callback;
}
protected:
virtual void connectionCallback(const int filedescriptor) override;
virtual void disconnectionCallback(const int filedescriptor) override;
virtual void messageCallback(const int filedescriptor, char* buffer, int nbytesrecv) override;
private:
enum class ScriptCommand : int32_t
{
ZERO_FTSENSOR = 0,
SET_PAYLOAD = 1,
SET_TOOL_VOLTAGE = 2,
START_FORCE_MODE = 3,
END_FORCE_MODE = 4,
START_TOOL_CONTACT = 5,
END_TOOL_CONTACT = 6,
};
bool client_connected_;
static const int MAX_MESSAGE_LENGTH = 26;
std::function<void(ToolContactResult)> handle_tool_contact_result_;
};
} // namespace control
} // namespace urcl
#endif // UR_CLIENT_LIBRARY_SCRIPT_COMMAND_INTERFACE_H_INCLUDED