|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
|||
|
|||
|
Re: Twitchy Motors
Quote:
Before swapping out for Y-cables, have you tried removing 3 of the existing ones and seeing if the issue is still occurring? Only have one connected at a time and see if you can narrow down the specific cable/port/controller combination that triggers the condition? The video only shows one side of the drive train twitching so I'm not sure if the other side is doing it as well like ours was. |
|
#47
|
|||
|
|||
|
Re: Twitchy Motors
In addition to what Nate said:
This only occurs when the robot is enabled, correct? Another thing you could try, although I imagine it will have no effect, is try switching languages to C++ and see if the problem still occurs. Just use the default example code and see if it twitches. |
|
#48
|
|||
|
|||
|
Re: Twitchy Motors
Both sides twitch. I removed all but one PWM for each talon and each talon individually twitches.
I set it to autonomous and found it didn't twitch. I set each motor value to 0 and found it still didn't twitch. To make sure I coded it right, I set one side to a value of 1 and it moved constantly at full speed while the other side didn't move at all. It only twitches when enabled in TeloOp. |
|
#49
|
|||
|
|||
|
Re: Twitchy Motors
Huh. Well I switched C++ and slightly modified the code (someone should check if I entered the motor ports correctly) and the motors didn't twitch.
Code:
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
* don't. Unless you know what you are doing, complex code will be much more difficult under
* this system. Use IterativeRobot or Command-Based instead if you're new.
*/
class Robot: public SampleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick; // only joystick
SendableChooser *chooser;
const std::string autoNameDefault = "Default";
const std::string autoNameCustom = "My Auto";
public:
Robot() :
myRobot(4, 5, 6, 7), // these must be initialized in the same order
stick(0), // as they are declared above.
chooser()
{
//Note SmartDashboard is not initialized here, wait until RobotInit to make SmartDashboard calls
myRobot.SetExpiration(0.1);
}
void RobotInit()
{
chooser = new SendableChooser();
chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault);
chooser->AddObject(autoNameCustom, (void*)&autoNameCustom);
SmartDashboard::PutData("Auto Modes", chooser);
}
/**
* This autonomous (along with the chooser code above) shows how to select between different autonomous modes
* using the dashboard. The sendable chooser code works with the Java SmartDashboard. If you prefer the LabVIEW
* Dashboard, remove all of the chooser code and uncomment the GetString line to get the auto name from the text box
* below the Gyro
*
* You can add additional auto modes by adding additional comparisons to the if-else structure below with additional strings.
* If using the SendableChooser make sure to add them to the chooser code above as well.
*/
void Autonomous()
{
std::string autoSelected = *((std::string*)chooser->GetSelected());
//std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl;
if(autoSelected == autoNameCustom){
//Custom Auto goes here
std::cout << "Running custom Autonomous" << std::endl;
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-0.5, 1.0); // spin at half speed
Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
} else {
//Default Auto goes here
std::cout << "Running default Autonomous" << std::endl;
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-0.5, 0.0); // drive forwards half speed
Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
}
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl()
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled())
{
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
Wait(0.005); // wait for a motor update time
}
}
/**
* Runs during test mode
*/
void Test()
{
}
};
START_ROBOT_CLASS(Robot)
|
|
#50
|
|||
|
|||
|
Re: Twitchy Motors
That C++ code is correct, and if it didn't twitch then the problem seems to be with Java.
Do you have the latest updates and everything installed for Java/WPILib? |
|
#51
|
|||
|
|||
|
Re: Twitchy Motors
Quote:
Do you have any dead-band in your software so that the joysticks must move a significant amount before the system responds? I did not notice any mention of dead-band in this thread yet. In Auto-mode, dead-band is not an issue since the software should be ignoring your joysticks. Perhaps set your dead-band to some large value to see what effect it has. |
|
#52
|
|||
|
|||
|
Re: Twitchy Motors
I can't check the firmware version because the web dashboard is showing a white screen. (If I remember correctly, the version number is 3.0.0f0)
My eclipse plugins versions are now updated to 0.1.0.201602112135. When I image the roborio I use the FRC_roboRIO_2016_v19.zip image. The JRE is ARMv7 Linux - VFP, SOftFP ABI, Little Endian^2. Since I updated the eclipse plugins, I now have this message in the driver station: ERROR 1 PWM 7... Output not updated often enough. java.lang.Thread.run(Thread.java:745) ERROR 1 PWM 6... Output not updated often enough. java.lang.Thread.run(Thread.java:745) ERROR 1 PWM 5... Output not updated often enough. java.lang.Thread.run(Thread.java:745) ERROR 1 PWM 4... Output not updated often enough. java.lang.Thread.run(Thread.java:745) |
|
#53
|
|||
|
|||
|
Re: Twitchy Motors
I do not have any dead band. Earlier I tested it by setting the values to 0 and it still twitched, so i don't think it's the controllers.
![]() I unplugged the controller so it wouldn't receive any input. |
|
#54
|
|||
|
|||
|
Re: Twitchy Motors
You need some dead-band. It allows your system to ignore the noise that you will invariably have coming out of your joysticks. Do a search on this forum for how to properly implement the dead-band.
|
|
#55
|
|||
|
|||
|
Re: Twitchy Motors
I've implemented a deadband, but it still twitches.
Code:
public void operatorControl() {
LF.setSafetyEnabled(true);
LR.setSafetyEnabled(true);
RF.setSafetyEnabled(true);
RR.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
LF.set(-deadband(stickL.getRawAxis(1)));
LR.set(-deadband(stickL.getRawAxis(1)));
RF.set(deadband(stickR.getRawAxis(1)));
RR.set(deadband(stickR.getRawAxis(1)));
C.setClosedLoopControl(true);
if(controller.getRawButton(5)){
D.set(DoubleSolenoid.Value.kForward);
}
else if(controller.getRawButton(6)){
D.set(DoubleSolenoid.Value.kReverse);
}
Timer.delay(0.005); // wait for a motor update times
}
}
public double deadband(double JoystickValue) {
double deadbandreturn = 0;
if(Math.abs(JoystickValue)<.2){
return 0;
}
else {
deadbandreturn = JoystickValue;
}
return deadbandreturn;
|
|
#56
|
||||
|
||||
|
Re: Twitchy Motors
Have you tried switching out the joystick or game pad?
|
|
#57
|
|||
|
|||
|
Re: Twitchy Motors
Yes, I've swapped between an xbox controller and two Logitech Extreme 3D Pro joysticks. I don't think it's the controller because I've also tried running it without controllers and it still twitches.
|
|
#58
|
|||
|
|||
|
Re: Twitchy Motors
In your Java code, you are addressing each Talon individually, and it is causing the motors to Twitch.
In the C++ code, the motors are NOT twitching, when you are calling the ArcadeDrive method. Try addressing each talon in C++ and see if it twitches. Try this code and see if it twitches: Code:
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
* don't. Unless you know what you are doing, complex code will be much more difficult under
* this system. Use IterativeRobot or Command-Based instead if you're new.
*/
class Robot: public SampleRobot
{
Joystick stick; // left joystick
Joystick stick2; //right joystick
Talon left1;
Talon left2;
Talon right1;
Talon right2;
public:
Robot() :
stick(0),
stick2(1),
left1(4),
left2(5),
right1(6),
right2(7)
{
myRobot.SetExpiration(0.1);
}
void RobotInit()
{
}
void Autonomous()
{
left1.Set(0.0);
left2.Set(0.0);
right1.Set(0.0);
right2.Set(0.0);
}
void OperatorControl()
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled())
{
left1.Set(stick.GetY());
left2.Set(stick2.GetY());
right1.Set(-stick2.GetY());
right2.Set(-stick2.GetY());
Wait(0.005);
}
}
void Test()
{
}
};
START_ROBOT_CLASS(Robot)
|
|
#59
|
|||
|
|||
|
Re: Twitchy Motors
Neither time did it twitch.
I modified the code because you were using myrobot when it didn't exist. Code:
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
* don't. Unless you know what you are doing, complex code will be much more difficult under
* this system. Use IterativeRobot or Command-Based instead if you're new.
*/
class Robot: public SampleRobot
{
Joystick stick; // left joystick
Joystick stick2; //right joystick
Talon left1;
Talon left2;
Talon right1;
Talon right2;
public:
Robot() :
stick(0),
stick2(1),
left1(4),
left2(5),
right1(6),
right2(7)
{
left1.SetExpiration(0.1);
left2.SetExpiration(0.1);
right1.SetExpiration(0.1);
right2.SetExpiration(0.1);
}
void RobotInit()
{
}
void Autonomous()
{
left1.Set(0.0);
left2.Set(0.0);
right1.Set(0.0);
right2.Set(0.0);
}
void OperatorControl()
{
left1.SetSafetyEnabled(true);
left2.SetSafetyEnabled(true);
right1.SetSafetyEnabled(true);
right2.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled())
{
left1.Set(stick.GetY());
left2.Set(stick2.GetY());
right1.Set(-stick2.GetY());
right2.Set(-stick2.GetY());
Wait(0.005);
}
}
void Test()
{
}
};
START_ROBOT_CLASS(Robot)
|
|
#60
|
|||
|
|||
|
Re: Twitchy Motors
We found the solution. It was because we were missing motor.setExpiration(0.1)
Code:
public Robot() {
stickL = new Joystick(0);
stickR = new Joystick(1);
controller = new Joystick(2);
LF = new Talon(0);
RF = new Talon(3);
LR = new Talon(1);
RR = new Talon(4);
LF.setExpiration(0.1);
RF.setExpiration(0.1);
LR.setExpiration(0.1);
RR.setExpiration(0.1);
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|