View unanswered posts | View active topics It is currently Sat Oct 25, 2014 8:01 pm






Reply to topic  [ 10 posts ] 
CMUcam Sample Code in RobotC 1.52 
Author Message
Rookie

Joined: Tue Mar 10, 2009 2:43 pm
Posts: 21
Location: Houston, TX
Post CMUcam Sample Code in RobotC 1.52
I open up the sample program without any modifications ,
Code:
CMUCAM_Simple_Test.c


And i get the following compliation errors.

Code:
**Error**:Undefined variable 'TTrackingDataInts'. 'short' assumed.
**Error**:Expected->';'. Found 'myData'
**Error**:Undefined variable 'myData'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:Undefined variable 'camStatusTracking'. 'short' assumed.
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:'myData' is not a 'struct' variable
**Info***:'horizontal' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'vertical' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'nFrameRate' is written but has no read references


I am doing something wrong ?


Fri Jun 26, 2009 4:24 pm
Profile WWW
Rookie
User avatar

Joined: Fri Jun 12, 2009 6:38 pm
Posts: 25
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Post Re: CMUcam Sample Code in ROBOTC 1.52
lyncas wrote:
I open up the sample program without any modifications ,
Code:
CMUCAM_Simple_Test.c


And i get the following compliation errors.

Code:
**Error**:Undefined variable 'TTrackingDataInts'. 'short' assumed.
**Error**:Expected->';'. Found 'myData'
**Error**:Undefined variable 'myData'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:Undefined variable 'camStatusTracking'. 'short' assumed.
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:'myData' is not a 'struct' variable
**Info***:'horizontal' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'vertical' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'nFrameRate' is written but has no read references


I am doing something wrong ?



I get the same thing...

It apears to be all related to the missing Structure "TTrackingDataInts myData;".

I am looking into it...

_________________
MarkO

FRC Team 957 "2007-2009 Professional Mentor"

http://vex.markdoverholser.com/notice.html

http://vex.markdoverholser.com/
http://tech.markdoverholser.com/


Sat Jun 27, 2009 7:45 pm
Profile WWW
Rookie
User avatar

Joined: Fri Jun 12, 2009 6:38 pm
Posts: 25
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Post Re: CMUcam Sample Code in ROBOTC 1.52
lyncas wrote:
I open up the sample program without any modifications ,
Code:
CMUCAM_Simple_Test.c


And i get the following compliation errors.

Code:
**Error**:Undefined variable 'TTrackingDataInts'. 'short' assumed.
**Error**:Expected->';'. Found 'myData'
**Error**:Undefined variable 'myData'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:Undefined variable 'camStatusTracking'. 'short' assumed.
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:'myData' is not a 'struct' variable
**Info***:'horizontal' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'vertical' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'nFrameRate' is written but has no read references


I am doing something wrong ?





OK, so somebody needs to Recompile the "RobotCIFI.exe" or wherever the Pre-Compiled Header Files are located, so that this will Compile.. Also, the RobotC Header Files ALL need to be Re-Written for "Conditional Inclusion" (See K_n_R, s4.11.3), with the format:

Code:
For example, to make sure that the contents of a file hdr.h are included only once, the contents of the file are surrounded with a conditional like this:

   #if !defined(HDR)
   #define HDR

   /* contents of hdr.h go here */

   #endif

The first inclusion of hdr.h defines the name HDR; subsequent inclusions will find the name defined and skip down to the #endif. A similar style can be used to avoid including files multiple times. If this style is used consistently, then each header can itself include any other headers on which it depends, without the user of the header having to deal with the interdependence.

This sequence tests the name SYSTEM to decide which version of a header to include:

   #if SYSTEM == SYSV
       #define HDR "sysv.h"
   #elif SYSTEM == BSD
       #define HDR "bsd.h"
   #elif SYSTEM == MSDOS
       #define HDR "msdos.h"
   #else
       #define HDR "default.h"
   #endif
   #include HDR

The #ifdef and #ifndef lines are specialized forms that test whether a name is defined. The first example of #if above could have been written

   #ifndef HDR
   #define HDR

   /* contents of hdr.h go here */

   #endif




The Errors as presented by lyncas, seem to revolve around the Structure "TTrackingDataInts" and its Declaration "myData". Of course, there are other Errors, once these are "cleaned up".


So, the Source Code, "CMUCAM_Simple_Test.c" #includes"cameraConfiguration.h".

"cameraConfiguration.h" #includes"TCamera.h".

"TCamera.h" #includes"cameraIntrinsics.h", IF there is a DEFINE for "ROBOTC", Which seems reasonable.

"cameraIntrinsics.h" #includes"TCameraResults.h", IF there is a DEFINE for "hasCamera", which there is not, but adding the DEFINE to the Source Code "CMUCAM_Simple_Test.c" causes other Errors to appear..

Adding the DEFINE "hasCamera":

Code:

//
// Load the "configuration program" generated camera  settings
//
#define hasCamera
#include "cameraConfiguration.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////



Now shows these Errors:
Code:
**Error**:Undefined variable 'sysFuncCameraFunctions'. 'short' assumed.
**Error**:Undefined variable 'sysFuncSetCameraConfig'. 'short' assumed.
**Error**:Undefined variable 'sysFuncGetCameraConfig'. 'short' assumed.
**Error**:Undefined variable 'sysFuncGetTrackingParms'. 'short' assumed.
**Error**:Undefined variable 'kExternCMUCAMTracking'. 'short' assumed.
**Severe*:Constant Expression Expected
**Error**:Unexpected scanner token-> ')'
**Error**:Undefined variable 'kSystemStreamCameraIOToPC'. 'short' assumed.
**Severe*:Constant Expression Expected
**Error**:Unexpected scanner token-> ')'
**Info***:'horizontal' is written but has no read references
**Info***:'vertical' is written but has no read references
**Info***:'nFrameRate' is written but has no read references


These "Undefined variable(s)" are defined in "cameraIntrinsics.h", which ARE REQUIRED to create the Definitions for "intrinsic functions", "StartCamera()", "StopCamera()", "ResetCameraConfigurationToDefault()", "SetCameraConfig(...)", "GetCameraConfig(...)", "GetTrackingParms(...)", "bool variableIndex(...)".

"cameraIntrinsics.h" also contains the Definition for the "intrinsic function" "TTrackingDataInts".


The "Undefined variable(s)", 'sysFuncCameraFunctions', 'sysFuncSetCameraConfig', 'sysFuncGetCameraConfig', 'sysFuncGetTrackingParms', 'kExternCMUCAMTracking', 'kSystemStreamCameraIOToPC' apperar to be RobotC, Opperation Codes (Op Codes), defined in the file "OpcodeDefinitions.h", in the Enumeration (enum), "TSystemFunctions", Enum "TSystemExternParms", and Enum "TSystemParmTypes". These are ALL setup with "Conditional Inclusion", on the DEFINE "hasCamera".

When including file "OpcodeDefinitions.h" in file "cameraIntrinsics.h" as shown below:

Code:
#if defined(hasCamera)

#include "OpcodeDefinitions.h"
#include "TCameraResults.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////
//
//      Camera Control and Operation
//
///////////////////////////////////////////////////////////////////////////////////////////////////////




Gives an entirely new set of Error Messages:

Code:
**FATAL**:Include file 'OpcodeDefinitions.h' has already been opened in precompiled header
**Severe*:Couldn't open '#include' file 'OpcodeDefinitions.h'
**Error**:Undefined variable 'sysFuncCameraFunctions'. 'short' assumed.
**Error**:Undefined variable 'sysFuncSetCameraConfig'. 'short' assumed.
**Error**:Undefined variable 'sysFuncGetCameraConfig'. 'short' assumed.
**Error**:Undefined variable 'sysFuncGetTrackingParms'. 'short' assumed.
**Error**:Undefined variable 'kExternCMUCAMTracking'. 'short' assumed.
**Severe*:Constant Expression Expected
**Error**:Unexpected scanner token-> ')'
**Error**:Undefined variable 'kSystemStreamCameraIOToPC'. 'short' assumed.
**Severe*:Constant Expression Expected
**Error**:Unexpected scanner token-> ')'


Creating a new Header File, with just the Enumerations, "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes", causes a Error of Re-Definition of Enum "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes".

This leading me to believe that the "precompiled header" has been compiler with an older Version of "OpcodeDefinitions.h", or more likely, the "Conditional Inclusion" for "hasCamera" was not DEFINED, thus giving an incomplete "precompiled header", and the failure of the Definition of Structure "TTrackingDataInts". There might be other optional DEFINES as Well, that need to be DEFINED for the creation of the "precompiled headers".

_________________
MarkO

FRC Team 957 "2007-2009 Professional Mentor"

http://vex.markdoverholser.com/notice.html

http://vex.markdoverholser.com/
http://tech.markdoverholser.com/


Sun Jun 28, 2009 3:50 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: CMUcam Sample Code in ROBOTC 1.52
Quote:
OK, so somebody needs to Recompile the "RobotCIFI.exe" or wherever the Pre-Compiled Header Files are located, so that this will Compile.. Also, the ROBOTC Header Files ALL need to be Re-Written for "Conditional Inclusion" (See K_n_R, s4.11.3), with the format:

Won't stop the compiler from barfing when you include a file twice, though. That is quite broken. I use this:
Code:
#ifndef __COMMON_H__
#include "common.h"
#endif

with the appropriate defines in common.h, of course.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jun 28, 2009 4:16 am
Profile WWW
Rookie
User avatar

Joined: Fri Jun 12, 2009 6:38 pm
Posts: 25
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Post Re: CMUcam Sample Code in ROBOTC 1.52
mightor wrote:
Quote:
OK, so somebody needs to Recompile the "RobotCIFI.exe" or wherever the Pre-Compiled Header Files are located, so that this will Compile.. Also, the ROBOTC Header Files ALL need to be Re-Written for "Conditional Inclusion" (See K_n_R, s4.11.3), with the format:

Won't stop the compiler from barfing when you include a file twice, though. That is quite broken. I use this:
Code:
#ifndef __COMMON_H__
#include "common.h"
#endif

with the appropriate defines in common.h, of course.

Regards,
Xander


Yes, that is what "Conditional Inclusion" is all about.... The 3rd Paragraph of K_n_R, s4.11.3 explicitly describes the usage of "#defines" for this purpose.

But even that does not help in this case, because the Enumerations of, "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes" in the Pre-Compiled Headers, don't have the "named constants" (See K_n_R, sa.8.4), that are in the "OpcodeDefinitions.h" header file.

This is kind of a Catch-22.

The program won't compile, because the Pre-Compiled Headers have the Enumerations of, "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes", but don't have the "named constants" 'sysFuncCameraFunctions', 'sysFuncSetCameraConfig', 'sysFuncGetCameraConfig', 'sysFuncGetTrackingParms', 'kExternCMUCAMTracking', 'kSystemStreamCameraIOToPC'.

The Header File "OpcodeDefinitions.h" has the same Enumerations of, "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes", but do have the "named constants" 'sysFuncCameraFunctions', 'sysFuncSetCameraConfig', 'sysFuncGetCameraConfig', 'sysFuncGetTrackingParms', 'kExternCMUCAMTracking', 'kSystemStreamCameraIOToPC'.

Since the Enumerations of, "TSystemFunctions", "TSystemExternParms", and "TSystemParmTypes" are different, the compiler will only accept the first Definition, which lacks the correct "named constants" to compile the Program.

So we are "stuck", until the Pre-Compiled Headers are re-built, or the Compiler is told to forget about using the Pre-Compiled Headers, and "compile it the Old Way"! ( I guess that would be Old-School.)

_________________
MarkO

FRC Team 957 "2007-2009 Professional Mentor"

http://vex.markdoverholser.com/notice.html

http://vex.markdoverholser.com/
http://tech.markdoverholser.com/


Sun Jun 28, 2009 5:38 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: CMUcam Sample Code in ROBOTC 1.52
MarkO,

I think you need to forget about what K'nR tell you is "The Right Way" when it comes to RobotC. RobotC is not ANSI compliant, nor does it claim to be. That means that some of the nice features and rules that the original founding fathers of C came up with don't apply here. It can be frustrating at times for experienced C programmers. I've banged my head on stuff like this a few times, trust me :)

Is there no work-around for your problem until it is fixed in a new build?

Regards,
Xander

PS: I don't think you had nearly enough hyper links in your last post. C'mon, you can do better than that! Next post try to make at least every 3rd word hyper linked.

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jun 28, 2009 5:55 am
Profile WWW
Rookie
User avatar

Joined: Fri Jun 12, 2009 6:38 pm
Posts: 25
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Post Re: CMUcam Sample Code in ROBOTC 1.52
mightor wrote:
MarkO,

I think you need to forget about what K'nR tell you is "The Right Way" when it comes to ROBOTC. ROBOTC is not ANSI compliant, nor does it claim to be. That means that some of the nice features and rules that the original founding fathers of C came up with don't apply here. It can be frustrating at times for experienced C programmers. I've banged my head on stuff like this a few times, trust me :)


Kn'R is not the Right Way, it is just a way. You can follow the way or not. The more ways you must follow, the more variations you must remember, the harder it becomes to be proficient at all of the ways. It does not matter if RobotC follows the Kn'R way, or their own way. I can learn whatever..

So... In the matter "Conditional Inclusion", RobotC seems to support it (in the K_n_R way), because Include Files like "TCamera.h" and "cameraIntrinsics.h" implement it, but files like "cameraConfiguration.h" don't. In the mater of Pre-Compiled Headers, that is from the RobotC Compiler itself, "**FATAL**:Include file 'OpcodeDefinitions.h' has already been opened in precompiled header". In the matter of the definition of "named constants" for the Items within an Enum, I guess you can pick whatever "term" you want to call it, but then you will need to Describe it before usage, so that those following the conversation will be able to understand what ideas you are conveying.


Quote:
Is there no work-around for your problem until it is fixed in a new build?


I am sure there is a work around... "Re-Build the Pre-Compiled Headers with the correct #include Files" or "Tell the Compiler to not use the Pre-Compiled Headers", unfortunately the RobotC documentation is very limited on Compiler Options for either of the above. It might be possible to Hard-Code the Values from the #include Files, but if the Compiler itself was built with a different version, you will get unpredictable results.


Quote:
Regards,
Xander

PS: I don't think you had nearly enough hyper links in your last post. C'mon, you can do better than that! Next post try to make at least every 3rd word hyper linked.


:) Every good researcher lists their references. Also, it is Polite to Introduce or Reference Terminology before using it in conversation. If you find the Hyper-Links "superfluous", you may skip them, others may want to use them to learn where the Information was obtained from or what that Colloquialism means. I am conversing with you, "mightor", but writing for everyone.

"The problem with communication... Is the illusion that it has been accomplished." - G. Bernard Shaw

_________________
MarkO

FRC Team 957 "2007-2009 Professional Mentor"

http://vex.markdoverholser.com/notice.html

http://vex.markdoverholser.com/
http://tech.markdoverholser.com/


Sun Jun 28, 2009 7:37 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: CMUcam Sample Code in ROBOTC 1.52
MarkO wrote:
:) Every good researcher lists their references. Also, it is Polite to Introduce or Reference Terminology before using it in conversation. If you find the Hyper-Links "superfluous", you may skip them, others may want to use them to learn where the Information was obtained from or what that Colloquialism means. I am conversing with you, "mightor", but writing for everyone.

I liked the fact that you hyper link so much. It shows you care enough that people understand what you're trying to say by clarifying the terms you're using. I try to do the same whenever I write an article for my blog. I did not think it was superfluous in any way, it just brought a smile to my face :)

As for documentation, I think you hit the nail on the head. There is a profound lack of documentation for the internals (and public interface) for RobotC. The stuff we do know has been gathered bit by bit but never really collated anywhere.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jun 28, 2009 8:21 am
Profile WWW
Rookie
User avatar

Joined: Fri Jun 12, 2009 6:38 pm
Posts: 25
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Post Re: CMUcam Sample Code in ROBOTC 1.52
lyncas wrote:
I open up the sample program without any modifications ,
Code:
CMUCAM_Simple_Test.c


And i get the following compliation errors.

Code:
**Error**:Undefined variable 'TTrackingDataInts'. 'short' assumed.
**Error**:Expected->';'. Found 'myData'
**Error**:Undefined variable 'myData'. 'short' assumed.
*Warning*:Meaningless statement -- no code generated
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:Undefined variable 'camStatusTracking'. 'short' assumed.
**Error**:Undefined procedure 'GetTrackingParms'.
**Error**:'myData' is not a 'struct' variable
**Error**:'myData' is not a 'struct' variable
**Info***:'horizontal' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'vertical' is written but has no read references
**Error**:'myData' is not a 'struct' variable
**Info***:'nFrameRate' is written but has no read references


I am doing something wrong ?


OK, I don't have the CMUCAM to work with, I have a Zip File with two modified files for you to try. I got this to compile, but I have no idea if it will download and work, or what.

I recommend you backup your "Includes" and "sample programs\VEX" Subdirectories, but I did included the Unmodified versions of the files, the extensions renamed ".org", for Original.

The file "CMUCAM_Simple_Test.c" has one line added, "#define hasCamera".

The file "cameraIntrinsics.h" has the "named constants" from the Enumeration "TSystemFunctions" from the file "OpcodeDefinitions.h", HardCoded into it.

They are:
Code:
    sysFuncCameraFunctions          = 18,
    sysFuncSetCameraConfig          = 19,
    sysFuncGetCameraConfig          = 20,
    sysFuncGetTrackingParms         = 21,


Remember, YMMV.....

(File Attachment is not currently working, use this backup Link, ROBOTC for IFI.zip.)

_________________
MarkO

FRC Team 957 "2007-2009 Professional Mentor"

http://vex.markdoverholser.com/notice.html

http://vex.markdoverholser.com/
http://tech.markdoverholser.com/


Tue Jun 30, 2009 12:41 am
Profile WWW
Rookie

Joined: Tue Mar 10, 2009 2:43 pm
Posts: 21
Location: Houston, TX
Post Re: CMUcam Sample Code in ROBOTC 1.52
Thanks for the help, I will try to test out this code soon.

I'm more interested in getting access to the serial port than testing CMUcam but this code will definitely be useful.


Tue Jun 30, 2009 1:05 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.