29 #define RAD2DEG(x) ((x) * 180.0 / M_PI) 30 #define DEG2RAD(x) ((x) / 180.0 * M_PI) 32 #define M2MM(x) ((x) * 1000.0) 33 #define MM2M(x) ((x) / 1000.0) 47 m_eng = boost::make_shared<DensoRobotCore>();
55 | DensoRobotRC8::SENDFMT_HANDIO;
56 m_recvfmt = DensoRobotRC8::RECVFMT_POSE_PJ
57 | DensoRobotRC8::RECVFMT_MINIIO
58 | DensoRobotRC8::RECVFMT_HANDIO;
71 ROS_WARN(
"Failed to get robot_name parameter.");
75 ROS_WARN(
"Failed to get robot_joints parameter.");
80 ss <<
"joint_" << i+1;
83 ROS_WARN(
"Failed to get joint_%d parameter.", i+1);
84 ROS_WARN(
"It was assumed revolute type.");
98 if (!nh.
getParam(
"arm_group", armGroup)) {
104 if(nh.
getParam(
"send_format", format)) {
109 if(nh.
getParam(
"recv_format", format)) {
112 switch(
m_recvfmt & DensoRobotRC8::RECVFMT_POSE) {
113 case DensoRobotRC8::RECVFMT_POSE_J:
114 case DensoRobotRC8::RECVFMT_POSE_PJ:
115 case DensoRobotRC8::RECVFMT_POSE_TJ:
118 ROS_WARN(
"Recieve format has to contain joint.");
120 | DensoRobotRC8::RECVFMT_POSE_J);
129 ROS_ERROR(
"Failed to connect real controller. (%X)", hr);
136 hr =
m_ctrl->get_Robot(DensoBase::SRV_ACT, &pRob);
138 ROS_ERROR(
"Failed to connect real robot. (%X)", hr);
150 m_rob->ChangeArmGroup(armGroup);
154 ROS_ERROR(
"Failed to get current joint. (%X)", hr);
158 hr =
m_ctrl->AddVariable(
"@ERROR_CODE");
163 ROS_ERROR(
"Failed to get @ERROR_CODE object. (%X)", hr);
170 vntVal->vt =
VT_I4; vntVal->lVal = 0L;
171 hr =
m_varErr->ExecPutValue(vntVal);
173 ROS_ERROR(
"Failed to clear error. (%X)", hr);
178 hr =
m_rob->AddVariable(
"@SERVO_ON");
181 hr =
m_rob->get_Variable(
"@SERVO_ON", &pVar);
186 hr = pVar->ExecPutValue(vntVal);
190 ROS_ERROR(
"Failed to motor on. (%X)", hr);
205 | DensoRobotRC8::SLVMODE_POSE_J);
207 ROS_ERROR(
"Failed to change to slave mode. (%X)", hr);
216 HRESULT hr =
m_eng->ChangeMode(mode, mode == DensoRobotRC8::SLVMODE_NONE);
220 vntVal->vt =
VT_I4; vntVal->lVal = 0L;
225 msg.data =
m_eng->get_Mode();
228 if(msg.data == DensoRobotRC8::SLVMODE_NONE) {
242 if(
m_sendfmt & DensoRobotRC8::SENDFMT_HANDIO)
247 if(
m_sendfmt & DensoRobotRC8::SENDFMT_MINIIO)
252 if(
m_sendfmt & DensoRobotRC8::SENDFMT_USERIO)
257 if(
m_recvfmt & DensoRobotRC8::RECVFMT_HANDIO)
261 if(
m_recvfmt & DensoRobotRC8::RECVFMT_CURRENT)
265 if(
m_recvfmt & DensoRobotRC8::RECVFMT_MINIIO)
269 if(
m_recvfmt & DensoRobotRC8::RECVFMT_USERIO)
282 boost::mutex::scoped_lock lockMode(
m_mtxMode);
284 ROS_INFO(
"Change to mode %d.", msg->data);
287 ROS_ERROR(
"Failed to change mode. (%X)", hr);
295 std::string strTypeName =
"@TYPE_NAME";
299 m_rob->get_Variable(strTypeName, &pVar);
300 hr = pVar->ExecGetValue(vntVal);
302 strTypeName = DensoBase::ConvertBSTRToString(vntVal->bstrVal);
303 if(strncmp(
m_robName.c_str(), strTypeName.c_str(),
304 (
m_robName.length() < strTypeName.length())
305 ?
m_robName.length() : strTypeName.length()))
317 boost::mutex::scoped_lock lockMode(
m_mtxMode);
319 if(
m_eng->get_Mode() == DensoRobotRC8::SLVMODE_NONE) {
322 ROS_ERROR(
"Failed to get current joint. (%X)", hr);
344 boost::mutex::scoped_lock lockMode(
m_mtxMode);
346 if(
m_eng->get_Mode() != DensoRobotRC8::SLVMODE_NONE) {
347 std::vector<double> pose;
367 if(
m_recvfmt & DensoRobotRC8::RECVFMT_HANDIO)
370 msg.data =
m_rob->get_HandIO();
373 if(
m_recvfmt & DensoRobotRC8::RECVFMT_CURRENT)
375 Float64MultiArray msg;
376 m_rob->get_Current(msg.data);
379 if(
m_recvfmt & DensoRobotRC8::RECVFMT_MINIIO)
382 msg.data =
m_rob->get_MiniIO();
385 if(
m_recvfmt & DensoRobotRC8::RECVFMT_USERIO)
388 m_rob->get_RecvUserIO(msg);
396 hr =
m_varErr->ExecGetValue(vntVal);
397 if(
FAILED(hr) || (vntVal->lVal != 0)) {
398 ROS_ERROR(
"Automatically change to normal mode.");
407 m_rob->put_MiniIO(msg->data);
412 m_rob->put_HandIO(msg->data);
417 m_rob->put_SendUserIO(*msg.get());
422 m_rob->put_RecvUserIO(*msg.get());
void registerInterface(T *iface)
DensoController_Ptr m_ctrl
ros::Subscriber m_subChangeMode
void read(ros::Time, ros::Duration)
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher m_pubRecvUserIO
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void Callback_RecvUserIO(const UserIO::ConstPtr &msg)
ros::Publisher m_pubCurrent
ros::Publisher m_pubMiniIO
HRESULT ChangeModeWithClearError(int mode)
DensoVariable_Ptr m_varErr
ros::Publisher m_pubHandIO
void write(ros::Time, ros::Duration)
ros::Publisher m_pubCurMode
ros::Subscriber m_subRecvUserIO
ros::Subscriber m_subHandIO
hardware_interface::JointStateInterface m_JntStInterface
boost::interprocess::unique_ptr< VARIANT, variant_deleter > VARIANT_Ptr
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void registerHandle(const JointStateHandle &handle)
hardware_interface::PositionJointInterface m_PosJntInterface
JointStateHandle getHandle(const std::string &name)
ros::Subscriber m_subSendUserIO
void Callback_SendUserIO(const UserIO::ConstPtr &msg)
std::vector< double > m_joint
bool getParam(const std::string &key, std::string &s) const
void Callback_HandIO(const Int32::ConstPtr &msg)
void Callback_MiniIO(const Int32::ConstPtr &msg)
ros::Subscriber m_subMiniIO
void Callback_ChangeMode(const Int32::ConstPtr &msg)