Controlling the velocity of motors

My students are using this program for Castle and we can’t get the drive velocity to change. Any ideas?
Thanks

1 Like

Are you using the controller configuration in the robot config to drive the robot around? If so, you will be unable to adjust the drivetrain speeds using that.

The controller config will scale the drivetrain speed based on how far you move the joystick(s). the further you move them from center, the faster the drivetrain will move.

If you want to adjust the max speed of the drivetrain, you will need to manually program the robot, there are several examples like “Left Arcade Control” that will show you how to control the drivetrain from the code.

If your goal is to change the drivetrain scale to set a max speed, you will need to adjust the math and device the motor speed values so that instead of passing 100% you pass the desired value. For example, if you want to limit the drivetrain to 25%, you would divide by 4, so that 100%/4 = 25%.

Hopefully that makes sense and helps answer your question.

Hi Jacob, thanks for replying. Were you able to see the pic of the program I attached? Isn’t that what we did with the When Started block in the programming. I guess I’m not quite sure how else we could do it. We are doing the Defend the Castle Activity but we are trying to 1. slow the robot down 2. make the A button squeeze the ball, hold it, and lift it 3. make the B button lower the arm to a height above the ring, brake the motor, and open the claw. We have been able to get all of the arm and claw functions to work correctly but we can’t get the robot to simply slow down. I’m new at this, thanks!

The issue is that the generated code from the robot configuration keeps updating the motor velocities directly based on the joystick values. This means that the drivetrain velocity you are setting does not change the speed that is set by the controller code.

This is why I was pointing you to the examples that control the drivetrain motors directly instead of using the robot config code that can not be changed. This way you will be able to adjust the max speed of the drivetrain motors.

Since the motors are controlled for the blocks code directly in the examples, you have full control over what they do. This means that you can set the motors to be as fast or as slow as you want.

You can either recreate your code for controlling the arm and claw off the example, or recreate the drivetrain motor control from the example in your code. I would recommend adding your arm/claw logic to the example as it will be easier/faster to make those changes.

@Jacob_Palnick I believe this example project is what you were describing when you were talking about controlling the drivetrain motors directly, correct?
Screenshot 2023-12-04 at 5.51.11 PM

This is different because as you can see from this image, the motors are not assigned in the configuration for the controller.

This is the one we are using.

Hi @Ray_Johnson! Yes, I saw that mentioned above. What does the configuration look like from the Controller? Is it blank like this or does it have motors assigned to the buttons?

We can also schedule a 1-1 Session to talk through this if that would be more helpful :slight_smile:

It has buttons assigned to motors. Button A is the arm motor and button B is the claw motor.
Thanks!

Hi @Ray_Johnson! Is the Drivetrain also assigned to the Joysticks? Would you be able to send a screenshot of what it looks like from the configuration? :slight_smile: