|Using PyPose with the CM9_BC library (and setting up a Windows computer for PyPose)|
|Writer : NaN||DATE : November 6, 2013 | Hit : 3,189|
1) (Windows) Download and install python 2.7 by going to http://python.org/download/ and selecting the latest version of the "Python 2.7.x Windows Installer". Python serial port support is not great for 64-bit Windows, and any performance advantage of 64-bit python is not needed for PyPose.
2) (Windows) Download and install wxPython by going to http://www.wxpython.org/download.php and selecting the latest version of "wxPython2.x-win32-unicode-py2.7" installer link (will have "32-bit Python 2.7" adjacent to the link). If Python2.7 was installed correctly, the wxPython installer will produce no errors or warnings. NOTE: wxPython does not support Python3 and the PyPose files have not been completely modified to be Python3 compatible.
3) (Windows) Download and install the latest version of PySerial by going to http://sourceforge.net/projects/pyserial/files/pyserial/2.7/ and selecting "pyserial-2.7.win32.exe". Follow the on-screen instructions of the installer, and all should be well.
4) Download the latest version of PyPose (modified slightly to accommodate the hardware USB serial port of the CM9) by going to https://github.com/tician/pypose/ and clicking the "Download ZIP" button. No installation is required. Simply extract the contents to a convenient location and double-click on "pypose.py" to start the program (alternatively, open a command prompt, cd into the PyPose folder and run "python.exe pypose.py").
5) Open the CM9 IDE and upload the pypose sketch to the CM9 (File -> Examples -> CM9_BC -> pypose).
1) Connect the CM9 USB cable to the PC.
2) Start up PyPose as described in #4 above.
3) Select the correct serial port (config -> port).
4) Create a new project (project -> new). In the pop-up window, type in a text name, verify the number of servos, and verify the servo resolution. PyPose will always use servo ID numbers starting at ID==1, so if you have a servo of ID==20, then will need to select 20 as number of servos. PyPose also does not yet support mixed resolution servos; you cannot use AX/RX/EX servos (having a 10-bit potentiometer) together with MX servos (having a 12-bit magnetic encoder). This should be resolved in a future project for creating motions (not PyPose or RoboPlus Motion).
5) Create a new pose by clicking the "add" button in the main window and entering a text name in the pop-up window.
5a) Capture current servo positions into the pose by using the "capture" button. If the servos are not found, check that you have actually applied power to the servos and that no cables are damaged.6) Create a new motion sequence by going to the "sequence editor tool" (tools -> sequence editor).
6a) Create a new sequence using the "add" button and entering a text name in the pop-up window.7) Save the project (file -> save) and create a BioloidController compatible header file (tools -> export to header).
The version of PyPose in the tician/pypose repository should create header files compatible with the CM9_BC library, but may require a little bit of manual manipulation to make them easier for human readability. PyPose also creates only a single header file instead of separating poses and sequences into two header files like the "mtn2cm9rpm.py" script. These issues should be fixed sometime very soon.
Using the headers in a sketch:
1) Create a new sketch, or modify an example sketch (tutorial_1 is poses, tutorial_2 is sequences).
2) Include the CM9_BC library (#include <CM9_BC.h>) and the newly created header file.
3) Follow the processes in the first two tutorial sketches in libraries' example folder.
Using a RoboPlus Motion file to create CM9_BC compatible headers:
1) Copy the RoboPlus Motion file to the CM9_BC/example folder, or copy the "mtn2cm9rpm.py" script to the folder containing the RoboPlus Motion file.
2) Open a terminal, cd to the folder containing both the python script and the RoboPlus Motion file, and run "python.exe mtn2cm9rpm.py -i TheInputRoboPlusMotionFile.mtn -p SomeSpecialNameToPrefixTheImportedPosesAndSequences". Adding a "-T" or "--task" to the list of arguments will create an RPM_Array that will be directly compatible with the MotionPage numbers of a RoboPlus Task program using the same Motion file.
3) Copy the three header files to your sketch's folder, include the CM9_BC library (#include <CM9_BC.h>) and the RPM header (#include "HelloRobo_RPM.h"), and follow the processes used in the third tutorial and/or the soccer example. The RPM header includes the Sequences header, which includes the Poses header.