Pages: [1]   Go Down
Author Topic: "class was not declared in this scope" I could swear it was.  (Read 1177 times)
0 Members and 1 Guest are viewing this topic.
Vancouver, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
I want to make a living designing robots
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a file,
https://github.com/i-make-robots/Delta-Robot/tree/master/arduino/ik/ik.ino
that includes another file,
https://github.com/i-make-robots/Delta-Robot/tree/master/arduino/ik/Vector3.ino
and yet when I compile on OSX Arduino 1.0.1 I get...

ik:3: error: 'Vector3' was not declared in this scope
ik:40: error: 'Vector3' does not name a type
ik:41: error: 'Vector3' does not name a type
ik:42: error: 'Vector3' does not name a type
ik:43: error: 'Vector3' does not name a type
ik:44: error: 'Vector3' does not name a type
ik.cpp: In function 'void setup_robot()':
ik:91: error: 'Vector3' was not declared in this scope
ik:91: error: expected `;' before 'temp'
ik:98: error: 'class Joint' has no member named 'pos'
ik:102: error: 'class Joint' has no member named 'pos'
ik:106: error: 'n' was not declared in this scope
ik:106: error: 'class Joint' has no member named 'pos'
ik:108: error: 'temp' was not declared in this scope
ik:108: error: 'class Joint' has no member named 'pos'
ik:109: error: 'class Joint' has no member named 'pos'
ik:112: error: 'class Joint' has no member named 'pos'
ik:114: error: 'class Joint' has no member named 'relative'
ik:114: error: 'class Joint' has no member named 'pos'
ik:115: error: 'class Joint' has no member named 'relative'
ik:115: error: 'class Joint' has no member named 'pos'
ik:116: error: 'class Joint' has no member named 'relative'
ik:119: error: 'class Joint' has no member named 'pos'
ik.cpp: At global scope:
ik:151: error: redefinition of 'char outOfBounds'
ik:3: error: 'char outOfBounds' previously defined here
ik:151: error: 'Vector3' was not declared in this scope

Please: what am I doing wrong and how do I fix it?

Thank you!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50345
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd help you out, but I don't see anything useful at either of those links. Use the Additional Options link below to attach the code.
Logged

Vancouver, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
I want to make a living designing robots
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here you go.

* ik.ino (12.86 KB - downloaded 12 times.)
Logged

Vancouver, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
I want to make a living designing robots
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is vector3.h

* Vector3.h (6.82 KB - downloaded 25 times.)
Logged

Miramar Beach, Florida
Online Online
Faraday Member
**
Karma: 150
Posts: 6120
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you certain that is the way those files are supposed to be compiled? It looks like you must open the first file, then add the second file.

Open the file ik.ino with your IDE. Then select "Sketch/Add file". Find and add Vector3.ino. Compile.

Is that what you did?
Logged

Vancouver, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
I want to make a living designing robots
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The moment I open the first file it automatically opens the second, same as in the Marlin sourcecode.
I tried it your way... no difference.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50345
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why is Vector3.h, being used with a .ino file, including WProgram.h? That does not exist after 1.0.
Logged

Vancouver, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
I want to make a living designing robots
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems I've fixed the problem.  I checked it into Github if anyone wants to see.  A few of the operators had to be removed and I cut out some other stuff just to be on the lean side.

Thanks for the help!
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think your sketch  can "include"  another  .ino file.

It normally has to include .h files
Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 74
Posts: 2224
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

#include will grab any text file, some things that get included aren't valid c or c++ so putting it in a .c, .h, or .cpp would be misleading.
Logged


Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

#include will grab any text file, some things that get included aren't valid c or c++ so putting it in a .c, .h, or .cpp would be misleading.

You mean if you were doing
Code:
char* str =
#include "stringsource"
;
stringsource:
Code:
"Hello this is a string"
How would you do that without quotation marks in the included file?
Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 74
Posts: 2224
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That wasn't my exactly my intention, by text file I meant a non binary file, however, I'll post an example from some code I wrote a while ago to help me do a platform independent low level IO system.

This is part of the AVR implementation, it dynamically loads a particular file based on the chipset, that file is used to create an array of pins for port mapping.

Code:
#if defined(__AVR_ATmega168__) ||defined(__AVR_ATmega168P__) ||defined(__AVR_ATmega328P__)
#define CHIPSET ATmega_168_168P_328P
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define CHIPSET ATmega_1280_2560
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
#define CHIPSET ATmega_644_644P_1284P
#elif defined(__AVR_ATmega32U4__)
#ifdef CORE_TEENSY
#define CHIPSET ATmega_32U4_A
#else
#define CHIPSET ATmega_32U4_B
#endif
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define CHIPSET AT90USB_646_1286
#endif
#define _PIN( port, bit )      {&DDR##port, &PIN##port, &PORT##port, bit},

const static pin_map_t pinMap[] = {
#include INCLUDE_FILE_3(HARDWARE_PREFIX,GENX_PLATFORM,MAKE_DIR(CHIPSET),.pins)
};
#undef CHIPSET
#undef _PIN

and this is the pins file for the 328

Code:
_PIN( D, 0 )
_PIN( D, 1 )
_PIN( D, 2 )
_PIN( D, 3 )
_PIN( D, 4 )
_PIN( D, 5 )
_PIN( D, 6 )
_PIN( D, 7 )

_PIN( B, 0 )
_PIN( B, 1 )
_PIN( B, 2 )
_PIN( B, 3 )
_PIN( B, 4 )
_PIN( B, 5 )

_PIN( C, 0 )
_PIN( C, 1 )
_PIN( C, 2 )
_PIN( C, 3 )
_PIN( C, 4 )
_PIN( C, 5 )

This list is laid out for the Uno pin layout, very easy to re-order for other designs.
Logged


Pages: [1]   Go Up
Jump to: