![]() |
How to grdually speed up the robot?
We are trying to make it so that when the joystick signals to seed up, there has to be several milliseconds delays in order to gradually increase the speed. Is there any simple way to do this? [ using simple robot template ]
Thanks |
Re: How to grdually speed up the robot?
Quote:
Code:
float output = 0.0; |
Re: How to grdually speed up the robot?
We use what's called a rolling average to accomplish this. You keep a list of the past X values and average them together to get the current value. Each iteration you add the new value at the end and drop the first value. The more numbers you store the slower the system will react to changes. We wrote a utility to do this, I can get one of our students to post the code for it if you'd like.
|
Re: How to grdually speed up the robot?
What problem are you trying to solve? Are you trying to prevent spinning your wheels on acceleration? Preventing stress on the drivetrain when reversing direction quickly? Or just generally going for more control and less 'twitchiness'?
Eddie12390 has the right idea, but you need to manage each situation of input. For instance what will happen if you are going full speed and get a joystick input of full forward (-1.0). If you exactly cut and paste that code without at least limiting it you will be out of range for the motor input. But his concept is sound for the problem as stated: take some percentage between where you are now and where you want to be and apply it. Just make sure you account for all situations. |
Re: How to grdually speed up the robot?
Quote:
Code:
change = joystick - limitedJoystick;limitedJoystick is the rate-limited joystick value you use to control your motors. Here's an article which might be of interest: http://thinktank.wpi.edu/article/140 |
Re: How to grdually speed up the robot?
Quote:
Thanks ::ouch:: |
Re: How to grdually speed up the robot?
Quote:
We typically output the values so they can be viewed in NetConsole, like this: System.out.println("X: " + joystick.getX() + ", Y: " + joystick.getY() + ", Rot: " + joystick.getTwist() ); However, we found out (we switched to java this year, it used to work in C++) that the getRotate() didn't work as we expected, so instead we use double rotate = joystick.getRawAxis(4); In fact, joystick.getTwist() for us was returning 0 until we moved it a bit, then it'd be stuck at 1. Not sure what's going on there.... |
Re: How to grdually speed up the robot?
Quote:
I filed artf1718 |
Re: How to grdually speed up the robot?
Quote:
|
Re: How to grdually speed up the robot?
Quote:
|
Re: How to grdually speed up the robot?
Another way to do this is:
Code:
motor_value = k*joystick_reading + (1-k)*motor_valueLarge k values make the motor very responsive, and a value of 1 means no filtering is actually happening. Small values make the output move slowly from the old value to the joystick value. This is an Infinite Impulse Response (IIR) low pass filter, whereas the moving average is a Finite Impulse Response (FIR) filter. Which of these to choose (or using a rate limiter like Ether suggested) depends on what exactly you are trying to accomplish. My experience with using any sort of filtering in the drive train (other than traction control in 2009) is that drivers usually hate it because if the effect is significant it feels "sluggish". |
Re: How to grdually speed up the robot?
Quote:
|
Re: How to grdually speed up the robot?
Quote:
|
Re: How to grdually speed up the robot?
Quote:
|
| All times are GMT -5. The time now is 10:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi