Difference between revisions of "Sc mc python examples"

From DIDEAS Wiki
Jump to: navigation, search
m (Created page with " =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 ...")
 
m
Line 1: Line 1:
 +
=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'.
  
=prepare the hardware=
+
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
 +
 
 +
==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:
 
Take the robot out of its boot mode so that it can be controlled externally.  Generally the following special commands achieve this:
  
Line 8: Line 32:
 
*[1421, 17]  # MC statemachine to a 'do nothing success state'
 
*[1421, 17]  # MC statemachine to a 'do nothing success state'
  
=move robot back - fort in voltage mode=
+
==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:
 
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
 
*[1115, 1000, 0, 6]    # qVq = 1000, mode = 6 (voltage
Line 16: Line 40:
 
*[1115, 0,0,0]        # short the motor leads
 
*[1115, 0,0,0]        # short the motor leads
  
=enter trajectory mode=
+
==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.
 
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.
  

Revision as of 15:39, 5 November 2010

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

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