Go to Post Practice field Practice bot Iteration = awesome sauce - Akash Rastogi [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 25-01-2014, 20:12
Jceggbert5 Jceggbert5 is offline
Registered User
FRC #1825
 
Join Date: Feb 2013
Location: Terran
Posts: 5
Jceggbert5 is an unknown quantity at this point
Initialization issues with Talons.

This is our first year using C++. We've used LabView for the last several years, but our programming team finally made the switch for this season.

We're having an extremely weird issue with our code. We are using a mecanum drive system, and have not had issues until we attempted to add a fifth controller for our manipulator. We are using the RobotDrive class to initialize our first four controllers (using myRobot(1, 2, 3, 4) for init).

I attempted to add a fifth controller using this:
Code:
Talon shooter;

shooter = new Talon(6);
Once I deploy the code and reboot, every time I enable the robot (in either Teleop or in Autonomous), all the motors spin in reverse for about a quarter of a second and then disable.

For sake of troubleshooting, I tried removing all drive code and then reinitialize all the controllers manually as Talons. Once I did this, I cannot get the motors to spin at all. When I click Enable, the controllers enable for a split second and then disable. During that split second, I cannot give any value to the controllers, either directly in the code or by joystick input.

Anyone have any ideas?

Here's my full code:

Code:
#include "WPILib.h"
#include <math.h>

/**
 * This is a demo program showing the use of the RobotBase class.
 * The IterativeRobot class is the base of a robot application that will automatically call your
 * Periodic methods for each packet based on the mode.
 */ 
class RobotDemo : public IterativeRobot
{
	double joyX, joyY, joyZ;
	//RobotDrive myRobot; // robot drive system
	Jaguar  LF, LR, RF, RR, talonFive, shooter;
	Joystick stick; // only joystick
	Gyro fieldOrientation;

public:
	RobotDemo():
		//myRobot(1, 2, 3, 4),	// these must be initialized in the same order
		LF(1),
		LR(2),
		RF(3),
		RR(4),
		talonFive(5),
		shooter(6),
		stick(1),		// as they are declared above.
		fieldOrientation(1)
	{
		//myRobot.SetExpiration(0.1);
		//shooter.SetSafetyEnabled(false);
		//shooter.SetExpiration(0.1);
		this->SetPeriod(0); 	//Set update period to sync with robot control packets (20ms nominal)
	}
	
/**
 * Robot-wide initialization code should go here.
 * 
 * Use this method for default Robot-wide initialization which will
 * be called when the robot is first powered on.  It will be called exactly 1 time.
 */
void RobotDemo::RobotInit() {
}

/**
 * Initialization code for disabled mode should go here.
 * 
 * Use this method for initialization code which will be called each time
 * the robot enters disabled mode. 
 */
void RobotDemo::DisabledInit() {
}

/**
 * Periodic code for disabled mode should go here.
 * 
 * Use this method for code which will be called periodically at a regular
 * rate while the robot is in disabled mode.
 */
void RobotDemo::DisabledPeriodic() {
}

/**
 * Initialization code for autonomous mode should go here.
 * 
 * Use this method for initialization code which will be called each time
 * the robot enters autonomous mode.
 */
void RobotDemo::AutonomousInit() {
}

/**
 * Periodic code for autonomous mode should go here.
 *
 * Use this method for code which will be called periodically at a regular
 * rate while the robot is in autonomous mode.
 */
void RobotDemo::AutonomousPeriodic() {
}

/**
 * Initialization code for teleop mode should go here.
 * 
 * Use this method for initialization code which will be called each time
 * the robot enters teleop mode.
 */
void RobotDemo::TeleopInit() {
	fieldOrientation.Reset();
}

/**
 * Periodic code for teleop mode should go here.
 *
 * Use this method for code which will be called periodically at a regular
 * rate while the robot is in teleop mode.
 */
void RobotDemo::TeleopPeriodic() {
	//myRobot.ArcadeDr1ive(stick); // drive with arcade style
	joyX = pow(stick.GetX(), 3);
	joyY = pow(stick.GetY(), 3);
	joyZ = pow(stick.GetRawAxis(3), 3);
	//myRobot.MecanumDrive_Cartesian(-joyX, -joyY, joyZ, fieldOrientation.GetAngle());
	
	//shooter.SetLeftRightMotorOutputs(pow(stick.GetRawAxis(4), 3), pow(stick.GetRawAxis(5), 3));
	LF.SetSpeed(pow(stick.GetRawAxis(5), 3));
	LR.SetSpeed(pow(stick.GetRawAxis(5), 3));
	RF.SetSpeed(pow(stick.GetRawAxis(5), 3));
	RR.SetSpeed(pow(stick.GetRawAxis(5), 3));
	talonFive.SetSpeed(pow(stick.GetRawAxis(5), 3));
	shooter.SetSpeed(pow(stick.GetRawAxis(5), 3));
}

/**
 * Initialization code for test mode should go here.
 * 
 * Use this method for initialization code which will be called each time
 * the robot enters test mode.
 */
void RobotDemo::TestInit() {
}

/**
 * Periodic code for test mode should go here.
 *
 * Use this method for code which will be called periodically at a regular
 * rate while the robot is in test mode.
 */
void RobotDemo::TestPeriodic() {
}

};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote
 


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 12:49.

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