User Tools

Site Tools


darwin_walk_backward

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
darwin_walk_backward [2017/11/20 17:24] – [Programming] yuhanghedarwin_walk_backward [2017/11/21 11:37] (current) – [Programming] yuhanghe
Line 10: Line 10:
 {{ ::yuhang:darwin_sprint:darwin_target.jpg?700 |}} {{ ::yuhang:darwin_sprint:darwin_target.jpg?700 |}}
 \\  \\ 
-This tutorial will demonstrate how to program Darwin OP 2 to walk backward. The walking algorithm for backward motion is included in Darwin OP 2's source code by Robotis. However, there is no on-line, or barely any, documentation of this process. This tutorial take approximately 1 hour to complete.+This tutorial will demonstrate how to program Darwin OP 2 to walk backward. The walking algorithm for backward motion is included in Darwin OP 2's source code by Robotis. However, there is no on-line, or barely any, documentation of this process. This tutorial will provide some insight into the process and it will take approximately 1 hour to complete.
 \\  \\ 
  
 ===== Motivation and Audience ===== ===== Motivation and Audience =====
  
-This tutorial's motivation is to demonstrate how to program Darwin OP 2 to walk toward a target. This tutorial assumes the reader has the following background and interests: +This tutorial's motivation is to demonstrate and document how to program Darwin OP 2 to walk backward. This tutorial assumes the reader has the following background and interests: 
  
   * Familiar with handling Darwin OP 2   * Familiar with handling Darwin OP 2
Line 29: Line 29:
 ===== Programming ===== ===== Programming =====
  
-Following a target can be accomplished through BallFollower ClassThere is a [[http://support.robotis.com/en/product/darwin-op/development/tutorials/linux/walking_control.htm| tutorial]] on Robotis' online manual that may provide further detail+Darwin OP 2's Walking class calculates motor positions for walking algorithm internally based on parameters. Most of these parameters can be edited through walking_tuner programHere is a detailed [[http://support.robotis.com/en/product/darwin-op/development/tools/walking_tuner.htm | tutorial ]] from Robotis on how to use walking_tuner. 
-\\  +\\ \\  
-This tutorial will only demonstrate parts of program that needs modification to include program Darwin OP 2 to walk toward target.+There are 3 parameter in walking_tuner that cannot be saved: ''Step forward/back (mm), Step right/left (mm), and Step Direction (degree)''. Instead, these variables should be updated constantly by your program during Darwin OP 2's walking process.  
 +\\ \\  
 +Below is a sample program that demonstrates Darwin OP 2 walking backward. Place both ''main.cpp'' and ''Makefile'' inside new folder in directory **''robotisop2/Linux/project/tutorial/''**Then, type ''make'' command to compile  executable and type ''./walk_backward'' to execute program. 
  
 <code cpp | main.cpp> <code cpp | main.cpp>
Line 69: Line 72:
  return 0;  return 0;
  }  }
-    MotionManager::GetInstance()->LoadINISettings(ini); +        //Port initialization and opening, dynamixel power on 
-    Walking::GetInstance()->LoadINISettings(ini);+         
 +        MotionManager::GetInstance()->LoadINISettings(ini); 
 +        Walking::GetInstance()->LoadINISettings(ini); 
 +        //Load default settings for MotionManager and Walking module
  
  MotionManager::GetInstance()->AddModule((MotionModule*)Head::GetInstance());  MotionManager::GetInstance()->AddModule((MotionModule*)Head::GetInstance());
  MotionManager::GetInstance()->AddModule((MotionModule*)Walking::GetInstance());  MotionManager::GetInstance()->AddModule((MotionModule*)Walking::GetInstance());
-    LinuxMotionTimer *motion_timer = new LinuxMotionTimer(MotionManager::GetInstance()); +        LinuxMotionTimer *motion_timer = new LinuxMotionTimer(MotionManager::GetInstance()); 
-    motion_timer->Start();+        motion_timer->Start(); 
 +        //Create MotionManager object and registers head and walking modules, then timers are initialized.
  /////////////////////////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////
  
 +        /////////////////////////Capture Motor Position//////////////////////
  int n = 0;  int n = 0;
  int param[JointData::NUMBER_OF_JOINTS * 5];  int param[JointData::NUMBER_OF_JOINTS * 5];
Line 102: Line 110:
  }  }
  cm730.SyncWrite(MX28::P_GOAL_POSITION_L, 5, JointData::NUMBER_OF_JOINTS - 1, param);  cm730.SyncWrite(MX28::P_GOAL_POSITION_L, 5, JointData::NUMBER_OF_JOINTS - 1, param);
 +        //Capture initial position of Darwin OP 2's motor position 
 +        
  printf("Press the ENTER key to begin!\n");  printf("Press the ENTER key to begin!\n");
  getchar();  getchar();
  
-    Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true); +        Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true); 
-    Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true, true);+        Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true, true);
  MotionManager::GetInstance()->SetEnable(true);  MotionManager::GetInstance()->SetEnable(true);
 +        //Walking and MotionManager enable motors
  
     while(1)     while(1)
Line 119: Line 129:
  
                 if(Walking::GetInstance()->IsRunning() == false){                 if(Walking::GetInstance()->IsRunning() == false){
-                Walking::GetInstance()->X_MOVE_AMPLITUDE = -30.0;+                Walking::GetInstance()->X_MOVE_AMPLITUDE = -15.0; 
 +                //X_MOVE_AMPLITUDE is a variable in Walking class that controls Darwin OP 2's walking step length,  
 +                //each unit corresponds to approximately 1 mm. Set X_MOVE_AMPLITUDE to negative numbers to program  
 +                //Darwin OP 2 to walk backwards. The Walking class calculates corresponding motor positions  
 +                //internally 
 +                
                 Walking::GetInstance()->A_MOVE_AMPLITUDE = 0.0;                 Walking::GetInstance()->A_MOVE_AMPLITUDE = 0.0;
 +                //A_MOVE_AMPLITUDE is a variable in Walking class that controls Darwin OP 2's yaw movement. Each 
 +                //unit correspond approximately to 1 degree. Positive degrees for Darwin OP 2 to turn 
 +                //counterclockwise, negative degree for clockwise. 
 +                
                 Walking::GetInstance()->Start();                 Walking::GetInstance()->Start();
 +                //Start walking algorithm
                 }                 }
  
- Walking::GetInstance()->X_MOVE_AMPLITUDE = -30.0;+ Walking::GetInstance()->X_MOVE_AMPLITUDE = -15.0;
  Walking::GetInstance()->A_MOVE_AMPLITUDE = 0.0;  Walking::GetInstance()->A_MOVE_AMPLITUDE = 0.0;
 +                
       }       }
  
Line 132: Line 153:
     return 0;     return 0;
 } }
 +</code>
  
- +<code make | Makefile>
-<code make | MakeFile>+
  
 TARGET = walk_backward TARGET = walk_backward
Line 171: Line 192:
 ===== Demonstration ===== ===== Demonstration =====
  
-In this demonstration,created a new mode called Sprint mode following the previous step and successfully execute it on Darwin OP 2.+In this demonstration, I successfully compile and execute the above programs
  
-{{ youtube>HaZladeEsJo?large }} +{{ youtube>GQ8AyZpQ9NU?large }} 
  
 ===== Final Words ===== ===== Final Words =====
  
-This tutorial's objective was to demonstrate how to program Darwin OP 2 to walk toward target+This tutorial's objective was to demonstrate how to program Darwin OP 2 to walk backward
 \\ \\
 \\ \\
darwin_walk_backward.1511227497.txt.gz · Last modified: by yuhanghe