Robotics Library  0.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MitsubishiH7.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of the Technische Universitaet Muenchen nor the names of
14 // its contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef _RL_HAL_MITSUBISHIH7_H_
31 #define _RL_HAL_MITSUBISHIH7_H_
32 
33 #include <string>
34 #include <rl/math/Transform.h>
35 
38 #include "Gripper.h"
39 #include "JointPositionActuator.h"
40 #include "JointPositionSensor.h"
41 #include "types.h"
42 
43 namespace rl
44 {
45  namespace hal
46  {
47  class TcpSocket;
48  class UdpSocket;
49 
51  {
52  public:
53  enum Mode
54  {
56  MODE_POSE = 0,
58  };
59 
60  enum HandSts
61  {
67  };
68 
69  enum HandType
70  {
76  };
77 
78  enum TaskCond
79  {
86  };
87 
88  struct EditSts
89  {
91  bool isEditing;
93  bool isRunning;
95  bool isChanged;
96  };
97 
98  struct Hand
99  {
101  int outputNo;
106  };
107 
109  typedef bool MechInfo[3];
110 
111  struct RunSts
112  {
114  bool isRepeat;
118  bool isMlockOn;
120  bool isTeach;
124  bool isServoOn;
126  bool isRun;
129  };
130 
131  struct StopSts
132  {
134  bool isEmgStop;
136  bool isStop;
138  bool isWait;
144  bool isReserve;
147  };
148 
149  struct CalibState
150  {
152  bool isDefined;
154  bool isAxis[8];
155  };
156 
157  typedef Hand HandState[8];
158 
159  struct RunState
160  {
162  char programName[256];
164  int lineNo;
166  int override;
174  int errorNo;
176  int stepNo;
180  char taskPrgName[256];
186  int taskPri;
188  int mechNo;
189  };
190 
192  {
194  bool isTb;
196  bool isPc;
198  bool isIo;
200  bool isOp;
202  bool isIoEmg;
204  bool isOpEmg;
206  bool isTbEmg;
207  };
208 
209  struct StopState
210  {
216  int errorNo;
218  int stepNo;
220  int mechNo;
221  };
222 
223  MitsubishiH7(
224  const ::std::size_t& dof,
225  const ::std::string& server,
226  const ::std::string& client,
227  const unsigned short int& tcp = 10001,
228  const unsigned short int& udp = 10000,
229  const Mode& mode = MODE_JOINT,
230  const uint16_t& haltIoData = 0x00AA,
231  const uint16_t& releaseIoData = 0x00A6,
232  const uint16_t& shutIoData = 0x000A9
233  );
234 
235  virtual ~MitsubishiH7();
236 
241  void calibCmd(CalibState& state) const;
242 
243  void close();
244 
251  void cntlCmd(const bool& doOn) const;
252 
263  void datinstCmd(const ::std::string& j1, const ::std::string& j2, const ::std::string& j3, const ::std::string& j4, const ::std::string& j5, const ::std::string& j6, const ::std::string& checksum) const;
264 
277  void datinstCmd(const ::std::string& j1, const ::std::string& j2, const ::std::string& j3, const ::std::string& j4, const ::std::string& j5, const ::std::string& j6, const ::std::string& j7, const ::std::string& j8, const ::std::string& checksum) const;
278 
283  void dstateCmd(StopState& state) const;
284 
289  void eclrCmd() const;
290 
296  void emdatCmd(const ::std::string& program) const;
297 
303  ::std::string errormesCmd(const int& errorNo) const;
304 
309  void execCmd(const ::std::string& instruction) const;
310 
311  void getCartesianPosition(::rl::math::Transform& x) const;
312 
313  void getCurrentFeedback(::Eigen::Matrix< int32_t, ::Eigen::Dynamic, 1 >& c) const;
314 
315  ::std::size_t getFilter() const;
316 
317  uint16_t getIoData() const;
318 
319  void getJointPosition(::rl::math::Vector& q) const;
320 
321  Mode getMode() const;
322 
323  void getMotorPulse(::Eigen::Matrix< int32_t, ::Eigen::Dynamic, 1 >& p) const;
324 
325  void halt();
326 
332  void hndCmd(const bool& doOpen, const int& handNo) const;
333 
338  void hndstsCmd(HandState& state) const;
339 
345  void inEqualsCmd(const ::std::size_t& inNo, const ::std::string& inVal) const;
346 
351  void loadCmd(const ::std::string& programName) const;
352 
353  void loadProgram(const ::std::string& name, const ::std::string& program) const;
354 
358  void newCmd() const;
359 
360  void open();
361 
367  void outEqualsCmd(const ::std::size_t& outNo, const ::std::string& outVal) const;
368 
369  void release();
370 
374  void rstalrmCmd() const;
375 
379  void rstpwrCmd() const;
380 
386  void runCmd(const ::std::string& programName, const bool& doModeCycle = false) const;
387 
391  void saveCmd() const;
392 
394 
395  void setFilter(const ::std::size_t& filter);
396 
397  void setInput(const uint16_t& bitTop);
398 
400 
401  void setMode(const Mode& mode);
402 
403  void setMotorPulse(const ::Eigen::Matrix< int32_t, ::Eigen::Dynamic, 1 >& p);
404 
405  void setOutput(const uint16_t& bitTop, const uint16_t& bitMask, const uint16_t& ioData);
406 
407  void shut();
408 
412  void slotinitCmd() const;
413 
418  void srvCmd(const bool& doOn) const;
419 
420  void start();
421 
422  void startProgram(const ::std::string& name) const;
423 
428  void stateCmd(RunState& state) const;
429 
430  void step();
431 
435  void stopCmd() const;
436 
437  void stop();
438 
439  void stopProgram() const;
440 
445  void stpsigCmd(StopSignalState& state) const;
446 
447  protected:
448  struct MxtWorld
449  {
451  float x;
453  float y;
455  float z;
457  float a;
459  float b;
461  float c;
463  float l1;
465  float l2;
466  };
467 
468  struct MxtJoint
469  {
471  float j1;
473  float j2;
475  float j3;
477  float j4;
479  float j5;
481  float j6;
483  float j7;
485  float j8;
486  };
487 
488  struct MxtPose
489  {
492  uint32_t sflg1;
494  uint32_t sflg2;
495  };
496 
497  struct MxtPulse
498  {
500  int32_t p1;
502  int32_t p2;
504  int32_t p3;
506  int32_t p4;
508  int32_t p5;
510  int32_t p6;
512  int32_t p7;
514  int32_t p8;
515  };
516 
517  struct MxtCommand
518  {
519  union MxtData
520  {
528  int32_t lng[8];
529  };
531  uint16_t command;
533  uint16_t sendType;
535  uint16_t recvType;
537  uint16_t reserve;
541  uint16_t sendIoType;
543  uint16_t recvIoType;
545  uint16_t bitTop;
547  uint16_t bitMask;
549  uint16_t ioData;
551  uint16_t tCount;
553  uint32_t cCount;
555  uint16_t recvType1;
557  uint16_t reserve1;
561  uint16_t recvType2;
563  uint16_t reserve2;
567  uint16_t recvType3;
569  uint16_t reserve3;
572  };
573 
574  private:
576  ::std::string client;
577 
579  ::std::size_t filter;
580 
581  uint16_t haltIoData;
582 
584 
586 
588 
589  uint16_t releaseIoData;
590 
592  ::std::string server;
593 
594  uint16_t shutIoData;
595 
597 
599  };
600  }
601 }
602 
603 #endif // _RL_HAL_MITSUBISHIH7_H_