Go to Post FIRST is our Hunger Games. May the odds be ever in your favor. - GeorgeM [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-01-2015, 20:57
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
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.
  #2   Spotlight this post!  
Unread 31-01-2015, 21:12
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by ozrien View Post
If you are seeing kNoDrive then most likely set is not being called. See software reference manual for more details.
Can I just call Set() once at the beginning of teleop or is there something I have to change in RobotDrive? Unfortunately, I can't test until Monday.
  #3   Spotlight this post!  
Unread 31-01-2015, 22:48
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: [C++] Use CAN Talons in RobotDrive

Are you calling Wait(.01) in your code? That may cause the code to do nothing.
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
  #4   Spotlight this post!  
Unread 01-02-2015, 00:09
viggy96 viggy96 is offline
Registered User
FRC #3331
Team Role: College Student
 
Join Date: Jan 2015
Rookie Year: 2010
Location: Charlotte
Posts: 54
viggy96 is infamous around these partsviggy96 is infamous around these parts
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.

Last edited by viggy96 : 01-02-2015 at 00:17.
  #5   Spotlight this post!  
Unread 01-02-2015, 00:45
viggy96 viggy96 is offline
Registered User
FRC #3331
Team Role: College Student
 
Join Date: Jan 2015
Rookie Year: 2010
Location: Charlotte
Posts: 54
viggy96 is infamous around these partsviggy96 is infamous around these parts
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
{
private:
	LiveWindow *lw;

	CANTalon leftFront = new CANTalon(1);
	CANTalon leftBack = new CANTalon(5);
	CANTalon rightFront = new CANTalon(2);
	CANTalon rightBack = new CANTalon(6);

	RobotDrive drive = new RobotDrive(leftFront, leftBack, rightFront, rightBack);

	Joystick stick = new Joystick(1);

	Gyro gyro = new gyro(0);

	void RobotInit()
	{
		lw = LiveWindow::GetInstance();
	}

	void AutonomousInit()
	{

	}

	void AutonomousPeriodic()
	{

	}

	void TeleopInit()
	{

	}

	void TeleopPeriodic()
	{
		drive.MecanumDrive_Cartesian(stick.getX(), stick.getY(), stick.getThrottle(), gyro.getAngle());
	}

	void TestPeriodic()
	{
		lw->Run();
	}
};
  #6   Spotlight this post!  
Unread 01-02-2015, 16:29
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by viggy96 View Post
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.
How would this be different than the code I started with? Iterative basically just adds a function to be called at the beginning, but doesn't really change what is actually going on in the program.
  #7   Spotlight this post!  
Unread 02-02-2015, 01:19
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by 1452-Leo View Post
How would this be different than the code I started with? Iterative basically just adds a function to be called at the beginning, but doesn't really change what is actually going on in the program.
Iterative waits for each driver station packet for each iteration, whereas your original code runs in a tight loop without waiting for input. If you added a 20ms sleep in your loop, it would be vaguely equivalent to the iterative version.

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.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #8   Spotlight this post!  
Unread 03-02-2015, 10:14
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by virtuald View Post
Iterative waits for each driver station packet for each iteration, whereas your original code runs in a tight loop without waiting for input. If you added a 20ms sleep in your loop, it would be vaguely equivalent to the iterative version.

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.
Thanks, I didn't realize there was an actual difference in the how the program ran for iterative, so we will probably switch over to it today.
  #9   Spotlight this post!  
Unread 05-02-2015, 10:09
kmateti kmateti is offline
Registered User
FRC #3494
 
Join Date: May 2014
Location: United States
Posts: 2
kmateti is an unknown quantity at this point
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!
  #10   Spotlight this post!  
Unread 05-02-2015, 10:15
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by kmateti View Post
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!
We haven't had any time to test really, so we have just hardcoded the Mecanum drive with no gyro. I hope that we can get RobotDrive sorted out later today, but I'm not too sure. Of course I'll post the solution here though if we find it!
  #11   Spotlight this post!  
Unread 05-02-2015, 11:43
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
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
  #12   Spotlight this post!  
Unread 05-02-2015, 12:08
1452-Leo 1452-Leo is offline
Registered User
FRC #1452 (Omnicats)
Team Role: Alumni
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Los Angeles
Posts: 44
1452-Leo is an unknown quantity at this point
Re: [C++] Use CAN Talons in RobotDrive

Quote:
Originally Posted by ozrien View Post
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
Thanks! I'll have to try this later. I did just get RobotDrive working by putting this before the drive function:
Code:
leftFront->SetControlMode(CANSpeedController::kPercentVbus);
leftBack->SetControlMode(CANSpeedController::kPercentVbus);
rightFront->SetControlMode(CANSpeedController::kPercentVbus);
rightBack->SetControlMode(CANSpeedController::kPercentVbus);
There are problems with this solution though. For example, I can't reverse the motors anymore (it doesn't drive as soon as I add SetInvertedMotor in). I have another idea though that I will try later.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:48.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi