Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Compressor Code causes No Robot Code Error (http://www.chiefdelphi.com/forums/showthread.php?t=80970)

sircedric4 23-01-2010 16:43

Compressor Code causes No Robot Code Error
 
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:
Code:

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\n";
               
                // 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.

Any ideas? Help.

jhersh 23-01-2010 19:39

Re: Compressor Code causes No Robot Code Error
 
Are you getting any errors in the diagnostics tab of the driver station? Is your robot program crashing?

sircedric4 24-01-2010 10:33

Re: Compressor Code causes No Robot Code Error
 
I didn't realize we got error messages on the driver station. I will check that and get back to you.

sircedric4 25-01-2010 17:41

Re: Compressor Code causes No Robot Code Error
 
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.

jhersh 25-01-2010 17:50

Re: Compressor Code causes No Robot Code Error
 
Can you post a console log of the crash?

sircedric4 25-01-2010 18:40

Re: Compressor Code causes No Robot Code Error
 
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.

Code:

#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\n";
               
                // 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\n";
        }
       
       
        /********************************** 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?

sircedric4 25-01-2010 20:41

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by jhersh (Post 906721)
Can you post a console log of the crash?

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.

sircedric4 26-01-2010 18:17

Re: Compressor Code causes No Robot Code Error
 
1 Attachment(s)
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.

Alan Anderson 26-01-2010 21:05

Re: Compressor Code causes No Robot Code Error
 
See this thread and look for the information on using mlongcall.

jhersh 27-01-2010 00:44

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by sircedric4 (Post 907406)
Ok, you've got my code up above and we got NetConsole to work right off the bat today which was a pleasant surprise.

Well... I'm glad something is working for you! ;)

Quote:

Originally Posted by sircedric4 (Post 907406)
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.

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.

-Joe

jhersh 27-01-2010 00:49

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by sircedric4 (Post 906844)
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.

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.

-Joe

sircedric4 27-01-2010 06:59

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by jhersh (Post 907661)
Well... I'm glad something is working for you! ;)



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.

-Joe

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.

gvarndell 27-01-2010 08:10

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by sircedric4 (Post 907704)
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?

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.

sircedric4 27-01-2010 12:24

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by gvarndell (Post 907721)
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.

jhersh 27-01-2010 16:59

Re: Compressor Code causes No Robot Code Error
 
Quote:

Originally Posted by sircedric4 (Post 907704)
We built it off the IterativeRobot example.

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.

Quote:

Originally Posted by sircedric4 (Post 907704)
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 tried removing the build targets and creating a new one and it still had the -mlongcall setting there.

Quote:

Originally Posted by sircedric4 (Post 907704)
I swear I am starting to feel like a caveman looking at magic. Any sufficiently advance technology being indistinguishable 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.

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.

-Joe


All times are GMT -5. The time now is 13:34.

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