8 #include <std_msgs/Bool.h> 20 setupLimitInterface<joint_limits_interface::EffortJointSoftLimitsHandle>(
38 msg.data =
static_cast<int>(error);
49 ROS_DEBUG_THROTTLE(1,
"FrankaCombinableHW::%s::control_loop(): controller is not active.",
70 ROS_INFO(
"FrankaCombinableHW::%s::control_loop(): controller is active.",
arm_id_.c_str());
92 std::make_unique<actionlib::SimpleActionServer<franka_msgs::ErrorRecoveryAction>>(
93 node_handle,
"error_recovery",
94 [&](
const franka_msgs::ErrorRecoveryGoalConstPtr&) {
96 robot_->automaticErrorRecovery();
122 const std::list<hardware_interface::ControllerInfo>& info)
const {
131 ROS_ERROR(
"FrankaCombinableHW: Unknown interface claimed. Conflict!");
137 ROS_ERROR_STREAM(
"FrankaCombinableHW: Invalid claim joint position or velocity interface." 138 <<
"Note: joint position and joint velocity interfaces are not supported" 139 <<
" in FrankaCombinableHW. Arm:" <<
arm_id_ <<
". Conflict!");
179 robot_->automaticErrorRecovery();
193 const bool limit_rate,
194 const double cutoff_frequency,
196 using Callback = std::function<bool(const franka::RobotState&, franka::Duration)>;
204 robot.control(std::bind(&FrankaCombinableHW::libfrankaUpdateCallback<franka::Torques>,
this,
206 std::placeholders::_2),
207 limit_rate, cutoff_frequency);
212 ROS_ERROR(
"FrankaCombinableHW: No valid control mode selected; cannot set run function.");
virtual void enforceLimits(const ros::Duration &period)
Enforces limits on position, velocity, and torque level.
virtual void setupFrankaModelInterface(franka::RobotState &robot_state)
Configures and registers the model interface offering kinematics and dynamics in ros_control.
ServiceContainer services_
std::unique_ptr< actionlib::SimpleActionServer< franka_msgs::ErrorRecoveryAction > > recovery_action_server_
void initRobot() override
Uses the robot_ip_ to connect to the robot via libfranka and loads the libfranka model.
virtual bool controllerActive() const noexcept
Indicates whether there is an active controller.
std::unique_ptr< std::thread > control_loop_thread_
void publish(const boost::shared_ptr< M > &message) const
void triggerError()
Triggers a stop of the controlLoop.
#define ROS_DEBUG_THROTTLE(rate,...)
franka::Torques effort_joint_command_ros_
A hardware class for a Panda robot based on the ros_control framework.
std::string getArmID() const noexcept
Getter method for the arm_id which is used to distinguish between multiple instances of FrankaCombina...
void initROSInterfaces(ros::NodeHandle &robot_hw_nh) override
Initializes the class in terms of ros_control interfaces.
virtual void checkJointLimits()
Checks the proximity of each joint to its joint position limits and prints a warning whenever a joint...
bool getArmClaimedMap(ResourceWithClaimsMap &resource_map, ArmClaimedMap &arm_claim_map)
bool setRunFunction(const ControlMode &requested_control_mode, bool limit_rate, double cutoff_frequency, franka::ControllerMode internal_controller) override
Configures the run function which is used as libfranka control callback based on the requested contro...
bool hasError() const noexcept
Getter for the error flag of the class.
franka::Torques effort_joint_command_libfranka_
void control(const std::function< bool(const ros::Time &, const ros::Duration &)> &ros_callback=[](const ros::Time &, const ros::Duration &){return true;}) const override
Runs the currently active controller in a realtime loop.
std::map< std::string, ResourceClaims > ArmClaimedMap
franka::RobotState robot_state_ros_
std::mutex ros_state_mutex_
virtual void write(const ros::Time &time, const ros::Duration &period) override
Writes data to the franka robot.
ros::Publisher has_error_pub_
std::atomic_bool controller_needs_reset_
void publishErrorState(bool error)
void read(const ros::Time &, const ros::Duration &) override
Reads data from the franka robot.
virtual void initRobot()
Uses the robot_ip_ to connect to the robot via libfranka and loads the libfranka model.
std::mutex libfranka_cmd_mutex_
std::unique_ptr< franka::Robot > robot_
franka::RobotState robot_state_libfranka_
void setupServices(franka::Robot &robot, ros::NodeHandle &node_handle, ServiceContainer &services)
Sets up all services relevant for a libfranka robot inside a service container.
void resetError()
Recovers the libfranka robot, resets the error flag and publishes the error state.
hardware_interface::EffortJointInterface effort_joint_interface_
std::atomic_bool has_error_
void setupServicesAndActionServers(ros::NodeHandle &node_handle)
std::atomic_bool controller_active_
FrankaCombinableHW()
Creates an instance of FrankaCombinableHW.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::map< std::string, std::vector< std::vector< std::string >>> ResourceWithClaimsMap
void setupJointCommandInterface(std::array< double, 7 > &command, franka::RobotState &state, bool use_q_d, T &interface)
Configures and registers a joint command interface for positions velocities or efforts in ros_control...
void write(const ros::Time &, const ros::Duration &period) override
Writes data to the franka robot.
virtual void read(const ros::Time &time, const ros::Duration &period) override
Reads data from the franka robot.
bool hasTrajectoryClaim(const ArmClaimedMap &arm_claim_map, const std::string &arm_id)
bool checkForConflict(const std::list< hardware_interface::ControllerInfo > &info) const override
Checks whether a requested controller can be run, based on the resources and interfaces it claims...
virtual void setupJointStateInterface(franka::RobotState &robot_state)
Configures and registers the joint state interface in ros_control.
virtual franka::Robot & robot() const
Getter for the libfranka robot instance.
bool partiallyClaimsArmJoints(const ArmClaimedMap &arm_claim_map, const std::string &arm_id)
virtual void setupFrankaStateInterface(franka::RobotState &robot_state)
Configures and registers the state interface offering the full franka::RobotState in ros_control...
std::function< void(franka::Robot &, Callback)> run_function_
std::array< double, 7 > tau_J
#define ROS_ERROR_STREAM(args)
bool controllerNeedsReset() const noexcept
Returns whether the controller needs to be reset e.g.
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
std::function< bool(const franka::RobotState &, franka::Duration)> Callback
ResourceWithClaimsMap getResourceMap(const std::list< hardware_interface::ControllerInfo > &info)
bool hasConflictingMultiClaim(const ResourceWithClaimsMap &resource_map)
std::mutex libfranka_state_mutex_
std::atomic_bool error_recovered_
joint_limits_interface::EffortJointSoftLimitsInterface effort_joint_limit_interface_