// it's for Latex

pages

[Pick and Place using Inception_v3 in ROS] #05. Recording Trajectory

이제 Trajectory를 Recording 해보자.


PC Enviroment ( Labtop )
OS : Ubuntu 16.04
ROS : Kinetic
CPU : i8
Graphic Card : RTX 2070

Hardware
OpenManipulator(ROBOTIS)
U2D2 Interface

Software
Inception_v3

Camera
Logitech C920 Webcam



Recording Trajectory 


앞에서

#02에서 만든 source를 이용해 다음과 같은 명령어로 Trajectory를 recording 한다.

$ roscore
$ roslaunch open_manipulator_master_slave open_manipulator_recording_trajectory.launch

tmp 폴더로 가면 test.txt 파일이 생성되었을 것이다.
해당 파일의 이름을 Datasets의 물체 이름과 같게 수정해준다.
ex. test.txt -> salt.txt




open_manipulator_master.h에 관련 버퍼를 선언해주고,

  std::vector<WaypointBuffer> record_buffer_salt_;



open_manipulator_play_recorded_trajectory.cpp의 initOpenManipulator에 아래 코드를 넣는다.
아래 코드에서 text 파일을 parsing한 후 record_buffer_salt_ 버퍼에 담는 것이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
string filePath;
  // for Reading File  
  filePath = "/tmp/salt.txt";
  ifstream openFile_salt(filePath.data());
  if(openFile_salt.is_open())
  {
    string line;
    record_buffer_salt_.clear();
    
    while(getline(openFile_salt, line)){
      //cout << line << endl;
      // Parsing text data to record_buffer_
      
      istringstream iss(line);
      WaypointBuffer temp;
      std::vector<double> goal_joint_position_;
      double goal_tool_position_;
      goal_joint_position_.resize(NUM_OF_JOINT);
      goal_tool_position_ = 0.0;
      int count = 0;
      do
      {
        string sub;
        iss >> sub;
        //cout << "Substring: " << sub << endl;
      
        if(count==0) goal_joint_position_.at(0= stod(sub);
        else if(count==1) goal_joint_position_.at(1= stod(sub);
        else if(count==2) goal_joint_position_.at(2= stod(sub);
        else if(count==3) goal_joint_position_.at(3= stod(sub);
        else if(count==4) goal_tool_position_ = stod(sub);
        temp.joint_angle = goal_joint_position_;
        temp.tool_position = goal_tool_position_;
        
        count++;
      } while (iss);
      record_buffer_salt_.push_back(temp);
    }
    openFile_salt.close();
  }
cs

댓글 없음:

댓글 쓰기