![]() |
[C++] Use CAN Talons in RobotDrive
We are using CAN for the first time and after a few hours of learning how to do it, wiring, and formatting the Talons, our drive code didn't work. I tried controlling each motor individually and it works perfectly, but we would like to use RobotDrive because we are using Mecanum wheels with a gyro. Here is the non-working code:
Code:
class Robot: public SampleRobot {Code:
class Robot: public SampleRobot { |
Re: [C++] Use CAN Talons in RobotDrive
Have you tried connecting the TalonSRXs via the PWM? That may alleviate your problem. Could also check if your TalonSRXs have the latest firmware.
Check here: http://crosstheroadelectronics.com/T...7s%20Guide.pdf |
Re: [C++] Use CAN Talons in RobotDrive
Maybe grab the self test from the Rio web based configuration? Maybe its not in percent throttle mode. I don't have the implementation of robot drive in front of me but I think it just uses Set().
|
Re: [C++] Use CAN Talons in RobotDrive
What sort of problems are you encountering when you try to run the mecanum drive code? Does it simply not do anything at all, does it move the motors around but not in the way you expect, or something else? If the motors are running but the robot is responding how you expect, you should double check that everything is plugged into the right ports, that all the motors are turning the right direction, etc.
|
Re: [C++] Use CAN Talons in RobotDrive
Quote:
Quote:
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
try calling
robotDrive.SetSafetyEnabled(false); before the while loop in OperatorControl. Edit: actually, try calling that in the Robot() constructor. It's possible that the Talons are getting disabled before you start running the robot but that they aren't getting properly re-enabled. |
Re: [C++] Use CAN Talons in RobotDrive
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
If you are seeing kNoDrive then most likely set is not being called. See software reference manual for more details.
|
Re: [C++] Use CAN Talons in RobotDrive
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
Are you calling Wait(.01) in your code? That may cause the code to do nothing.
|
Re: [C++] Use CAN Talons in RobotDrive
Could also try creating a new project. Sometimes projects get messed up. On the surface, it may not seem like it matters, but it could be worth a try.
I reccomend you switch from using the SampleRobot project to using IterativeRobot and try the code again. |
Re: [C++] Use CAN Talons in RobotDrive
This should work, but as I don't have a bot with TalonSRXs, I can't confirm this, but you could try it. I have used the IterativeRobot class.
Code:
class Robot: public IterativeRobot |
Re: [C++] Use CAN Talons in RobotDrive
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
Quote:
Either way, you should add some sleep to your loop, otherwise you'll starve the rest of the threads on your system and you'll encounter problems. I'd recommend using iterative robot instead though, then you don't have to worry about things like that. |
Re: [C++] Use CAN Talons in RobotDrive
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
Please post your progress... we have the same exact need, and are hard coding our drive code currently... CAN has so many benefits, but so does using RobotDrive...
Thanks! |
Re: [C++] Use CAN Talons in RobotDrive
Quote:
|
Re: [C++] Use CAN Talons in RobotDrive
This might help, I ran this code on my mec bot, with gyro and CANTalons. I use IterativeRobot (it's just my preference).
http://www.chiefdelphi.com/forums/sh...3&postcount=20 |
Re: [C++] Use CAN Talons in RobotDrive
Quote:
Code:
leftFront->SetControlMode(CANSpeedController::kPercentVbus); |
Re: [C++] Use CAN Talons in RobotDrive
Ok I got it working! It's kind of an unusual workaround, but it works fine for us. Basically, create 4 fake motor controllers on unused PWM ports, and pass those to RobotDrive. From there, set the values of the real motor controllers to the values of the fake ones. Here is part of the code we used:
Code:
CANTalon *leftFront = new CANTalon(1); //Real ones |
Re: [C++] Use CAN Talons in RobotDrive
The problem looks like it's motor safety tripping. I reproduced the symptom with a similar project. Either the robot hits the motor safety trip once it boots up, or it fires during disable-to-enable transitions. When this happens the driver station will throw the MotorSafetyHelper assert (Section 16.14 in Talon SRX software reference manual), and the self-test will report "No-drive ".
I bet if you just called m_robotDrive->SetLeftRightMotorOutputs(0,0) in the disabled loop, that will keep feeding the motor safety object often enough to prevent your problem. Or alternatively just TURN OFF the feature with... m_robotDrive->SetSafetyEnabled(false) Using dummy PWM objects seems like a drastic workaround. Here's what I tested. If you comment out DisabledPeriodic(), you can reproduce the problem. Code:
#include "WPILib.h" |
Re: [C++] Use CAN Talons in RobotDrive
I tried turning the safeties off already and it didn't work, but I'll try the disabled loop tomorrow and get back. I agree that dummy PWMs is a bad solution, but we're going all CAN this year so it shouldn't really affect anything, and we will probably revert to it if your solution doesn't work because we've spent too long trying to get this to work. Thanks for the help though!
|
Re: [C++] Use CAN Talons in RobotDrive
Quote:
Anyway if you are still seeing the EXACT symptom of "...Motor Safety Timeout..." errors in the DS then you need to remedy it. Even with the PWM workaround (eek) you're still generating errors in your DS log. That's going to prevent your drive team from seeing other reported errors (because they will get used to seeing errors in that area of the DS". m_robotDrive->SetSafetyEnabled(false); will absolutely prevent MS errors. If you are still seeing them then something is very wrong, and it will likely be a problem throughout the season. |
Re: [C++] Use CAN Talons in RobotDrive
Definitely turn off the motor safety on the RobotDrive object, not the individual motor controllers and see if that fixes the problem. In the library, RobotDrive is the only place where the motor safety stuff is enabled by default, and as Omar said, it is part of the RobotDrive class as a whole. The thought was that it would stopping the runaway program from driving on it's own was the highest priority.
Use something like: drive.SetSafetyEnabled(false); Please let us know if does it for you. |
| All times are GMT -5. The time now is 21:12. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi