cmvr-es/cmvr-es/devices/arm/robot_arm.h

134 lines
5.3 KiB
C++

#ifndef CMVR_ES_ROBOT_ARM_H
#define CMVR_ES_ROBOT_ARM_H
#include <cstddef>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "algorithms/kinematics/ik_solver/common/include/ik_solver.h"
#include "common/types/arm/arm_types.h"
#include "devices/abstract_device.h"
namespace cmvr::device {
class RobotArm : public AbstractDevice {
public:
~RobotArm() override = default;
DeviceKind kind() const noexcept override { return DeviceKind::Arm; }
virtual RobotModel getRobotModel() const = 0;
virtual std::size_t getDof() const = 0;
virtual ArmState getRobotState() const = 0;
virtual JointGroupState getJointState() const = 0;
virtual CartesianPose getTcpPose(FrameType frame = FrameType::Base) const = 0;
virtual RobotMode getRobotMode() const = 0;
virtual SafetyMode getSafetyMode() const = 0;
virtual ControlMode getControlMode() const = 0;
// ActionQueue requires synchronous motion and cooperative cancellation.
// Backends opt in only after both semantics are implemented.
virtual bool supportsActionQueueMotion() const noexcept { return false; }
virtual Result listBaseFrame(std::vector<std::string>& frame_names) const
{
frame_names.clear();
return Result::failure(
ArmErrorCode::UnsupportedCommand,
"ListBaseFrame is not supported by this robot arm");
}
virtual Result listTCPFrame(std::vector<std::string>& frame_names) const
{
frame_names.clear();
return Result::failure(
ArmErrorCode::UnsupportedCommand,
"ListTCPFrame is not supported by this robot arm");
}
virtual Result torqueOn() = 0;
virtual Result torqueOff() = 0;
virtual Result calibrateZeroQ(const std::string& joint_name) = 0;
virtual Result emergencyStop() = 0;
virtual Result protectiveStop() = 0;
virtual Result setSpeedScaling(double scaling) = 0;
virtual double getSpeedScaling() const = 0;
virtual bool isProtectiveStopped() const = 0;
virtual bool isEmergencyStopped() const = 0;
virtual bool isFault() const = 0;
virtual Result moveJ(const JointPositionCommand& target,
const MotionOptions& options) = 0;
virtual Result speedJ(const JointVelocityCommand& velocity,
double acceleration,
double duration) = 0;
virtual Result stopJ(double acceleration) = 0;
virtual Result moveL(const CartesianPose& target,
const MotionOptions& options,
FrameType frame = FrameType::Base) = 0;
// Named-frame overload. Empty names select the driver's configured defaults.
virtual Result moveL(const CartesianPose& target,
const MotionOptions& options,
const std::string& base_frame,
const std::string& tcp_frame)
{
if (base_frame.empty() && tcp_frame.empty()) {
return moveL(target, options, FrameType::Base);
}
return Result::failure(
ArmErrorCode::UnsupportedCommand,
"named base_frame/tcp_frame are not supported by this robot arm");
}
virtual Result speedL(const CartesianVelocity& velocity,
double acceleration,
double duration,
FrameType frame = FrameType::Base) = 0;
virtual Result stopL(std::optional<double> acceleration = std::nullopt) = 0;
virtual Result stopMotion() = 0;
virtual Result moveP(const CartesianPose& target,
const MotionOptions& options,
FrameType frame = FrameType::Base)
{
return moveL(target, options, frame);
}
virtual Result startServoMode(const ServoOptions& options) = 0;
virtual Result servoJ(const JointPositionCommand& target) = 0;
virtual Result servoL(const CartesianPose& target,
FrameType frame = FrameType::Base) = 0;
virtual Result servoSpeedJ(const JointVelocityCommand& velocity) = 0;
virtual Result servoSpeedL(const CartesianVelocity& velocity,
FrameType frame = FrameType::Base) = 0;
virtual Result stopServoMode() = 0;
virtual Result connect(const std::string& ip, int port) = 0;
virtual Result disconnect() = 0;
virtual bool isConnected() const = 0;
virtual Result powerOn() = 0;
virtual Result powerOff() = 0;
virtual Result brakeRelease() = 0;
virtual Result shutdown() = 0;
virtual Result clearFault() = 0;
virtual Result unlockProtectiveStop() = 0;
virtual Result loadProgram(const std::string& program_name) = 0;
virtual Result playProgram() = 0;
virtual Result pauseProgram() = 0;
virtual Result stopProgram() = 0;
virtual std::vector<double> ik(const std::string& base_link,
const std::string& ee_link,
const CartesianPose& pose) = 0;
virtual std::shared_ptr<cmvr::IKSolver> kinematicsSolver() const = 0;
virtual CartesianPose fk(const std::string& base_link,
const std::string& ee_link) = 0;
virtual CartesianPose fk(bool is_tcp = true) = 0;
virtual CartesianVelocity getSpeedLCommandTwistBase() const = 0;
virtual bool busy() const = 0;
};
} // namespace cmvr::device
#endif // CMVR_ES_ROBOT_ARM_H