I am using vscode with the Vex Robotics extension and I don’t know how to drive the drivetrain. I have a 6 motor drive setup using the smartmotor based on this post 6 motor drivetrain Python coding
This is my code please help
All I’m seeing in your code are function commands, no actual controls, are you trying to use competition template or just something to drive for fun? Cause right now theres nothing commanding the robot to take controls from your controller, just a bunch of “def” to call out when you want it.
I’m trying to figure out how to do it. I don’t know how to do it. It is tank drive but I want arcade controls. If you could help me with that it would be greatly appreciated.
Here is the code style we usually use for usercontrol,
# ---------------------------------------------------------------------------- #
# #
# Module: main.py #
# Author: Kaleo03 #
# Created: Thu Aug 25 2022 #
# Description: Auto Drive #
# #
# ---------------------------------------------------------------------------- #
# Library imports
from vex import *
# Brain should be defined by default
brain=Brain()
# Robot Configuration Code
LfM = Motor(Ports.PORT1)
LbM = Motor(Ports.PORT11)
RfM = Motor(Ports.PORT2, True)
RbM = Motor(Ports.PORT12, True)
InerT = Inertial(Ports.PORT13)
# Motor groups
LgM = MotorGroup(LfM, LbM)
RgM = MotorGroup(RfM, RbM)
# drivetrain and Controller
SupaDrive = SmartDrive(LgM, RgM, InerT, 300, 320, 320, MM, 1)
# 2 motor groups, inertial sensor, wheel base measurement, track base measuerement, Inches or MM, gear ration in decial form
Control1= Controller()
#Functions
#Competition Code
def pre_autonomous():
wait(10)
def autonomous():
wait(15000)
def usercontrol():
while True:
# controller with joy sticks
LgM.set_velocity((Control1.axis3.position() + Control1.axis1.position()), PERCENT)
RgM.set_velocity((Control1.axis3.position() - Control1.axis1.position()), PERCENT)
LgM.spin(FORWARD)
RgM.spin(FORWARD)
#Buttons
wait(10)
comp = Competition(usercontrol, autonomous) #do not touch this
pre_autonomous() #do not touch this
I usually go over with the kids how to program motors, set up motor groups and set up Super Drives, and then show them how to make functions for auton.
You can use the same code, just add the two extra motors into the beginning and then add to the motor groups, it will work the same way. Just take note of the 2 extra motors spin the opposite direction (stacking of the 6th motor) that needs to be reflected in your code.