This section documents the classes related to VEX smart motors and drivetrain control in DishPy.
vex.Motor
port : The smartport this device is attached to
gears (optional) : The gear cartridge installed in the motor, default is the green 18_1
reverse (optional) : Should the motor's spin direction be reversed, default is False
A new Motor object.
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2, GearSetting.RATIO_36_1)\
motor3 = Motor(Ports.PORT3, True)\
motor4 = Motor(Ports.PORT4, GearSetting.RATIO_6_1, True)
vex.py
2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 |
|
command(*args)
units (optional) : The units for the returned velocity, the default is RPM
The motor command velocity in provided units
vex.py
2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 |
|
current(*args)
units (optional) : The units for the returned current, the default is AMP
The motor current in provided units
vex.py
2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 |
|
direction()
None
The spin direction, FORWARD, REVERSE or UNDEFINED
vex.py
2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 |
|
efficiency(*args)
units (optional) : The units for the efficiency, the only valid value is PERCENT
The motor efficiency in percent
vex.py
2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 |
|
get_timeout()
None
The current timeout value
vex.py
2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 |
|
installed()
None
True or False
vex.py
2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 |
|
is_done()
This function is used when False has been passed as the wait parameter to spin_to_position or spin_for\ It will return False if the motor is still spinning or True if it has completed the move or a timeout occurred.
None
The current spin_to_position or spin_for status
vex.py
2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 |
|
is_spinning()
This function is used when False has been passed as the wait parameter to spin_to_position or spin_for\ It will return True if the motor is still spinning or False if it has completed the move or a timeout occurred.
None
The current spin_to_position or spin_for status
vex.py
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 |
|
position(*args)
units (optional) : The units for the returned position, the default is DEGREES
The motor position in provided units
vex.py
2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 |
|
power(*args)
units (optional) : The units for the returned power, the default is WATT
The motor power in provided units
vex.py
2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 |
|
reset_position()
None
None
vex.py
2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 |
|
set_max_torque(value, units)
The torque can be set as torque, current or percent of maximum.
value : the new maximum torque to use
units : the units that value is passed in
None
# set maximum torque to 2 Nm\
motor1.set_max_torque(2, TorqueUnits.NM)
# set maximum torque to 1 Amp\
motor1.set_max_torque(1, CurrentUnits.AMP)
# set maximum torque to 20 percent\
motor1.set_max_torque(20, PERCENT)
vex.py
2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 |
|
set_position(value, units=RotationUnits.DEG)
The position returned by the position() function is set to this value.
value : The new position
units : The units for the provided position, the default is DEGREES
None
vex.py
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 |
|
set_reversed(value)
Setting the reverse flag will cause spin commands to run the motor in reverse.
value : Reverse flag, True or False
None
vex.py
2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 |
|
set_stopping(value)
Setting the action for the motor when stopped.
value : The stopping mode, COAST, BRAKE or HOLD
None
vex.py
2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 |
|
set_timeout(value, units=TimeUnits.MSEC)
The timeout value is used when performing spin_to_position and spin_for commands. If timeout is reached and the motor has not completed moving, then the spin... function will return False.
value : The new timeout
units : The units for the provided timeout, the default is MSEC
None
vex.py
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 |
|
set_velocity(value, units=VelocityUnits.RPM)
This will be the velocity used for subsequent calls to spin if a velocity is not provided to that function.
value : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 |
|
spin(direction, *args, **kwargs)
direction : The direction to spin the motor, FORWARD or REVERSE
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# spin motor forward at velocity set with set_velocity\
motor1.spin(FORWARD)
# spin motor forward at 50 rpm\
motor1.spin(FORWARD, 50)
# spin with negative velocity, ie. backwards\
motor1.spin(FORWARD, -20)
# spin motor forwards with 100% velocity\
motor1.spin(FORWARD, 100, PERCENT)
# spin motor forwards at 50 rpm\
motor1.spin(FORWARD, 50, RPM)
# spin motor forwards at 360 dps\
motor1.spin(FORWARD, 360.0, VelocityUnits.DPS)
vex.py
2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 |
|
spin_for(direction, rot_or_time, *args, **kwargs)
Move the motor to the requested position or for the specified amount of time.\ The position is relative (ie. an offset) to the current position\ This function supports keyword arguments.
dir : The direction to spin the motor, FORWARD or REVERSE
rot_or_time : The relative position to spin the motor to or tha amount of time to spin for
units (optional) : The units for the provided position or time, the default is DEGREES or MSEC
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# spin 180 degrees from the current position\
motor1.spin_for(FORWARD, 180)
# spin reverse 2 TURNS (revolutions) from the current position\
motor1.spin_for(REVERSE, 2, TURNS)
# spin 180 degrees from the current position at 25 rpm\
motor1.spin_for(FORWARD, 180, DEGREES, 25, RPM)
# spin 180 degrees from the current position and do not wait for completion\
motor1.spin_for(FORWARD, 180, DEGREES, False)
# spin 180 degrees from the current position and do not wait for completion\
motor1.spin_for(FORWARD, 180, DEGREES, wait=False)
vex.py
2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 |
|
spin_to_position(rotation, *args, **kwargs)
Move the motor to the requested position.\ This function supports keyword arguments.
rotation : The position to spin the motor to
units (optional) : The units for the provided position, the default is DEGREES
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# spin to 180 degrees\
motor1.spin_to_position(180)
# spin to 2 TURNS (revolutions)\
motor1.spin_to_position(2, TURNS)
# spin to 180 degrees at 25 rpm\
motor1.spin_to_position(180, DEGREES, 25, RPM)
# spin to 180 degrees and do not wait for completion\
motor1.spin_to_position(180, DEGREES, False)
# spin to 180 degrees and do not wait for completion\
motor1.spin_to_position(180, DEGREES, wait=False)
vex.py
2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 |
|
stop(mode=None)
The motor will be stopped and set to COAST, BRAKE or HOLD
None
None
vex.py
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 |
|
temperature(*args)
units (optional) : The units for the returned temperature, the default is CELSIUS
The motor temperature in provided units
vex.py
2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 |
|
timestamp()
None
timestamp of the last status packet in mS
vex.py
2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 |
|
torque(*args)
units (optional) : The units for the returned torque, the default is NM
The motor torque in provided units
vex.py
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 |
|
velocity(*args)
units (optional) : The units for the returned velocity, the default is RPM
The motor velocity in provided units
vex.py
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 |
|
vex.MotorGroup
One or more Motor class instances
A new MotorGroup object.
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2)\
mg1 = MotorGroup(motor1, motor2)
vex.py
5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 |
|
count()
None
The number of motors in the group
vex.py
5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 |
|
current(units=CurrentUnits.AMP)
units (optional) : The units for the returned current, the default is AMP
The motor current in provided units
vex.py
6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 |
|
direction()
None
The spin direction, FORWARD, REVERSE or UNDEFINED
vex.py
6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 |
|
efficiency(units=PercentUnits.PERCENT)
units (optional) : The units for the efficiency, the only valid value is PERCENT
The motor efficiency in percent
vex.py
6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 |
|
is_done()
This function is used when False has been passed as the wait parameter to spin_to_position or spin_for\ It will return False if any motor is still spinning or True if they have completed the move or a timeout occurred.
None
The current spin_to_position or spin_for status
vex.py
6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 |
|
is_spinning()
This function is used when False has been passed as the wait parameter to spin_to_position or spin_for\ It will return True if any motor is still spinning or False if they have completed the move or a timeout occurred.
None
The current spin_to_position or spin_for status
vex.py
5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 |
|
position(units=RotationUnits.DEG)
units (optional) : The units for the returned position, the default is DEGREES
The motor position in provided units
vex.py
6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 |
|
power(units=PowerUnits.WATT)
units (optional) : The units for the returned power, the default is WATT
The motor power in provided units
vex.py
6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 |
|
reset_position()
None
None
vex.py
5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 |
|
set_max_torque(value, units=TorqueUnits.NM)
The torque can be set as torque, current or percent of maximum.
value : the new maximum torque to use
units : the units that value is passed in
None
# set maximum torque to 2 Nm\
motor1.set_max_torque(2, TorqueUnits.NM)
# set maximum torque to 1 Amp\
motor1.set_max_torque(1, CurrentUnits.AMP)
# set maximum torque to 20 percent\
motor1.set_max_torque(20, PERCENT)
vex.py
6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 |
|
set_position(value, units=None)
The position returned by the position() function is set to this value.
value : The new position
units : The units for the provided position, the default is DEGREES
None
vex.py
5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 |
|
set_stopping(mode=BrakeType.COAST)
Setting the action for the motor when stopped.
mode : The stopping mode, COAST, BRAKE or HOLD
None
vex.py
5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 |
|
set_timeout(timeout, units=TimeUnits.MSEC)
The timeout value is used when performing spin_to_position and spin_for commands. If timeout is reached and the motor has not completed moving, then the spin... function will return False.
timeout : The new timeout
units : The units for the provided timeout, the default is MSEC
None
vex.py
5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 |
|
set_velocity(velocity, units=None)
This will be the velocity used for subsequent calls to spin if a velocity is not provided to that function.
velocity : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 |
|
spin(direction, velocity=None, units=VelocityUnits.RPM)
direction : The direction to spin the motor, FORWARD or REVERSE
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# spin motors forward at velocity set with set_velocity\
mg1.spin(FORWARD)
# spin motors forward at 50 rpm\
mg1.spin(FORWARD, 50)
# spin with negative velocity, ie. backwards\
mg1.spin(FORWARD, -20)
# spin motors forwards with 100% velocity\
mg1.spin(FORWARD, 100, PERCENT)
# spin motors forwards at 50 rpm\
mg1.spin(FORWARD, 50, RPM)
# spin motors forwards at 360 dps\
mg1.spin(FORWARD, 360.0, VelocityUnits.DPS)
vex.py
5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 |
|
spin_for(direction, rotation, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
Move the motor to the requested position or for the specified amount of time.\ The position is relative (ie. an offset) to the current position\ This function supports keyword arguments.
direction : The direction to spin the motor, FORWARD or REVERSE
rotation : The relative position to spin the motor to or tha amount of time to spin for
units (optional) : The units for the provided position or time, the default is DEGREES or MSEC
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# spin 180 degrees from the current position\
mg1.spin_for(FORWARD, 180)
# spin reverse 2 TURNS (revolutions) from the current position\
mg1.spin_for(REVERSE, 2, TURNS)
# spin 180 degrees from the current position at 25 rpm\
mg1.spin_for(FORWARD, 180, DEGREES, 25, RPM)
# spin 180 degrees from the current position and do not wait for completion\
mg1.spin_for(FORWARD, 180, DEGREES, False)
# spin 180 degrees from the current position and do not wait for completion\
mg1.spin_for(FORWARD, 180, DEGREES, wait=False)
vex.py
5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 |
|
spin_to_position(rotation, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
Move the motor to the requested position.\ This function supports keyword arguments.
rotation : The position to spin the motor to
units (optional) : The units for the provided position, the default is DEGREES
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# spin to 180 degrees\
mg1.spin_to_position(180)
# spin to 2 TURNS (revolutions)\
mg1.spin_to_position(2, TURNS)
# spin to 180 degrees at 25 rpm\
mg1.spin_to_position(180, DEGREES, 25, RPM)
# spin to 180 degrees and do not wait for completion\
mg1.spin_to_position(180, DEGREES, False)
# spin to 180 degrees and do not wait for completion\
mg1.spin_to_position(180, DEGREES, wait=False)
vex.py
5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 |
|
stop(mode=None)
The motor will be stopped and set to COAST, BRAKE or HOLD
None
None
vex.py
6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 |
|
temperature(units=TemperatureUnits.CELSIUS)
units (optional) : The units for the returned temperature, the default is CELSIUS
The motor temperature in provided units
vex.py
6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 |
|
torque(units=TorqueUnits.NM)
units (optional) : The units for the returned torque, the default is NM
The motor torque in provided units
vex.py
6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 |
|
velocity(units=VelocityUnits.RPM)
units (optional) : The units for the returned velocity, the default is RPM
The motor velocity in provided units
vex.py
6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 |
|
vex.DriveTrain
lm : Left motor or motorgroup
rm : Right motor or motorgroup
wheelTravel (optional) : The circumference of the driven wheels, default is 300 mm
trackWidth (optional) : The trackwidth of the drivetrain, default is 320 mm
wheelBase (optional) : The wheelBase of the drivetrain, default is 320 mm
units (optional) : The units that wheelTravel, trackWidth and wheelBase are specified in, default is MM.
externalGearRatio (optional) : An optional gear ratio used to compensate drive distances if gearing is used.
A new DriveTrain object.
# A simple two motor drivetrain using default values\
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2, True)\
drive1 = DriveTrain(motor1, motor2)
# A four motor drivetrain using custom values\
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2)\
motor3 = Motor(Ports.PORT3, True)\
motor4 = Motor(Ports.PORT4, True)\
mgl = MotorGroup(motor1, motor3)\
mgr = MotorGroup(motor2, motor4)\
drive1 = DriveTrain(mgl, mgr, 8.6, 10, 12, INCHES)
vex.py
6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 |
|
current(units=CurrentUnits.AMP)
units (optional) : The units for the returned current, the default is AMP
The drivetrain current in provided units
vex.py
6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 |
|
drive(direction, velocity=None, units=VelocityUnits.RPM)
The drive command is similar to the motor spin command.\ all drive motors are commanded using the provided parameters.
direction : The direction to drive, FORWARD or REVERSE
velocity (optional) : spin the motors using this velocity, the default velocity set by set_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# drive forward at velocity set with set_velocity\
drive1.drive(FORWARD)
# drive forward at 50 rpm\
drive1.drive(FORWARD, 50)
# drive with negative velocity, ie. backwards\
drive1.drive(FORWARD, -20)
# drive forwards with 100% velocity\
drive1.drive(FORWARD, 100, PERCENT)
# drive forwards at 50 rpm\
drive1.drive(FORWARD, 50, RPM)
# drive forwards at 360 dps\
drive1.drive(FORWARD, 360.0, VelocityUnits.DPS)
vex.py
6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 |
|
drive_for(direction, distance, units=DistanceUnits.IN, velocity=None, units_v=VelocityUnits.RPM, wait=True)
The drive_for command is similar to the motor spin_for command,\ however, the drivetrain is commanded to move a distance.
direction : The direction to drive
distance : The distance to drive
units (optional) : The units for the provided distance, the default is INCHES
velocity (optional) : drive using this velocity, the default velocity set by set_drive_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None or if wait is True then completion success or failure
# drive forward 10 inches from the current position\
drive1.drive_for(FORWARD, 10, INCHES)
# drive reverse 1000mm from the current position with motors at 50 rpm\
drive1.drive_for(REVERSE, 10000, MM, 50, RPM)
vex.py
6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 |
|
efficiency(units=PercentUnits.PERCENT)
This command only considers the first motor for left and right sides of the drive.
units (optional) : The units for the efficiency, the only valid value is PERCENT
The motor efficiency in percent
vex.py
6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 |
|
get_timeout()
None
Timeout value in mS
vex.py
6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 |
|
is_done()
This function is used when False has been passed as the wait parameter to drive_for or turn_for\ It will return False if the drivetrain is still moving or True if it has completed the move or a timeout occurred.
None
The current drive_for or turn_for status
vex.py
6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 |
|
is_moving()
This function is used when False has been passed as the wait parameter to drive_for or turn_for\ It will return True if the drivetrain is still moving or False if it has completed the move or a timeout occurred.
None
The current drive_for or turn_for status
vex.py
6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 |
|
power(units=PowerUnits.WATT)
This command only considers the first motor for left and right sides of the drive.
units (optional) : The units for the returned power, the default is WATT
The drivetrain power in provided units
vex.py
6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 |
|
set_drive_velocity(velocity, units=VelocityUnits.RPM)
This will be the velocity used for subsequent calls to drive if a velocity is not provided to that function.
velocity : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 |
|
set_stopping(mode=BrakeType.COAST)
Setting the action for the motors when stopped.
mode : The stopping mode, COAST, BRAKE or HOLD
None
vex.py
6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 |
|
set_timeout(timeout, units=TimeUnits.MSEC)
The timeout value is used when performing drive_for and turn_for commands. If timeout is reached and the motor has not completed moving, then the function will return False.
timeout : The new timeout
units : The units for the provided timeout, the default is MSEC
None
vex.py
6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 |
|
set_turn_velocity(velocity, units=VelocityUnits.RPM)
This will be the velocity used for subsequent calls to turn if a velocity is not provided to that function.
velocity : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 |
|
stop(mode=None)
The motors will be stopped and set to COAST, BRAKE or HOLD
None
None
vex.py
6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 |
|
temperature(units=TemperatureUnits.CELSIUS)
This command only considers the first motor for left and right sides of the drive.
units (optional) : The units for the returned temperature, the default is CELSIUS
The motor temperature in provided units
vex.py
6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 |
|
torque(units=TorqueUnits.NM)
This command only considers the first motor for left and right sides of the drive.
units (optional) : The units for the returned torque, the default is NM
The motor torque in provided units
vex.py
6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 |
|
turn(direction, velocity=None, units=VelocityUnits.RPM)
The drive command is similar to the motor spin command.\ all drive motors are commanded using the provided parameters.
direction : The turn direction, LEFT or RIGHT
velocity (optional) : spin the motors using this velocity, the default velocity set by set_turn_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# turn left at velocity set with set_turn_velocity\
drive1.turn(LEFT)
# drive right at 50 rpm\
drive1.turn(RIGHT, 50)
# turn right with 100% velocity\
drive1.turn(RIGHT, 100, PERCENT)
# turn right at 50 rpm\
drive1.turn(RIGHT, 50, RPM)
# turn right at 360 dps\
drive1.turn(RIGHT, 360.0, VelocityUnits.DPS)
vex.py
6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 |
|
turn_for(direction, angle, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
The turn_for command is similar to the motor spin_for command,\ however, the drivetrain is commanded to turn a specified angle.
direction : The direction to turn, LEFT or RIGHT
angle : The angle to turn
units (optional) : The units for the provided angle, the default is DEGREES
velocity (optional) : drive using this velocity, the default velocity set by set_drive_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None or if wait is True then completion success or failure
# turn right 90 degrees\
drive1.turn_for(RIGHT, 90, DEGREES)
# turn left 180 degrees with motors at 50 rpm\
drive1.turn_for(LEFT, 180, DEGREES, 50, RPM)
vex.py
6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 |
|
velocity(units=VelocityUnits.RPM)
units (optional) : The units for the returned velocity, the default is RPM
The drivetrain velocity in provided units
vex.py
6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 |
|
vex.SmartDrive
Bases: DriveTrain
A smart drivetrain uses a gyro or similar sensor to turn more accurately.\ The smartdrive inherits all drivetrain functions.
lm : Left motor or motorgroup
rm : Right motor or motorgroup
g : The gyro, inertial sensor or gps to use for turns
wheelTravel (optional) : The circumference of the driven wheels, default is 300 mm
trackWidth (optional) : The trackwidth of the drivetrain, default is 320 mm
wheelBase (optional) : The wheelBase of the drivetrain, default is 320 mm
units (optional) : The units that wheelTravel, trackWidth and wheelBase are specified in, default is MM.
externalGearRatio (optional) : An optional gear ratio used to compensate drive distances if gearing is used.
A new SmartDrive object.
# A simple two motor smart drivetrain using default values\
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2, True)\
imu1 = Inertial(Ports.PORT9)\
smart1 = SmartDrive(motor1, motor2, imu1)
# A four motor smart drivetrain using custom values\
motor1 = Motor(Ports.PORT1)\
motor2 = Motor(Ports.PORT2)\
motor3 = Motor(Ports.PORT3, True)\
motor4 = Motor(Ports.PORT4, True)\
imu1 = Inertial(Ports.PORT9)\
mgl = MotorGroup(motor1, motor3)\
mgr = MotorGroup(motor2, motor4)\
smart1 = SmartDrive(mgl, mgr, imu1, 8.6, 10, 12, INCHES)
vex.py
6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 |
|
heading(units=RotationUnits.DEG)
heading will be returned in the range 0 - 359.99 degrees
units (optional) : The units to return the heading in, default is DEGREES
A value for heading in the range that is specified by the units.
# get the current heading for the smartdrive\
value = smart1.heading()
vex.py
6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 |
|
is_moving()
This function is used when False has been passed as the wait parameter to drive_for\ It will return True if the drivetrain is still moving or False if it has completed the move or a timeout occurred.
None
The current drive_for status
vex.py
6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 |
|
is_turning()
This function is used when False has been passed as the wait parameter to turn_to_heading or turn_for\ It will return True if the drivetrain is still moving or False if it has completed the move or a timeout occurred.
None
The current turn_to_heading, turn_to_rotation or turn_for status
vex.py
6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 |
|
rotation(units=RotationUnits.DEG)
rotation is not limited, it can be both positive and negative and shows the absolute angle of the gyro.
units (optional) : The units to return the rotation in, default is DEGREES
A value for heading in the range that is specified by the units.
# get the current rotation for the smartdrive\
value = smart1.rotation()
vex.py
6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 |
|
set_heading(value, units=RotationUnits.DEG)
The new value for heading should be in the range 0 - 359.99 degrees.
value : The new value to use for heading.
units (optional) : The rotation units type for value, the default is DEGREES
None
# set the value of heading to 180 degrees\
smart1.set_heading(180)
vex.py
6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 |
|
set_rotation(value, units=RotationUnits.DEG)
value : The new value to use for rotation.
units (optional) : The rotation units type for value, the default is DEGREES
None
# set the value of rotation to 180 degrees\
smart1.set_rotation(180)
vex.py
6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 |
|
set_turn_constant(value)
The smartdrive uses a simple P controller when doing turns.\ This constant, generally known as kp, is the gain used in the equation that\ turns angular error into motor velocity.
value : The new turn constant in the range 0.1 - 4.0, the default is 1.0
None
vex.py
6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 |
|
set_turn_direction_reverse(value)
value : True or False
None
vex.py
6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 |
|
set_turn_threshold(value)
This is the threshold value used to determine that turns are complete.\ If this is too large then turns will not be accurate, if too small then turns ma\ not complete.
value : The new turn threshold in degrees, the default for a smartdrive is 1 degree
None
vex.py
6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 |
|
turn_for(direction, angle, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
The turn_for command is similar to the motor spin_for command,\ however, the smartdrive is commanded to turn a specified angle.
direction : The direction to turn, LEFT or RIGHT
angle : The angle to turn
units (optional) : The units for the provided angle, the default is DEGREES
velocity (optional) : drive using this velocity, the default velocity set by set_drive_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None or if wait is True then completion success or failure
# turn right 90 degrees\
smart1.turn_for(RIGHT, 90, DEGREES)
# turn left 180 degrees with motors at 50 rpm\
smart1.turn_for(LEFT, 180, DEGREES, 50, RPM)
vex.py
6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 |
|
turn_to_heading(angle, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
The turn_to_heading command is similar to the motor spin_to_position command,\ however, the smartdrive is commanded to turn to a specified angle.\ This function uses the value of heading() when turning the smartdrive\ This function supports keyword arguments.
angle : The angle to turn to
units (optional) : The units for the provided angle, the default is DEGREES
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# turn to heading 180 degrees\
smart1.turn_to_heading(180)
# turn to heading 180 degrees at 25 rpm\
smart1.turn_to_heading(180, DEGREES, 25, RPM)
# turn to heading 180 degrees and do not wait for completion\
smart1.turn_to_heading(180, DEGREES, False)
# turn to heading 180 degrees and do not wait for completion\
smart1.turn_to_heading(180, DEGREES, wait=False)
vex.py
6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 |
|
turn_to_rotation(angle, units=RotationUnits.DEG, velocity=None, units_v=VelocityUnits.RPM, wait=True)
The turn_to_rotation command is similar to the motor spin_to_position command,\ however, the smartdrive is commanded to turn to a specified angle.\ This function uses the value of rotation() when turning the smartdrive\ This function supports keyword arguments.
angle : The angle to turn to
units (optional) : The units for the provided angle, the default is DEGREES
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units_v (optional) : The units of the provided velocity, default is RPM
wait (optional) : This indicates if the function should wait for the command to complete or return immediately, default is True.
None
# turn to rotation 180 degrees\
smart1.turn_to_rotation(180)
# turn to rotation 400 degrees at 25 rpm\
smart1.turn_to_rotation(400, DEGREES, 25, RPM)
# turn to rotation 180 degrees and do not wait for completion\
smart1.turn_to_rotation(180, DEGREES, False)
# turn to rotation 180 degrees and do not wait for completion\
smart1.turn_to_rotation(180, DEGREES, wait=False)
vex.py
6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 |
|
vex.Motor29
The Motor29 class will create raw RC style pwm waveform.\ This is primarily for use with the VEX MC29 motor controller\ To minimize current draw, new values sent to the motor will have slew rate control applied
port : The 3wire port to use for the motor controller
reverse_flag (optional) : set reverse flag for this motor, spin commands will cause opposite rotation if set True. default is False.
An instance of the Motor29 class
motor1 = Motor29(brain.three_wire_port.a)
vex.py
4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 |
|
set_reversed(value)
value : 1, 0, True or False
None
# set motor reversed flag True\
motor1.set_reversed(True)
vex.py
4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 |
|
set_velocity(value, units=VelocityUnits.RPM)
This will be the velocity used for subsequent calls to spin of a velocity is not provided to that function.
value : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 |
|
spin(direction, velocity=None, units=None)
The motor is assumed to have a maximum velocity of 100 rpm.
direction : The direction to spin the motor, FORWARD or REVERSE
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# spin motor forward at velocity set with set_velocity\
motor1.spin(FORWARD)
# spin motor forward at 50 rpm\
motor1.spin(FORWARD, 50)
# spin with negative velocity, ie. backwards\
motor1.spin(FORWARD, -20)
# spin motor forwards with 100% velocity\
motor1.spin(FORWARD, 100, PERCENT)
# spin motor forwards at 50 rpm\
motor1.spin(FORWARD, 50, RPM)
# spin motor forwards at 360 dps\
motor1.spin(FORWARD, 360.0, VelocityUnits.DPS)
vex.py
4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 |
|
stop()
None
None
vex.py
4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 |
|
value()
This is the raw internal pwm value\ A motor velocity of 0 will return 127\ A maximum positive motor velocity will return 255
None
A value in the range 0 to 255.
# get motor current pwm value\
value = motor1.value()
vex.py
4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 |
|
vex.MotorVictor
The MotorVictor class will create raw RC style pwm waveform.\ This is primarily for use with the VEX Victor motor controller\
port : The 3wire port to use for the motor controller
reverse_flag (optional) : set reverse flag for this motor, spin commands will cause opposite rotation if set True. default is False.
An instance of the MotorVictor class
motor1 = MotorVictor(brain.three_wire_port.a)
vex.py
4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 |
|
set_reversed(value)
value : 1, 0, True or False
None
# set motor reversed flag True\
motor1.set_reversed(True)
vex.py
4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 |
|
set_velocity(value, units=VelocityUnits.RPM)
This will be the velocity used for subsequent calls to spin of a velocity is not provided to that function.
value : The new velocity
units : The units for the supplied velocity, the default is RPM
None
vex.py
4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 |
|
spin(direction, velocity=None, units=None)
The motor is assumed to have a maximum velocity of 100 rpm.
direction : The direction to spin the motor, FORWARD or REVERSE
velocity (optional) : spin the motor using this velocity, the default velocity set by set_velocity will be used if not provided.
units (optional) : The units of the provided velocity, default is RPM
None
# spin motor forward at velocity set with set_velocity\
motor1.spin(FORWARD)
# spin motor forward at 50 rpm\
motor1.spin(FORWARD, 50)
# spin with negative velocity, ie. backwards\
motor1.spin(FORWARD, -20)
# spin motor forwards with 100% velocity\
motor1.spin(FORWARD, 100, PERCENT)
# spin motor forwards at 50 rpm\
motor1.spin(FORWARD, 50, RPM)
# spin motor forwards at 360 dps\
motor1.spin(FORWARD, 360.0, VelocityUnits.DPS)
vex.py
4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 |
|
stop()
None
None
vex.py
4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 |
|
value()
This is the raw internal pwm value\ A motor velocity of 0 will return 127\ A maximum positive motor velocity will return 255
None
A value in the range 0 to 255.
# get motor current pwm value\
value = motor1.value()
vex.py
4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 |
|