Difference between revisions of "Sc mc python examples"
m (→read robot status) |
m |
||
Line 1: | Line 1: | ||
+ | {{pf_top_nav}} | ||
+ | |||
+ | |||
=special command sequences that are interesting= | =special command sequences that are interesting= | ||
Below are some special command that result in some interesting robot behavior. These special commands can be provided via 'do_command.py', or 'pfcmdmenu.exe', or directly in python with the method 'do_command' in the module 'pfcmd.py'. | Below are some special command that result in some interesting robot behavior. These special commands can be provided via 'do_command.py', or 'pfcmdmenu.exe', or directly in python with the method 'do_command' in the module 'pfcmd.py'. |
Revision as of 15:49, 5 November 2010
PF Users Navigation:
- PCB; Lifefix_users; Pf_users; benchtest_users; CalibFix Users; Hardware; Assembly ; iochan ;
- PCA : PCB ; AKENC SC/MC 218 ; FET 217 ; IMU219 ; Swifi ; Rev200_mods ; PCA Inventory
- Special Commands to the Ankle (PFCMD) : State Controller Commands; Motor Controller Commands; Python Examples; IMU Commands ;PFCMD_PY; Pf_calb_table_py; Virtual spring test; PF EEPROM
- DOC: Pf_users; Powerfoot Keyboard User Interface; Steps for Manual Tuning; "Dashboard" Program For Assisting with Tuning
- NEW (CEB) WIKI
- Torque Feedback Controller Guide
Contents
special command sequences that are interesting
Below are some special command that result in some interesting robot behavior. These special commands can be provided via 'do_command.py', or 'pfcmdmenu.exe', or directly in python with the method 'do_command' in the module 'pfcmd.py'.
The special command sequences below are listed in braces as comma separated values. For example for the sequence [100, 200, 300]
With do_command.py you would type:
do_command.py -p <serial port> -s 100 200 300
With pfcmdmenu.exe, in the string box :
100 200 300
With python, assuming pf is an instance of pfcmd.py:
result = pf.do_command('special', [100, 200, 300])
read robot status
- [104] # read SC status info
- [1101] # get motor mode
- [1106] # get encoder positions
- [1420] # get MC SM state
- [1105] # get motor velocity
- [1116] # read MC ADCs
- [1120] # get overload status values
- [230] # get IMU enable
An example reading SC status with do_command.py and special command 104, on serial port 17:
do_command.py -p 17 -n 10 -s 104
prepare the hardware
Take the robot out of its boot mode so that it can be controlled externally. Generally the following special commands achieve this:
- [231, 0] # IMU off - to minimize possible loss of commands over the FUP
- [173,77,7] # demux statemachine to idle mode
- [170,77,17] # primary statemachine to the 'do nothing state'
- [1421, 17] # MC statemachine to a 'do nothing success state'
move robot back - fort in voltage mode
After preparing the hardware above, can use special command 1115 to command a fixed voltage across the motor:
- [1115, 1000, 0, 6] # qVq = 1000, mode = 6 (voltage
- sleep 1 sec
- [1115, -1000, 0, 6] # qVq=-1000
- sleep 1 sec
- [1115, 0,0,0] # short the motor leads
enter trajectory mode
The trajectory mode will servo the robot to the goal position. This is achieved by adjusting the sent point of a virtual spring (whos parmeters) are adjusted. The goal point for the VS is set based on diffeence equstion that produces an exponential response to a position step input.
- [1318, 100] # set goal position to 100 need to be careful to limit the goal position to valid positions!!!
- [1421, 41] # go to trajectory control mode, robot immediatly jumps!
- sleep 1 sec
- [1318, 500] # servo to position 500
python examples
########################## # BASIC CODE REQUIRE TO ESTABLISH A ROBOT CONNECTION ########################### # update the python path variable import python_paths_default import python_paths as pyenv import pfcmd # robot communication module COM_PORT = 17 # use device manager to determine port # pf = pfcmd.PFCmd(0, 0); # instance of communication module pf.connect(COM_PORT, 115200); # baudrate=115200
#################################################### # send special commands to 'prepare the hardware' #################################################### pf.do_command('special',[173, 77, 7]); pf.do_command('special',[170, 77, 17]); pf.do_command('special',[1421, 8]); pf.do_command('special',[173, 77, 6]); pf.do_command('special',[170, 77, 17]);
#################################################### # move robot with voltage mode #################################################### for i in range(0,10) : print i pf.do_command('special',[1115, 2000, 0 ,6]); time.sleep(1.0) pf.do_command('special',[1115, -2000, 0 ,6]); time.sleep(1.0) pf.do_command('special',[1115, 0]);
#################################################### # do some trajectory control ####################################################
pf.do_command('special',[1318, 0]); # set goal position pf.do_command('special',[1421, 41]); # enter trajectory mode
for i in range(0,10) :
pf.do_command('special',[1318, 500]); # change goal position time.sleep(0.5); pf.do_command('special',[1318, 50]); time.sleep(0.5);
pf.do_command('special',[1421, 17]); # back to MC idle state
pf.do_command('special',[1115, 0]); # short leads
</pre>