|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Need help coding the jaguars
Last year I programmed our robot with the help of two mentors and another team member. Unfortunately this year the main programming mentor has moved away and the other mentor has been very busy the past week leaving me alone to handle the programming. It's only made harder by the fact that our computer with the code on it was stolen so I don't have any examples of how to write the code like we did last year.
Using the default example template I've managed to get most of the code properly written for our robot that currently only has a drive mechanism, however I can't get the jaguars attached to the cim motors to work properly. I have declared the jaguars but I'm not able to figure out how to add in the information for where each jag is connected. I've tried searching the provided guides and searching the internet but I've been unable to find anything that has worked. Whenever the robot is turned on the jags flash with a yellow light. Any help with the basic coding for the jaguars would be much appreciated! |
|
#2
|
|||
|
|||
|
Re: Need help coding the jaguars
go to the part in the code where all the other objects have their location stated. for example the stick controller should have whatever the name is then parentheses next to it with a number.
drivingcontroller(1) in that area you need to add your jaguars and in parentheses next to it type in the number that matches what port it is plugged into on your i/o board. jaguarthefirst(1) or whatever number you are using. |
|
#3
|
||||
|
||||
|
Re: Need help coding the jaguars
You need to find out how the Jaguars are connected to the cRIO. There are two ways. You are either connecting the Jaguars to the PWM channels or you are connecting them to a CAN bus by the RJ-12 cables. The way they are connected to the cRIO affects how they are programmed. If you are using CAN bus, you need to declare CANJaguar objects. If you are using PWM, then you declare Jaguar objects. What slot in the cRIO is your digital module plugged into? If your robot is 2-motor drive and you have an 8-slot cRIO with the digital module on slot 4 and connect them through PWM, then you need to declare the Jaguars like this:
Code:
class MyRobot: public SimpleRobot
{
RobotDrive drive;
MyRobot():
drive(PWM_CHANNEL_LEFTJAG, PWM_CHANNEL_RIGHTJAG)
{
// You may want to flip the booleans if the motors running the wrong way.
drive.SetInvertedMotor(kRearLeftMotor, true);
drive.SetInvertedMotor(kRearRightMotor, false);
...
...
}
}
Last edited by mikets : 14-01-2012 at 02:44. |
|
#4
|
||||
|
||||
|
Re: Need help coding the jaguars
Hmm we are having problems also programming our robot.
Code:
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotBase class.
* The SimpleRobot 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.
*/
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Joystick leftstick; // "leftstick" is a variable that points to the joystick object.
Jaguar *gripperMotor;
public:
RobotDemo(void):
myRobot(1, 2), // these must be initialized in the same order
leftstick(1)
// as they are declared above.
{
Joystick *rightstick;
myRobot.SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
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(void)
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl())
{
myRobot.ArcadeDrive(leftstick); // drive with arcade style (use right stick)
Wait(0.005);
}
}
};
START_ROBOT_CLASS(RobotDemo);
We have not been able to get Autonomous nor Operator control going. We are constantly bombarded with an error about the digital module not being found, and something at line 26 of PWM.cpp. When we try autonomous or teleoperated nothing occurs.The robot does not move or anything. Last edited by Team 3705 : 14-01-2012 at 12:11. |
|
#5
|
||||
|
||||
|
Re: Need help coding the jaguars
You need to put the module that the digital sidecar comes out of into the 2nd slot in the cRio - it's a change from 2011. If you're a veteran team, you probably skipped that step like the instructions told you to. Check out the "How to set up your robot control system" in the Getting Started with the 2012 FRC Control System_2.pdf.
|
|
#6
|
||||
|
||||
|
Re: Need help coding the jaguars
oh thanks~ I read that somewhere? So, after placing the module in the second slot of the cRIO, will the simple template program run?
|
|
#7
|
||||
|
||||
|
Re: Need help coding the jaguars
It should. You need the analog module in #1, digital module in #2, solenoid module in #3.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|