1 #ifndef GRL_KUKA_DRIVER 2 #define GRL_KUKA_DRIVER 8 #include <boost/asio.hpp> 9 #include <boost/circular_buffer.hpp> 10 #include <boost/exception/all.hpp> 11 #include <boost/config.hpp> 13 #include <boost/make_shared.hpp> 14 #include <boost/range/algorithm/copy.hpp> 15 #include <boost/range/algorithm/transform.hpp> 17 #include <boost/make_shared.hpp> 19 #ifdef BOOST_NO_CXX11_ATOMIC_SMART_PTR 20 #include <boost/thread.hpp> 29 namespace grl {
namespace robot {
namespace arm {
41 class KukaDriver :
public std::enable_shared_from_this<KukaDriver> {
74 return std::make_tuple(
76 "KUKA_LBR_IIWA_14_R820" ,
91 : params_(params), debug(false)
96 bool destruct(){
return JAVAdriverP_->destruct(); }
108 if( boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"FRI"))
109 || boost::iequals(std::get<KukaMonitorMode>(params_),std::string(
"FRI")))
115 std::string(std::get<RobotModel > (params)),
116 std::string(std::get<LocalHostKukaKoniUDPAddress > (params)),
117 std::string(std::get<LocalHostKukaKoniUDPPort > (params)),
118 std::string(std::get<RemoteHostKukaKoniUDPAddress> (params)),
119 std::string(std::get<RemoteHostKukaKoniUDPPort > (params)),
125 FRIdriverP_->construct();
129 if( boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"JAVA"))
130 || boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"FRI")))
133 JAVAdriverP_ = boost::make_shared<KukaJAVAdriver>(params_);
134 JAVAdriverP_->construct();
139 }
catch( boost::exception &e) {
140 e <<
errmsg_info(
"KukaDriver: Unable to connect to ZeroMQ Socket from " +
141 std::get<LocalUDPAddress> (params_) +
" to " +
142 std::get<RemoteUDPAddress> (params_));
175 bool haveNewData =
false;
179 if(JAVAdriverP_.get() !=
nullptr)
188 if(boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"FRI")))
194 if(boost::iequals(std::get<KukaMonitorMode>(params_),std::string(
"FRI")))
204 if( boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"JAVA")))
214 haveNewData = JAVAdriverP_->run_one();
216 if( boost::iequals(std::get<KukaMonitorMode>(params_),std::string(
"JAVA")))
218 JAVAdriverP_->get(armState_);
224 if(FRIdriverP_.get() !=
nullptr)
226 if( boost::iequals(std::get<KukaCommandMode>(params_),std::string(
"FRI")))
231 haveNewData = FRIdriverP_->run_one();
233 if( boost::iequals(std::get<KukaMonitorMode>(params_),std::string(
"FRI")))
235 FRIdriverP_->get(armState_);
236 JAVAdriverP_->getWrench(armState_);
250 JAVAdriverP_->set(armControlMode);
262 template<
typename Range>
264 boost::unique_lock<boost::mutex> lock(jt_mutex);
283 template<
typename Range>
285 boost::unique_lock<boost::mutex> lock(jt_mutex);
306 boost::lock_guard<boost::mutex> lock(jt_mutex);
310 FRIdriverP_->set(duration_to_goal_command,tag);
314 JAVAdriverP_->set(duration_to_goal_command,tag);
328 boost::lock_guard<boost::mutex> lock(jt_mutex);
353 template<
typename Range>
355 boost::unique_lock<boost::mutex> lock(jt_mutex);
361 template<
typename OutputIterator>
364 boost::unique_lock<boost::mutex> lock(jt_mutex);
369 template<
typename OutputIterator>
372 boost::unique_lock<boost::mutex> lock(jt_mutex);
377 template<
typename OutputIterator>
380 boost::unique_lock<boost::mutex> lock(jt_mutex);
385 template<
typename OutputIterator>
388 boost::unique_lock<boost::mutex> lock(jt_mutex);
393 template<
typename OutputIterator>
396 boost::unique_lock<boost::mutex> lock(jt_mutex);
416 boost::mutex jt_mutex;
417 boost::shared_ptr<KukaFRIdriver<LinearInterpolation>> FRIdriverP_;
418 boost::shared_ptr<KukaJAVAdriver> JAVAdriverP_;
cartesian_state externalForce
std::unique_ptr< std::thread > driver_threadP
cartesian_state wrenchJava
void getWrench(OutputIterator output)
joint_state commandedPosition
time_point_type timestamp
Internal implementation class for driver use only, stores all the kuka state data in a simple object...
static const Params defaultParams()
std::unique_ptr< boost::asio::io_service::work > device_driver_workP_
std::chrono::time_point< std::chrono::high_resolution_clock > time_point_type
volatile std::size_t m_attemptedCommunicationConsecutiveFailureCount
KukaDriver(Params params=defaultParams())
Simple low level driver to communicate over the Kuka iiwa FRI interface using KUKA::FRI::ClientData s...
external joint torque, i.e. torques applied to an arm excluding those caused by the mass of the arm i...
cartesian_state commandedCartesianWrenchFeedForward
Primary Kuka FRI driver, only talks over realtime network FRI KONI ethernet port. ...
OutputIterator copy(std::string model, OutputIterator it, grl::revolute_joint_velocity_open_chain_state_constraint_tag)
copy vector of joint velocity limits in radians/s
std::tuple< std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string > Params
double goal_position_command_time_duration
Kuka LBR iiwa Primary Multi Mode Driver, supports communication over FRI and JAVA interfaces...
const Params & getParams()
data for changing a system's physical state, such as joint angles to be sent to a robot arm...
boost::error_info< struct tag_errmsg, std::string > errmsg_info
volatile std::size_t m_attemptedCommunicationConsecutiveSuccessCount
the time duration over which a command should be completed
boost::asio::io_service device_driver_io_service
joint_state commandedPosition_goal
we need to mind arm constraints, so we set a goal then work towards it
volatile std::size_t m_haveReceivedRealDataCount
void construct(Params params)
external forces, i.e. forces applied to an arm excluding those caused by the mass of the arm itself a...
volatile std::size_t m_attemptedCommunicationCount
joint_state externalTorque
identifies data representing the state of a sytem
joint_state commandedTorque
single point in time relative to some start point