Random questions that I need help on

If you guys could either give an answer with an explanation, or provide a link to where I can find the answer to my questions, that would be great! :slight_smile:

  1. How is arcade code formed? Like what is the basic form of it? I know for tank drive you can just use the axis position like this(and modify the amount of power you get by dividing):
leftFront.spin(directionType::fwd, Controller1.Axis3.position()/1.25, pct);
leftBack.spin(directionType::fwd, Controller1.Axis3.position()/1.25, pct); 
rightFront.spin(directionType::fwd, Controller1.Axis2.position()/1.25, pct);
rightBack.spin(directionType::fwd, Controller1.Axis2.position()/1.25, pct); 

But how would arcade drive work? Could you use motor groups to make it easier to code? I mainly just don’t get the adding and subtracting part. Here’s a sample code I found:

leftFront.spin(vex::directionType::fwd, (Controller.Axis3.value() + Controller.Axis4.value()), vex::velocityUnits::pct);
leftBack.spin(vex::directionType::fwd, (Controller.Axis3.value() + Controller.Axis4.value()), vex::velocityUnits::pct);
rightFront.spin(vex::directionType::fwd, (Controller.Axis3.value() - Controller.Axis4.value()), vex::velocityUnits::pct);
rightBack.spin(vex::directionType::fwd, (Controller.Axis3.value() - Controller.Axis4.value()), vex::velocityUnits::pct);
  1. How would you make the drivetrain coast instead of brake? I don’t know if this code here will work:
leftFront.setBrake(brakeType::coast);
leftBack.setBrake(brakeType::coast);
rightFront.setBrake(brakeType::coast);
rightBack.setBrake(brakeType::coast);

and where I should put it(usercontrol, preautonomous, etc.)?

  1. When building drivetrains or anything that requires a motor, should you just build it with the motor cap only and then attach the motor base later with rubber bands or zipties?

  2. When attaching motors, should you screw both screws through the bearing into the motor or do only 1 screw through bearing and another directly into the motor? (apparently someone said that screwing 2 directly into the motor makes it easier for the motor to get loose…idk)

  3. Apparently, the motor acts as one bearing so you only need 1 other bearing on the outer c channel? And would you put that bearing in the “deadspace” of the outer c channel? (to save space for screw joints)

  4. HS or LS gears for screw joints? And how many holes wide(between the two c channels) is usually the best/average for screw joints?

thanks

  1. Arcade drive is using one joystick to control how the robot moves. Moving the joystick up and down makes the robot move forward and backward. Moving the joystick left and right makes the robot turn left and right on the spot. We can achieve this by adding or subtracting the turn control value to/from the forward control value. This will cause the robot to turn on the spot when the robot is not moving (forward = 0). You can make it easier to understand by putting Controller.Axis3.value() in a variable named fwd or forward. Similar thing with Controller.Axis4.value() and turn.
    And yes you are correct that using motor groups will make it easier. The same motors on each side should always be spinning in the same direction and speed in a standard tank/inline drive. Many teams will actually mechanically connect them together through gears.
    There is also a type called split arcade, where the left joystick is used for forward/backward and the right joystick is used for turning. This makes driving forward and backward easier without the chance of you accidentally turning because the joystick was not pushed directly straight, but in general this is a personal preference of the driver.

  2. I personally do not use vexcode myself, but according to online documentation, that seems to be correct. If it is wrong, someone please correct me. Thanks

  3. Attaching the motor base using rubber bands or zip ties (or both) is a “strategy” my team calls “hot swapping” (no clue if this is a professional term or not lol), but it basically lets us the motor quickly in case the motor starts overheating. If you are confident that the motor will not overheat, then you should leave them screwed in as using rubber bands and zip ties has a higher chance of the motor falling out.

  4. There should not be a need for the screw to be in a bearing as the motor cap has threading that should fit into the hole in a c-channel to ensure the motor is centered.

  5. That is true and yes. For the first question, it would only be a problem if you wanted to free spin it without a motor, where the shaft will touch the c-channel.

  6. We usually do HS to avoid the gear cracking. However, if you need the extra space, you can use LS, but you would have to be prepared at a competition to switch it out in case it does crack.
    If I remember correctly, we usually use 6 holes wide with HS, which is the widest it can be as there is no longer screw. (I am not 100% sure on this information)

1 Like

So to answer question 2.

you need to set the braking type (You already did this, but it needs to be a different format)

leftFront.setStopping(coast);
etc.
  1. It varies per person, but yes.
  2. You do not need a bearing on the side of the motor, and never screw it through a bearing.
  3. yes, yes and yes yes yes
  4. you have to use hs gears for screw joints given the nature of having to have a circle insert. (You can drill our a ls but I would not recommend it.
1 Like

This is a very basic explanation!

You should have a look at this. It’s all the documentation :slight_smile:

For an example, you could format it something like this:

// init motors
// e.g. vex::motor leftFront(PORT1);

// Create motor groups.
 vex::motor_group left_drive(leftFront, LeftBack);
 vex::motor_group right_drive(rightFront, RightBack);

// spin motors
left_drive.spin(fwd, Controller.Axis3.Value() + Controller.Axis4.Value(), pct);
right_drive.spin(fwd, Controller.Axis3.Value() - Controller.Axis4.Value(), pct);

Drive Forward!

I think for the VEX Code API an axis it will return a value from -100 to 100. Let’s focus on moving forward for now. For example, if you wanted to go forward at full speed, you would move the Y-axis joystick fully forward, this would read a value of 100.

If we were to plug this into the calculation (known that the X axis is 0)

// get joystick values
int forward_joystick = Controller.Axis3.value() ; // 100
int turn_joystick = Controller.Axis4.value(); // 0 

// apply joystick values to motors.
left_drive.spin(fwd, forward_joystick + turn_joystick, pct);
right_drive.spin(fwd, forward_joystick - turn_joystick, pct)

From this snippet, we know that for the left half, the calculation will be left_joystick + right_joystick = 100 + 0 = 100. This means that the robots left half will move forward at 100%.

for the right half it’s the same but minus. So left_joystick - right_joystick = 100 - 0 = 100.
This means that the robots right half will move forward at 100%.

Turning :face_with_raised_eyebrow:

For turning we apply the same logic, but an important thing to remember is that one side will be positive and the other will be negative. This allows the robot to turn. Think of it when you’re driving using tank drive. You normally put one stick forward and the second stick backwards to turn. The same logic applies here.

If we were to plug this into the calculation where the, y axis (turning axis) is 100 and x axis (forward axis) is 0

// get joystick values
int forward_joystick = Controller.Axis3.value() ; // 0
int turn_joystick = Controller.Axis4.value(); // 100

// apply joystick values to motors.
left_drive.spin(fwd, forward_joystick + turn_joystick, pct);
right_drive.spin(fwd, forward_joystick - turn_joystick, pct)

For the left drive we know that forward_joystick + turn_joystick → 0 + 100 = +100 (this will spin the left side forward at 100%).
for the right drive we know that forward_joystick - turn_joystick → 0 - 100 = -100 (this will spin the right side in reverse at 100%).

You don’t need to do this because by default the motor will be set to coast, you should only do this if you set the motors brake type to something else e.g., Hold or Brake.

I’m not really qualified to answer from three an onwards tho :grin:

1 Like
  1. Use the sample code you found.

  2. Use the code you wrote, and put it in usercontrol.

  3. Doesn’t matter.

  4. Doesn’t matter.

  5. Yes.

  6. Doesn’t matter and doesn’t matter as long as the screw reaches.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.