dance_m1013.cpp
Go to the documentation of this file.
1 /*
2  * [c++ demo] robot(m1013) dance
3  * Author: Kab Kyoum Kim (kabkyoum.kim@doosan.com)
4  *
5  * Copyright (c) 2019 Doosan Robotics
6  * Use of this source code is governed by the BSD, see LICENSE
7 */
8 
9 #include <ros/ros.h>
10 #include <signal.h>
11 
12 #include "dsr_util.h"
13 #include "dsr_robot.h"
14 
15 using namespace std;
16 using namespace DSR_Robot;
17 
18 //----- set tartget robot----------------------------------------------------
19 string ROBOT_ID = "dsr01";
20 string ROBOT_MODEL = "m1013";
21 void SET_ROBOT(string id, string model) {ROBOT_ID = id; ROBOT_MODEL= model;}
22 //---------------------------------------------------------------------------
23 
25 
26 void SigHandler(int sig)
27 {
28  // Do some custom action.
29  // For example, publish a stop message to some other nodes.
30 
31  // All the default sigint handler does is call shutdown()
32  ROS_INFO("shutdown time!");
33  ROS_INFO("shutdown time!");
34  ROS_INFO("shutdown time!");
35  //ros::ServiceClient srvMoveStop = nh.serviceClient<dsr_msgs::MoveStop>("/dsr01m1013/motion/move_stop");
36 
37  ros::NodeHandlePtr node = boost::make_shared<ros::NodeHandle>();
38  ros::Publisher pubRobotStop = node->advertise<dsr_msgs::RobotStop>("/"+ROBOT_ID +ROBOT_MODEL+"/stop",100);
39 
40  dsr_msgs::RobotStop msg;
41 
42  msg.stop_mode = STOP_TYPE_QUICK;
43  pubRobotStop.publish(msg);
44 
45  ros::shutdown();
46 }
47 
48 int main(int argc, char** argv)
49 {
50 
51  ros::init(argc, argv, "dance_m1013_cpp", ros::init_options::NoSigintHandler);
52  ros::NodeHandle nh("~");
53  // Override the default ros sigint handler.
54  // This must be set after the first NodeHandle is created.
55  signal(SIGINT, SigHandler);
56 
57  ros::Publisher pubRobotStop = nh.advertise<dsr_msgs::RobotStop>("/"+ROBOT_ID +ROBOT_MODEL+"/stop",10);
58 
59  //----- set target robot ---------------
60  const string my_robot_id = "dsr01";
61  const string my_robot_model = "m1013";
62  SET_ROBOT(my_robot_id, my_robot_model);
63  CDsrRobot robot(nh, my_robot_id, my_robot_model);
64 
66 
67  float JReady[6] = {0, -20, 110, 0, 60, 0}; //posj
68 
69  float TCP_POS[6] = {0, 0, 0,0 ,0, 0};
70  float J00[6] = {-180, 0, -145, 0, -35, 0};
71 
72  float J01r[6] = {-180.0, 71.4, -145.0, 0.0, -9.7, 0.0};
73  float J02r[6] = {-180.0, 67.7, -144.0, 0.0, 76.3, 0.0};
74  float J03r[6] = {-180.0, 0.0, 0.0, 0.0, 0.0, 0.0};
75 
76  float J04r[6] = {-90.0, 0.0, 0.0, 0.0, 0.0, 0.0};
77  float J04r1[6] = {-90.0, 30.0, -60.0, 0.0, 30.0, -0.0};
78  float J04r2[6] = {-90.0, -45.0, 90.0, 0.0, -45.0, -0.0};
79  float J04r3[6] = {-90.0, 60.0, -120.0, 0.0, 60.0, -0.0};
80  float J04r4[6] = {-90.0, 0.0, -0.0, 0.0, 0.0, -0.0};
81 
82  float J05r[6] = {-144.0, -4.0, -84.8, -90.9, 54.0, -1.1};
83 
84  float J07r[6] = {-152.4, 12.4, -78.6, 18.7, -68.3, -37.7};
85  float J08r[6] = {-90.0, 30.0, -120.0, -90.0, -90.0, 0.0};
86 
87  float JEnd[6] = {0.0, -12.6, 101.1, 0.0, 91.5, -0.0};
88 
89  float dREL1[6] = {0, 0, 350, 0, 0, 0};
90  float dREL2[6] = {0, 0, -350, 0, 0, 0};
91 
92  float velx[2] = {0,0};
93  float accx[2] = {0, 0};
94 
95  float vel_spi[2] = {400, 400};
96  float acc_spi[2] = {150, 150};
97 
98  float J1[6] = {81.2, 20.8, 127.8, 162.5, 56.1, -37.1};
99  float X0[6] = {-88.7, 799.0, 182.3, 95.7, 93.7, 133.9};
100  float X1[6] = {304.2, 871.8, 141.5, 99.5, 84.9, 133.4};
101  float X2[6] = {437.1, 876.9, 362.1, 99.6, 84.0, 132.1};
102  float X3[6] = {-57.9, 782.4, 478.4, 99.6, 84.0, 132.1};
103 
104  float amp[6] = {0, 0, 0, 30, 30, 0};
105  float period[6] = {0, 0, 0, 3, 6, 0};
106 
107  float x01[6] = {423.6, 334.5, 651.2, 84.7, -180.0, 84.7};
108  float x02[6] = {423.6, 34.5, 951.2, 68.2, -180.0, 68.2};
109  float x03[6] = {423.6, -265.5, 651.2, 76.1, -180.0, 76.1};
110  float x04[6] = {423.6, 34.5, 351.2, 81.3, -180.0, 81.3};
111  float x0204c[2][6];
113 
114 
115  while(ros::ok())
116  {
117  robot.movej(JReady, 20, 20);
118  robot.config_create_tcp("TCP_ZERO", TCP_POS);
119  robot.set_current_tcp("TCP_ZERO");
120 
121  robot.movej(J1, 0, 0, 3);
122  robot.movel(X3, velx, accx, 2.5);
123 
124  for(int i=0; i<2; i++){
125  robot.movel(X2, velx, accx, 2.5, 50, MOVE_REFERENCE_BASE, MOVE_MODE_ABSOLUTE);
126  robot.movel(X1, velx, accx, 1.5, 50, MOVE_REFERENCE_BASE, MOVE_MODE_ABSOLUTE);
127  robot.movel(X0, velx, accx, 2.5);
128  robot.movel(X1, velx, accx, 2.5, 50, MOVE_REFERENCE_BASE, MOVE_MODE_ABSOLUTE);
129  robot.movel(X2, velx, accx, 1.5, 50, MOVE_REFERENCE_BASE, MOVE_MODE_ABSOLUTE);
130  robot.movel(X3, velx, accx, 2.5, 50, MOVE_REFERENCE_BASE, MOVE_MODE_ABSOLUTE);
131  }
132 
133  robot.movej(J00, 60, 60, 6);
134 
135  robot.movej(J01r, 0, 0, 2, 100);
136  robot.movej(J02r, 0, 0, 2, 50);
137  robot.movej(J03r, 0, 0, 2);
138 
139  robot.movej(J04r, 0, 0, 1.5);
140  robot.movej(J04r1, 0, 0, 2, 50);
141  robot.movej(J04r2, 0, 0, 4, 50);
142  robot.movej(J04r3, 0, 0, 4, 50);
143  robot.movej(J04r4, 0, 0, 2);
144 
145  robot.movej(J05r, 0, 0, 2.5, 100);
146  robot.movel(dREL1, velx, accx, 1, 50, MOVE_REFERENCE_TOOL, MOVE_MODE_ABSOLUTE);
147  robot.movel(dREL2, velx, accx, 1.5, 100, MOVE_REFERENCE_TOOL, MOVE_MODE_ABSOLUTE);
148 
149  robot.movej(J07r, 60, 60, 1.5, 100);
150  robot.movej(J08r, 60, 60, 2);
151 
152  robot.movej(JEnd, 60, 60, 4);
153 
154  robot.move_periodic(amp, period, 0, 1, MOVE_REFERENCE_TOOL);
155  robot.move_spiral(3, 200, 100, vel_spi, acc_spi, 0, TASK_AXIS_X, MOVE_REFERENCE_TOOL);
156 
157  robot.movel(x01, velx, accx, 2);
158  robot.movel(x04, velx, accx, 2, 100, MOVE_MODE_ABSOLUTE, MOVE_REFERENCE_BASE);
159  robot.movel(x03, velx, accx, 2, 100, MOVE_MODE_ABSOLUTE, MOVE_REFERENCE_BASE);
160  robot.movel(x02, velx, accx, 2, 100, MOVE_MODE_ABSOLUTE, MOVE_REFERENCE_BASE);
161  robot.movel(x01, velx, accx, 2);
162  for(int i=0; i<6; i++){
163  x0204c[0][i] = x02[i];
164  x0204c[1][i] = x04[i];
165  }
166  robot.movec(x0204c, velx, accx, 4, 360, MOVE_MODE_ABSOLUTE, MOVE_REFERENCE_BASE);
167 
168  }
169 
170  ROS_INFO("dance_m1013 finished !!!!!!!!!!!!!!!!!!!!!");
171  return 0;
172 }
void SigHandler(int sig)
Definition: dance_m1013.cpp:26
float x0204c[2][6]
float amp[6]
float velx[2]
float J04r1[6]
float x03[6]
float J05r[6]
string ROBOT_MODEL
Definition: dance_m1013.cpp:20
float JReady[6]
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
float X0[6]
float period[6]
float JEnd[6]
float J04r2[6]
float J02r[6]
float accx[2]
float J04r[6]
#define ROS_INFO(...)
float J1[6]
float J01r[6]
float dREL1[6]
float X3[6]
ROSCPP_DECL bool ok()
float x01[6]
void SET_ROBOT(string id, string model)
Definition: dance_m1013.cpp:21
float vel_spi[2]
float x04[6]
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
float J08r[6]
float acc_spi[2]
int main(int argc, char **argv)
Definition: dance_m1013.cpp:48
float dREL2[6]
float x02[6]
float TCP_POS[6]
string ROBOT_ID
Definition: dance_m1013.cpp:19
float J00[6]
float J04r3[6]
float X2[6]
float X1[6]
ROSCPP_DECL void shutdown()
float J03r[6]
float J04r4[6]
float J07r[6]


cpp
Author(s): Kab Kyoum Kim , Jin Hyuk Gong , Jeongwoo Lee
autogenerated on Sat May 18 2019 02:32:53