User Tools

Site Tools


make_drc-hubo_wave_its_hands_non-whole_body_kinematics

Differences

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

Link to this comparison view

Next revisionBoth sides next revision
make_drc-hubo_wave_its_hands_non-whole_body_kinematics [2016/08/10 10:53] – created santiagoricoymake_drc-hubo_wave_its_hands_non-whole_body_kinematics [2016/08/11 00:32] santiagoricoy
Line 11: Line 11:
  
  
 +{{:ricoykaist:armwave:podo_gui_--_rainbow_robotics_107.png?nolink&700}}
  
 This tutorial is a brief overview of the basic concepts necessary to link the GUI to an Al via the shared memory and execute a command.  This tutorial is a brief overview of the basic concepts necessary to link the GUI to an Al via the shared memory and execute a command. 
Line 17: Line 17:
 I assume the reader understands: I assume the reader understands:
  
-* Knows how to create a new Al +  * Knows how to create a new Al 
-*Has fundamental knowledge of C++ +  * Has fundamental knowledge of C++ 
-*Can use Qt Creator+  * Can use Qt Creator
  
  
Line 30: Line 30:
  
  
-====Programming====+====Setup==== 
 +Open a session with your directory's PODOGUI project, PODOLauncher project, and ALPrograms project. 
 + 
 +{{:ricoykaist:armwave:podogui.pro_necktopic_-_review_session_-_qt_creator_112.png?nolink&700|}}
  
 We'll be utilizing the ALTutorial/TutorialDialog combination for this specific tutorial. The steps would essentially be the same for any GUI/Al combination. After this tutorial, you should be able to transfer these methods to another Al. We'll be utilizing the ALTutorial/TutorialDialog combination for this specific tutorial. The steps would essentially be the same for any GUI/Al combination. After this tutorial, you should be able to transfer these methods to another Al.
 +
 +====GUI Side====
 +{{:ricoykaist:armwave:tutorialdialog.ui_necktopic_-_review_session_-_qt_creator_101.png?nolink&700}}
 +
  
 First, go into the PODOGUI folder and open "TutorialDialog.ui", and in the designer window, I've dragged a push button onto the dialog. On the right side of the screen is an option to change the object name, where I've changed it to "pb_WaveArms". After editing your button and changing the name, right click the button. Click "Go to slot..." and choose "clicked()". First, go into the PODOGUI folder and open "TutorialDialog.ui", and in the designer window, I've dragged a push button onto the dialog. On the right side of the screen is an option to change the object name, where I've changed it to "pb_WaveArms". After editing your button and changing the name, right click the button. Click "Go to slot..." and choose "clicked()".
  
 +{{:ricoykaist:armwave:selection_103.png?nolink&500}}
  
 This should take you to a method definition within "TutorialDialog.cpp". Insert the code snippet below into the method. Choose a number above 100 (if you've gone through the [[creating_the_basics_of_a_new_al|Creating a new Al for PODO]] tutorial, you'll remember why) and set your USER_COMMAND element to that number. The COMMAND_TARGET for this Al is contained in ALNum_Tuto, so initialize the COMMAND_TARGET to that variable. Finally, the command is sent to shared memory. This should take you to a method definition within "TutorialDialog.cpp". Insert the code snippet below into the method. Choose a number above 100 (if you've gone through the [[creating_the_basics_of_a_new_al|Creating a new Al for PODO]] tutorial, you'll remember why) and set your USER_COMMAND element to that number. The COMMAND_TARGET for this Al is contained in ALNum_Tuto, so initialize the COMMAND_TARGET to that variable. Finally, the command is sent to shared memory.
-Note: If we have the same enumeration declaration in both our ALTutorial/main.cpp and TutorialDialog.cpp, as demonstrated in the Al creation tutorial, we could use the names chosen instead.+
  
     USER_COMMAND cmd;     USER_COMMAND cmd;
Line 45: Line 53:
     pLAN->SendCommand(cmd);     pLAN->SendCommand(cmd);
          
-Go to the ALTutorial/main.cpp file, and scroll down until you are looking under the "Initialize RBCore comment". This is where the connection between GUI and Al is made. Within the while loop will be a switch statement that takes "sharedCMD->COMMAND[PODO_NO].USER_COMMAND" as its argument. Add your own case as shown below. This is very similar to the command in the Al creation tutorial, but now we are changing an integer variable called _MoveMode. You must declare this variable globally toward the top of the file.+Note: If we have the same enumeration declaration in both our ALTutorial/main.cpp and TutorialDialog.cpp, as demonstrated in the Al creation tutorial, we could use the names chosen instead. That method is more easily read and explicit, but this way shows why we use that method.     
 + 
 +====Al Side==== 
 + 
 +{{:ricoykaist:armwave:selection_097.png?nolink&500|}} 
 + 
 + 
 +Go to the ALTutorial/main.cpp file, and scroll down until you are looking under the "Initialize RBCore comment". This is where the connection between GUI and Al is made. Within the while loop found there will be a switch statement that takes "sharedCMD->COMMAND[PODO_NO].USER_COMMAND" as its argument. Add your own case as shown below. This is very similar to the command in the Al creation tutorial, but now we are changing an integer variable called _MoveMode. You must declare this variable globally toward the top of the file.
  
             {             {
Line 54: Line 69:
             sharedCMD->COMMAND[PODO_NO].USER_COMMAND = NO_ACT;             sharedCMD->COMMAND[PODO_NO].USER_COMMAND = NO_ACT;
             }             }
 +
 +====Executing the Command====
 +            
 +{{:ricoykaist:armwave:selection_110.png?nolink&500|}}
                          
-If you scroll down and find the task thread, you'll find another while loop. Within this we will place another switch statement whose argument will be _MoveMode. _MoveMode will dictate which set of actions will be performed in the task thread. When _MoveMode is equal to 0, the loop will do nothing.+If you scroll down and find the task thread, you'll find another while loop. Within this we will place another switch statement whose argument will be an integer variable that you should declare globally. I called it _MoveMode. _MoveMode will dictate which set of actions will be performed in the task thread. When _MoveMode is equal to 0, the loop will do nothing.
  
 +{{:ricoykaist:armwave:selection_111.png?nolink&500|}}
  
 Here, when _MoveMode is 1, we'll be simply printing out some text, and when _MoveMode is 2, it performs our desired action. So how to go about it? Here, when _MoveMode is 1, we'll be simply printing out some text, and when _MoveMode is 2, it performs our desired action. So how to go about it?
  
 +=== The SetMoveJoint Function ===
  
-We're not using whole body kinematics, but very simple angle changes on joints. For that, the basic SetMoveJoint function is used.+We're not using whole body kinematics, but very simple angle changes on joints. For that, the basic SetMoveJoint function is used from the jCon class.
  
 For example: For example:
-jCon->SetMoveJoint(RSR, -90.0, 2000.0, MOVE_ABSOLUTE) +jCon->SetMoveJoint(RSR, -90.0, 2000.0, MOVE_ABSOLUTE)
  
 There are four parameters: There are four parameters:
  
-First is the joint, then degree, the time to make the change, and the movement mode.+First is the joint, then the reference degree, the time to make the change, and the movement mode. Commands for different joints can be executed at the same time. 
 + 
 +{{:ricoykaist:armwave:selection_100.png?nolink&300|}} 
 + 
 +The joint names are actually sets of numbers, but have been enumerated for convenience. That set can be found in "JointInformation.h" as seen above. Hubo's joint angle directions are decided via the right hand rule. The X-axis points forward, the Y-axis points left, and the Z-axis points upward. You can decide which direction is negative or positive by using the right hand rule on the axis that the joint aligns with (assuming the robot is in home position). Please keep in mind that too little time for a large movement can break a joint in DRC-Hubo. Lastly, your movement mode is either MOVE_ABSOLUTE (move to an absolute angle based on encoder pulses from the joint home position) or MOVE_RELATIVE (move to a certain angular distance from the current position). 
 + 
 +{{:ricoykaist:armwave:selection_098.png?nolink&500}} 
 + 
 +As you can see, here, I've separated left and right arm movements for convenience. Your movements may be similar. For lots of commands like this, the CTRL+F command to replace numbers/movement modes quickly is useful. 
 + 
 +The task thread is a loop whose timing is 0.005 seconds per cycle, so in our example if statements, you will find that we are timing in actual seconds. Therefore, each time our counter variable (which should be declared and initialized to 0 outside of the while loop) is incremented, it takes 0.005 seconds. So every 200 increments happens in one second. We do this because we want consecutive movements, so we have the computer wait until sending the next set of commands. 
 + 
 +{{:ricoykaist:armwave:podo_gui_--_rainbow_robotics_107.png?nolink&500|}}
  
-The joint names are actually sets of numbersbut have been enumerated for convenienceThat set can be found in "jointinformation.h".+If all was done correctlyrebuid, and run the PODOLauncherOpen the Daemon and the GUI, connect the GUI to the DaemonOpen the ALTutorial process, and click your buttonIt should work!
  
-The task thread is a loop whose timing is more or less 0.05 seconds per cycle, so in our example if statements, you will find that we are timing in actual seconds.+**Notes**:  
 +  * There are several issues that could pop up during execution. The most common  
 +  * There should be some functions already present in the task thread while loop. These work best at the end of the loop.  
 +  * Be sure to place your counter variable initialization outside of the while loop, or you'll end up with some very...interesting results.  
 +  * Your counter variable should be reset at the end of your movement for repeatability. 
 +  * _MoveMode should alse be reset to at the end of your movement. 
 +  * This is a simple example using MOVE_ABSOLUTEbut in some cases you may want to use MOVE_RELATIVE. If your loop has any command redundancies in MOVE_RELATIVE, it could work in the simulator, but break the joint on the physical robot. So walk through your code first.
  
  
make_drc-hubo_wave_its_hands_non-whole_body_kinematics.txt · Last modified: 2016/08/30 19:11 by santiagoricoy