I’ve just tried to add the Compressor class code to my C++ Iterative Robot code and when I load it to the robot it causes a no robot code error. Has anyone else run into this problem and do you have a solution on how you fixed it.
The code I used was:
public:
/**
* Constructor for this "IterativeRobotDemo" Class.
* Create an instance of a RobotDrive with left and right motors plugged into PWM
* ports 0 and 1 on the first digital module.
*/
IterativeDemo(void) {
cout << "IterativeDemo Constructor Started
";
// Create a robot using standard right/left robot drive on PWMS 1, 2, 3, and #4
myRobot = new RobotDrive(1, 3, 2, 4);
// Define joysticks being used at USB port #1 and USB port #2 on the Drivers Station
rightStick = new Joystick(2);
leftStick = new Joystick(1);
// Acquire the Driver Station object
ds = DriverStation::GetInstance();
dsLCD = DriverStationLCD::GetInstance();
// Counters to record the number of loops completed in autonomous and teleop modes
auto_periodic_loops = 0;
disabled_periodic_loops = 0;
tele_periodic_loops = 0;
//Compressor Instance
Compressor *cpressor = new Compressor(1,1); //Input DIO Port 1, Relay 1
cpressor->Start(); //Start compressor
I have the compressor Spike wired to Relay 1 and the Pressure Switch wired to Digital Input 1. Would I get a no robot code error if something wasn’t physically connected right? The example in the User Guide said to put it in the constructor of the robot and that’s the only place I need it, which I have done.
The robot works fine without the compressor code, its just when I uncomments the line above.
All right, I do get an error message on the computer. Here is what it says:
No change to network configuration “Local Network Connection”
I/O Unit not detected or not installed correctly
I thought this might have meant that I had a wire crossed or a bad PWM cable, but I have completely replaced the PWM cable and checked it to make sure it didn’t have a short. The robot works perfectly fine if I don’t call the Compressor code.
I am running the switch to the white and black cables in the PWM bundle just like last year. I am installing it in the digitial input on my digital sidecar, in address 1.
For the Spike I am running it to Relay 1 on the digital sidecar.
I believe I got it all wired right, but yet I still get the No Robot Code error and it appears it is “crashing”.
Help please, I don’t have the slightest clue what’s going on here.
So I have put Compressor on the back burner while we wire up and work with the encoders and now I get the same exact thing with them as I was getting with the Compressor. I am posting my code, can someone help me figure out what I am doing wrong. I imagine its to do with code or not activating something properly, but I am willing to try other things if you got ideas.
#include <iostream.h>
#include "WPILib.h"
#include <taskLib.h>
#include "DashboardDataFormat.h"
/**
* This is a demo program showing the use of the IterativeRobot base class.
*
* The IterativeRobot class is the base of a robot application that uses similar control
* flow to that used in the FRC default code in prior years.
*
* This robot provides identically the same external behavior as the SimpleRobot demo program.
*
* This code assumes the following connections:
* Driver Station:
* Joystick 1 - The "right" joystick. Used for either "arcade drive" or "right" stick for tank drive
* Joystick 2 - The "left" joystick. Used as the "left" stick for tank drive
*/
class IterativeDemo : public IterativeRobot
{
// Declare variable for the robot drive system
RobotDrive *myRobot; // robot will use PWM 1-4 for drive motors
// Declare a variable to use to access the driver station object
DriverStation *ds; // driver station object
DriverStationLCD *dsLCD; //driver station LCD update
// Declare variables for up to three joysticks being used
Joystick *rightStick; // joystick 1 (arcade stick or right tank stick)
Joystick *leftStick; // joystick 2 (tank left stick)
//Encoder setup
Encoder *leftencoder;
Encoder *rightencoder;
//Compressor
//Compressor *cpress;
// Local variables to count the number of periodic loops performed
int auto_periodic_loops;
int disabled_periodic_loops;
int tele_periodic_loops;
int dash_periodic_loops;
public:
/**
* Constructor for this "IterativeRobotDemo" Class.
* Create an instance of a RobotDrive with left and right motors plugged into PWM
* ports 0 and 1 on the first digital module.
*/
IterativeDemo(void) {
cout << "IterativeDemo Constructor Started
";
// Create a robot using standard right/left robot drive on PWMS 1, 2, 3, and #4
myRobot = new RobotDrive(1, 3, 2, 4);
// Define joysticks being used at USB port #1 and USB port #2 on the Drivers Station
rightStick = new Joystick(2);
leftStick = new Joystick(1);
// Acquire the Driver Station object
ds = DriverStation::GetInstance();
dsLCD = DriverStationLCD::GetInstance();
// Counters to record the number of loops completed in autonomous and teleop modes
auto_periodic_loops = 0;
disabled_periodic_loops = 0;
tele_periodic_loops = 0;
//Compressor Instance
//cpress = new Compressor(3,1); //Input DIO Port 1, Relay 1
//cpress->Start(); //Start compressor
//Encoder Instances
leftencoder = new Encoder(9,10,true,Encoder::k4X);
rightencoder = new Encoder(11,12,true,Encoder::k4X);
cout << "RobotDemo Constructor Completed
";
}
/********************************** Init Routines *************************************/
void DisabledInit(void) {
disabled_periodic_loops = 0; // Reset the loop counter for disabled mode
}
void AutonomousInit(void) {
auto_periodic_loops = 0; // Reset the loop counter for autonomous mode
}
void TeleopInit(void) {
tele_periodic_loops = 0; // Reset the loop counter for teleop mode
dash_periodic_loops = 0;
}
/********************************** Periodic Routines *************************************/
void DisabledPeriodic(void) {
// feed the user watchdog at every period when disabled
GetWatchdog().Feed();
// increment the number of disabled periodic loops completed
disabled_periodic_loops++;
}
void AutonomousPeriodic(void) {
// feed the user watchdog at every period when in autonomous
GetWatchdog().Feed();
auto_periodic_loops++;
if (auto_periodic_loops == 1) {
// When on the first periodic loop in autonomous mode, start driving forwards at half speed
myRobot->Drive(0.5, 0.0); // drive forwards at half speed
}
if (auto_periodic_loops == 200) {
// After 200 loops (2 seconds given 10ms loops), stop the robot
myRobot->Drive(0.0, 0.0); // stop robot
}
}
void TeleopPeriodic(void) {
// feed the user watchdog at every period when in autonomous
GetWatchdog().Feed();
// increment the number of teleop periodic loops completed
tele_periodic_loops++;
dash_periodic_loops++;
// determine if tank or arcade mode; default with no jumper is for tank drive
myRobot->TankDrive(leftStick, rightStick); // drive with tank style
//Dashboard update
if (dash_periodic_loops >= 20) {
sendIOPortData();
dsLCD->Printf(DriverStationLCD::kMain_Line6,1,"Code 6:");
dsLCD->Printf(DriverStationLCD::kUser_Line2,1,"Left encoder: %d",leftencoder->Get());
dsLCD->Printf(DriverStationLCD::kUser_Line3,1,"Right encoder: %d",rightencoder->Get());
dsLCD->UpdateLCD();
dash_periodic_loops = 0;
}
}
/********************************** Continuous Routines *************************************/
/*
* These routines are not used in the imitation of the SimpleDemo robot
*
*
void DisabledContinuous(void) {
}
void AutonomousContinuous(void) {
}
void TeleopContinuous(void) {
}
*/
};
START_ROBOT_CLASS(IterativeDemo);
I can’t see anything wrong with the code, but I don’t know what else to do. If I comment out the encoder code and the compressor code it works fine. Anyone know what’s going on? Am I doing pointers or something wrong?
I will look up how to do this and see if I can’t get a console log tomorrow evening. Does someone have a cliff notes version of how to get that console log?
I did some searching this morning and found the NetConsole thing which I will try first, but since everything I try this year has been an abject failure from the beginning I also want to have the serial cable console procedure on hand as a backup. The problem is that I can’t find directions for it. I’ve searched Chief Delphi and found some stuff about last years documents with instructions, but that link to last year’s control system documentation has been convienently broken by FIRST.
I do know I need a null-modem adapter which I will pick up on the way to the school and to use HyperTerminal but I don’t know much more about how to setup the program to chat with the cRio. I looked in all the documents for this year with no luck. Could someone point me to the Hyperterminal instructions for the cRIO and also let me know if you’ve had any trouble with NetConsole I should be aware of.
I really want to solve this problem soon, so I want to have every tool at my disposal tonight when I try to get this error message from the console so I can get some help.
Ok, you’ve got my code up above and we got NetConsole to work right off the bat today which was a pleasant surprise. We did have an interesting glitch today. When we turned on the robot we got the same No Robot Code as usual with the new code, but after the computer went to standby and we tried it a little later it started to run. It did not give me encoder data, but it got past the crash. We tried it a little later and it was back to No Code. I don’t like intermittent stuff.
Here’s the error stuff from our console: I couldn’t find a way to actually cut and paste the actual text so had to take screenshots. It is in the attachment.
Hopefully this is enough info to help us, we are spinning our wheels here.
To copy text from NetConsole client, just select it. When you let go of the left mouse button, it is copied to the clip board. To paste, just click the middle mouse button in the window. You can also resize the window to make it show more text or even maximize it.
And like Alan said… you need to build with the mlongcall option. Any project you create from the examples should already have this option set for you. Did you create a new project from scratch or based on an example? If an example, which one… I’d like to fix the example if one is not configured to use mlongcall.
You need to configure HyperTerminal (I prefer PuTTY for serial terminal) for 9600 baud, 8bit, no parity, 1 stop bit, no flow control. You need to flip the CONSOLE OUT dip switch on the cRIO to ON (push down away from the outside edge) and reboot the cRIO. Connect with a null modem cable, and you should be up and running with serial console. Remember that you need to disable NetConsole (remove it from the ni-rt.ini startup) if you want the global stdio to show up on the serial port.
We built it off the IterativeRobot example. But when I was copying that and pasting it and changing the name to our version control it wasn’t taking information from the new directory so I was deleting the old build targets and creating new build targets. Could that have removed the magic “mlongcall” thing?
I swear I am starting to feel like a caveman looking at magic. Any sufficiently advance technology being indistiguishable from magic. I feel like I am learning a specific chant to get specific outcomes. I’m glad we got wizards here that I can at least get answers on which magic chant to do for any given outcome. Thanks guys. I’ll setup the project like outlined above and let you know if that solves our problems.
Could be, but I doubt it.
I’m pretty sure I created that same sample project and, with no tinkering or mucking around, there was no -mlongcall in the compiler switches.
Easy enough to create a new one, you can create as many projects as you want from the samples, and have a look.
Why did you create new build targets? Just curious.
Everything started fine. We would create the initial template and then before we added code to it, I would copy the project and repaste it to the explorer and rename it and would create me a new folder to change the code in. This was working great up to Code 5, when we then copied it to move on to Code 6, whenever it would do the linking for the newly compiled 6 code, it kept pulling the data from the old 5 code and the code on the robot wasn’t changing right.
So now we copy the project, and then remove the build target and build a new target and the code always links and runs correctly. I guess I could just move the appropriate .cpp files over to a new created template project each time but the procedure I highlighted seemed easier. I wasn’t sure that it might not be causing the mlongcall problem which is why I mentioned it.
Hopefully we’ll be up and running again tonight when I get the mlongcall in.
Just to be clear, you are referring to the “FRC Default Program” (as listed in the examples) aka “BuiltinDefaultCode” (as listed in the Project Explorer)? I double checked this project and it definitely includes the -mlongcall option.
I tried removing the build targets and creating a new one and it still had the -mlongcall setting there.
I know it seems like witchcraft, but it really is just an option for the PowerPC platform that can save space if your code is not huge. WPILib is huge… well… huge enough to need longcalls. We anticipated this issue and made it use the whole memory space by default. Really what we need to track down is how you lost that option in your project.
Can you speculate what update we might be missing that would cause us not to have it?
I actually did a dump of the relocation data from the elf file after building it and there were a bunch of RELOC_24 in it.
After I added -mlongcall and rebuilt, they were gone – replaced by pairs of RELOC_16 as you would expect.
The only thing I’m not 100% certain is what sample project I used.
I’ll have to check my ‘robotics’ computer when I get a chance and see which sample it was.
The example I used was Iterative Robot Demo Main Program. We just performed the magic -mlongcall chant and did the appropriate ritual and the robot now functions as expected.
We are trying to figure out why our encoders themselves don’t give us data, but we’re just starting that. We are checking our wiring first again, and checking the forums, and then checking the code that’s already posted above. The good news is that the Compressor code performed flawlessly after we got the Reallocation error gone.
Thanks, and any suggestions on encoders would be appreciated though I may start a new post for that after we give it a good effort tonight.
Really the only thing I can think of off hand would be if either one of the projects doesn’t have that option set by default and that’s that you started with… or that you created the project from scratch. That option should have been set in all examples since last year.
I don’t even see that one. Perhaps that’s the problem. If there are really old examples left laying around since last year, it’s possible the example had a bug in the project from back then.
This is the list of projects that I see in source control today:
Anything you have in addition to these is probably very obsolete.
If I had a recommendation, it would be to remove all of the projects in the C:\WindRiver\workspace\WorkbenchUpdate\vxworks-6.3 arget\src\demo directory and then install the C++ update.
Glad it worked for you. As for encoders… first things first make sure that, as the wheel spins, both lines change by adding a Get() on each of the two DigitalInput objects. Then pass those DigitalImput objects into the Encoder constructor.
It turns out its extremely helpful if you actually tell the encoders to Start() in your code. Like I said we hadn’t gone through the code yet and seen what our errors might be. Once we dug into the encoder header it became pretty obvious what to do. They give us numbers now when we call the Get() method. In the WPI User’s manual they don’t mention anything beyond setting them up. I guess they leave the using them up to the user. Not sure what we’ll do with them yet but having the number there to deal with was the important bit right now.
As for the code, I moved my entire last years Windriver directory over to a new directory named Windriver 2009 when I installed the new Windriver for this year. I wouldn’t have expected it to add sample projects across directories like that. I know my project is up to date, but I will check it out tomorrow. I had a problem with my updater not installing correctly and had to move the files from it by hand after extracting the data manually, is it possible that a correctly running updater deletes projects that are installed by Windriver by default and since all I did was add due to installer error that it left the IterativeRobot Demo I was using?
I would like to thank everyone for all their help. Tonight was a good night, one that we needed as we were getting quite distressed.