I used gnuplot in a cpp code. I take the code from a guide. I tun this code without error,but the graphics can not be show.
Code :
#define GNUPLOT "gnuplot -persist"
int main(int argc, char **argv)
{
FILE *gp;
gp = popen(GNUPLOT,"w"); /* ’gp’ is the pipe descriptor */
if (gp==NULL)
{
printf("Error opening pipe to GNU plot. Check if you have it! \n");
return 0;
}
fprintf(gp, "set samples 2000\n");
fprintf(gp, "plot cos(x) \n");
fprintf(gp, "rep sin(x) \n");
fclose(gp);
return 0;
}
EDIT 1
I tried examples from another guide. I compile and run without error them, but the graph does not appear. I use linux os.
Code2 :
#include <stdio.h>
#include <plot.h>
#include <math.h>
#define SIZE 100.0 /* nominal size of user coordinate frame */
#define EXPAND 2.2 /* expansion factor for elliptical box */
void draw_boxed_string (plPlotter *plotter,
char *s, double size, double angle)
{
double true_size, width;
pl_ftextangle_r (plotter, angle); /* set text angle (degrees) */
true_size = pl_ffontsize_r (plotter, size); /* set font size */
width = pl_flabelwidth_r (plotter, s); /* compute width of string */
pl_fellipserel_r (plotter, 0.0, 0.0,
EXPAND * 0.5 * width, EXPAND * 0.5 * true_size,
angle); /* draw surrounding ellipse */
pl_alabel_r (plotter, 'c', 'c', s); /* draw centered text string */
}
int main()
{
plPlotter *plotter;
plPlotterParams *plotter_params;
int i;
/* set a Plotter parameter */
plotter_params = pl_newplparams ();
pl_setplparam (plotter_params, "PAGESIZE", "letter");
/* create a Postscript Plotter that writes to standard output */
if ((plotter = pl_newpl_r ("ps", stdin, stdout, stderr,
plotter_params)) == NULL)
{
fprintf (stderr, "Couldn't create Plotter\n");
return 1;
}
if (pl_openpl_r (plotter) < 0) /* open Plotter */
{
fprintf (stderr, "Couldn't open Plotter\n");
return 1;
}
/* specify user coor system */
pl_fspace_r (plotter, -(SIZE), -(SIZE), SIZE, SIZE);
pl_pencolorname_r (plotter, "blue"); /* use blue pen */
pl_fillcolorname_r (plotter, "white"); /* set white fill color */
pl_filltype_r (plotter, 1); /* fill ellipses with fill color */
/* choose a Postscript font */
pl_fontname_r (plotter, "NewCenturySchlbk-Roman");
for (i = 80; i > 1; i--) /* loop through angles */
{
double theta, radius;
theta = 0.5 * (double)i; /* theta is in radians */
radius = SIZE / pow (theta, 0.35); /* this yields a spiral */
pl_fmove_r (plotter, radius * cos (theta), radius * sin (theta));
draw_boxed_string (plotter, "GNU libplot!", 0.04 * radius,
(180.0 * theta / M_PI) - 90.0);
}
if (pl_closepl_r (plotter) < 0) /* close Plotter */
{
fprintf (stderr, "Couldn't close Plotter\n");
return 1;
}
if (pl_deletepl_r (plotter) < 0) /* delete Plotter */
{
fprintf (stderr, "Couldn't delete Plotter\n");
return 1;
}
return 0;
}
You should run ./plot > a.ps not only ./plot
Related
I'm trying to render some text using FreeType and OpenGL:
text = "fghjRT-123VWYUGHJ$#%"
And have two questions:
Why there are so weird spaces between letters? (what wrong with advance?)
How to calculate top position (or origin position)? (there are some space between yellow border and characters. I want to attach it to the top border)
My render code:
/* top left position on screen to render text (yellow border) */
Vector<2> pos = params.rect.left_top();
/* adjust to bottom (how to get correct origin position?) */
pos.y() += font->char_size();
for (char ch : params.text)
{
/* contains info after freetype FT_LoadGlyph */
FontChar const* char_info = font->find_char(ch);
RectF char_rect(
pos - char_info->bearing(), /* left, top */
char_info->glyph_rect().size() /* width, height */
);
/* convert screen coordinates to OpenGL coordinates */
RectF dr = calc_coord(m_screen_size, char_rect);
/* pack position of glyph and it's texture from bitmap
* into one sequence of data
*/
Vector<16> spr_coords = pack_spr_info(dr, char_info->rect());
m_sprite_buffer.push_back(spr_coords);
/* move pen by advance */
pos.x() += char_info->advance();
}
Piece of my glyph loading code:
FT_GlyphSlot slot = face->glyph;
char_info->bearing() = {
slot->metrics.horiBearingX / 64.0f,
slot->metrics.horiBearingY / 64.0f
};
char_info->glyph_rect() = {
slot->metrics.horiBearingX / 64.0f, /* left */
slot->metrics.horiBearingY / 64.0f, /* top */
slot->metrics.width / 64.0f, /* width */
slot->metrics.height / 64.0f /* height */
};
char_info->advance() = slot->metrics.horiAdvance / 64.0f;
Ok, I found out the answer by myself.
There are was a mistake in my calculation for char_rect position. Correct way:
RectF char_rect(
pos.x() + char_info->bearing().x(), /* left */
pos.y() - char_info->bearing().y(), /* top */
char_info->glyph_rect().size() /* width, height */
);
And the way to find baseline(origin) adjusted from top border:
Vector<2> pos = params.rect.left_top();
pos.y() += font->ascend(); /* move pen down on the screen */
Where:
FT_Face face = ...;
font->ascend() = face->ascender / 32;
I have 2x2 image
Shouldn't the pixels be arranged like this?
1 2 // each number is a pixel
3 4
I'm having trouble accessing a pixel with x and y because
when x = 1 and y = 0 i get index 2 but prints the rgb values of pixel 4
so it's something like?
1 2 // each number is a pixel
4 3
Here's the code that I use
index = y + x * s->w;
c = s->format->palette->colors[index]; // c is an SDL_Color and s is an SDL_Surface*
I also use this for loop and still prints the same
for (Uint8 i = *(Uint8 *)s->pixels; i < s->w*s->h; i++) {
c = s->format->palette->colors[i];
printf("%u %u %u %u \n", i, c.r , c.g , c.b);
}
SDL_Surface struct definition from the SDL documentation
typedef struct SDL_Surface {
Uint32 flags; /* Read-only */
SDL_PixelFormat *format; /* Read-only */
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
void *pixels; /* Read-write */
/* clipping information */
SDL_Rect clip_rect; /* Read-only */
/* Reference count -- used when freeing surface */
int refcount; /* Read-mostly */
/* This structure also contains private fields not shown here */
} SDL_Surface;
Uint8 *pixel = (Uint8 *)s->pixels,*index;
index = &pixel[y + x * s->pitch];
c = s->format->palette->colors[*index];
Got it doing using #holyblackcat's suggestion.
I am using a program to train svm classifier for object detection using hog descriptor. And i am not able to get the executable file of main program. My code is as follows:
#include <stdio.h>
#include <dirent.h>
#include <ios>
#include <fstream>
#include <stdexcept>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/ml/ml.hpp>
#define SVMLIGHT 1
#define LIBSVM 2
#define TRAINHOG_USEDSVM SVMLIGHT
#if TRAINHOG_USEDSVM == SVMLIGHT
#include "svm_light/svmlight.h"
#define TRAINHOG_SVM_TO_TRAIN SVMlight
#elif TRAINHOG_USEDSVM == LIBSVM
#include "libsvm/libsvm.h"
#define TRAINHOG_SVM_TO_TRAIN libSVM
#endif
using namespace std;
using namespace cv;
static string posSamplesDir = "pos/";
static string negSamplesDir = "neg/";
static string featuresFile = "genfiles/features.dat";
static string svmModelFile = "genfiles/svmlightmodel.dat";
static string descriptorVectorFile = "genfiles/descriptorvector.dat";
static const Size trainingPadding = Size(0,0);
static const Size winStride = Size(8,8);
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Helper functions">
/* Helper functions */
static string toLowerCase(const string& in) {
string t;
for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
t += tolower(*i);
}
return t;
}
static void storeCursor(void) {
printf("\033[s");
}
static void resetCursor(void) {
printf("\033[u");
}
/**
* Saves the given descriptor vector to a file
* #param descriptorVector the descriptor vector to save
* #param _vectorIndices contains indices for the corresponding vector values (e.g. descriptorVector(0)=3.5f may have index 1)
* #param fileName
* #TODO Use _vectorIndices to write correct indices
*/
static void saveDescriptorVectorToFile(vector<float>& descriptorVector, vector<unsigned int>& _vectorIndices, string fileName) {
printf("Saving descriptor vector to file '%s'\n", fileName.c_str());
string separator = " "; // Use blank as default separator between single features
fstream File;
float percent;
File.open(fileName.c_str(), ios::out);
if (File.good() && File.is_open()) {
printf("Saving %lu descriptor vector features:\t", descriptorVector.size());
storeCursor();
for (int feature = 0; feature < descriptorVector.size(); ++feature) {
if ((feature % 10 == 0) || (feature == (descriptorVector.size()-1)) ) {
percent = ((1 + feature) * 100 / descriptorVector.size());
printf("%4u (%3.0f%%)", feature, percent);
fflush(stdout);
resetCursor();
}
File << descriptorVector.at(feature) << separator;
}
printf("\n");
File << endl;
File.flush();
File.close();
}
}
/**
* For unixoid systems only: Lists all files in a given directory and returns a vector of path+name in string format
* #param dirName
* #param fileNames found file names in specified directory
* #param validExtensions containing the valid file extensions for collection in lower case
*/
static void getFilesInDirectory(const string& dirName, vector<string>& fileNames, const vector<string>& validExtensions) {
printf("Opening directory %s\n", dirName.c_str());
struct dirent* ep;
size_t extensionLocation;
DIR* dp = opendir(dirName.c_str());
if (dp != NULL) {
while ((ep = readdir(dp))) {
// Ignore (sub-)directories like . , .. , .svn, etc.
if (ep->d_type & DT_DIR) {
continue;
}
extensionLocation = string(ep->d_name).find_last_of("."); // Assume the last point marks beginning of extension like file.ext
// Check if extension is matching the wanted ones
string tempExt = toLowerCase(string(ep->d_name).substr(extensionLocation + 1));
if (find(validExtensions.begin(), validExtensions.end(), tempExt) != validExtensions.end()) {
printf("Found matching data file '%s'\n", ep->d_name);
fileNames.push_back((string) dirName + ep->d_name);
} else {
printf("Found file does not match required file type, skipping: '%s'\n", ep->d_name);
}
}
(void) closedir(dp);
} else {
printf("Error opening directory '%s'!\n", dirName.c_str());
}
return;
}
/**
* This is the actual calculation from the (input) image data to the HOG descriptor/feature vector using the hog.compute() function
* #param imageFilename file path of the image file to read and calculate feature vector from
* #param descriptorVector the returned calculated feature vector<float> ,
* I can't comprehend why openCV implementation returns std::vector<float> instead of cv::MatExpr_<float> (e.g. Mat<float>)
* #param hog HOGDescriptor containin HOG settings
*/
static void calculateFeaturesFromInput(const string& imageFilename, vector<float>& featureVector, HOGDescriptor& hog) {
/** for imread flags from openCV documentation,
* #see http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#Mat imread(const string& filename, int flags)
* #note If you get a compile-time error complaining about following line (esp. imread),
* you either do not have a current openCV version (>2.0)
* or the linking order is incorrect, try g++ -o openCVHogTrainer main.cpp `pkg-config --cflags --libs opencv`
*/
Mat imageData = imread(imageFilename, 0);
if (imageData.empty()) {
featureVector.clear();
printf("Error: HOG image '%s' is empty, features calculation skipped!\n", imageFilename.c_str());
return;
}
// Check for mismatching dimensions
if (imageData.cols != hog.winSize.width || imageData.rows != hog.winSize.height) {
featureVector.clear();
printf("Error: Image '%s' dimensions (%u x %u) do not match HOG window size (%u x %u)!\n", imageFilename.c_str(), imageData.cols, imageData.rows, hog.winSize.width, hog.winSize.height);
return;
}
vector<Point> locations;
hog.compute(imageData, featureVector, winStride, trainingPadding, locations);
imageData.release(); // Release the image again after features are extracted
}
/**
* Shows the detections in the image
* #param found vector containing valid detection rectangles
* #param imageData the image in which the detections are drawn
*/
static void showDetections(const vector<Point>& found, Mat& imageData) {
size_t i, j;
for (i = 0; i < found.size(); ++i) {
Point r = found[i];
// Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
rectangle(imageData, Rect(r.x-16, r.y-32, 32, 64), Scalar(64, 255, 64), 3);
}
}
/**
* Shows the detections in the image
* #param found vector containing valid detection rectangles
* #param imageData the image in which the detections are drawn
*/
static void showDetections(const vector<Rect>& found, Mat& imageData) {
vector<Rect> found_filtered;
size_t i, j;
for (i = 0; i < found.size(); ++i) {
Rect r = found[i];
for (j = 0; j < found.size(); ++j)
if (j != i && (r & found[j]) == r)
break;
if (j == found.size())
found_filtered.push_back(r);
}
for (i = 0; i < found_filtered.size(); i++) {
Rect r = found_filtered[i];
rectangle(imageData, r.tl(), r.br(), Scalar(64, 255, 64), 3);
}
}
/**
* Test the trained detector against the same training set to get an approximate idea of the detector.
* Warning: This does not allow any statement about detection quality, as the detector might be overfitting.
* Detector quality must be determined using an independent test set.
* #param hog
*/
static void detectTrainingSetTest(const HOGDescriptor& hog, const double hitThreshold, const vector<string>& posFileNames, const vector<string>& negFileNames) {
unsigned int truePositives = 0;
unsigned int trueNegatives = 0;
unsigned int falsePositives = 0;
unsigned int falseNegatives = 0;
vector<Point> foundDetection;
// Walk over positive training samples, generate images and detect
for (vector<string>::const_iterator posTrainingIterator = posFileNames.begin(); posTrainingIterator != posFileNames.end(); ++posTrainingIterator) {
const Mat imageData = imread(*posTrainingIterator, 0);
hog.detect(imageData, foundDetection, hitThreshold, winStride, trainingPadding);
if (foundDetection.size() > 0) {
++truePositives;
falseNegatives += foundDetection.size() - 1;
} else {
++falseNegatives;
}
}
// Walk over negative training samples, generate images and detect
for (vector<string>::const_iterator negTrainingIterator = negFileNames.begin(); negTrainingIterator != negFileNames.end(); ++negTrainingIterator) {
const Mat imageData = imread(*negTrainingIterator, 0);
hog.detect(imageData, foundDetection, hitThreshold, winStride, trainingPadding);
if (foundDetection.size() > 0) {
falsePositives += foundDetection.size();
} else {
++trueNegatives;
}
}
printf("Results:\n\tTrue Positives: %u\n\tTrue Negatives: %u\n\tFalse Positives: %u\n\tFalse Negatives: %u\n", truePositives, trueNegatives, falsePositives, falseNegatives);
}
/**
* Test detection with custom HOG description vector
* #param hog
* #param hitThreshold threshold value for detection
* #param imageData
*/
static void detectTest(const HOGDescriptor& hog, const double hitThreshold, Mat& imageData) {
vector<Rect> found;
Size padding(Size(32, 32));
Size winStride(Size(8, 8));
hog.detectMultiScale(imageData, found, hitThreshold, winStride, padding);
showDetections(found, imageData);
}
// </editor-fold>
/**
* Main program entry point
* #param argc unused
* #param argv unused
* #return EXIT_SUCCESS (0) or EXIT_FAILURE (1)
*/
int main(int argc, char** argv) {
// <editor-fold defaultstate="collapsed" desc="Init">
HOGDescriptor hog; // Use standard parameters here
hog.winSize = Size(64, 128); // Default training images size as used in paper
// Get the files to train from somewhere
static vector<string> positiveTrainingImages;
static vector<string> negativeTrainingImages;
static vector<string> validExtensions;
validExtensions.push_back("jpg");
validExtensions.push_back("png");
validExtensions.push_back("ppm");
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Read image files">
getFilesInDirectory(posSamplesDir, positiveTrainingImages, validExtensions);
getFilesInDirectory(negSamplesDir, negativeTrainingImages, validExtensions);
/// Retrieve the descriptor vectors from the samples
unsigned long overallSamples = positiveTrainingImages.size() + negativeTrainingImages.size();
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Calculate HOG features and save to file">
// Make sure there are actually samples to train
if (overallSamples == 0) {
printf("No training sample files found, nothing to do!\n");
return EXIT_SUCCESS;
}
/// #WARNING: This is really important, some libraries (e.g. ROS) seems to set the system locale which takes decimal commata instead of points which causes the file input parsing to fail
setlocale(LC_ALL, "C"); // Do not use the system locale
setlocale(LC_NUMERIC,"C");
setlocale(LC_ALL, "POSIX");
printf("Reading files, generating HOG features and save them to file '%s':\n", featuresFile.c_str());
float percent;
/**
* Save the calculated descriptor vectors to a file in a format that can be used by SVMlight for training
* #NOTE: If you split these steps into separate steps:
* 1. calculating features into memory (e.g. into a cv::Mat or vector< vector<float> >),
* 2. saving features to file / directly inject from memory to machine learning algorithm,
* the program may consume a considerable amount of main memory
*/
fstream File;
File.open(featuresFile.c_str(), ios::out);
if (File.good() && File.is_open()) {
// Remove following line for libsvm which does not support comments
// File << "# Use this file to train, e.g. SVMlight by issuing $ svm_learn -i 1 -a weights.txt " << featuresFile.c_str() << endl;
// Iterate over sample images
for (unsigned long currentFile = 0; currentFile < overallSamples; ++currentFile) {
storeCursor();
vector<float> featureVector;
// Get positive or negative sample image file path
const string currentImageFile = (currentFile < positiveTrainingImages.size() ? positiveTrainingImages.at(currentFile) : negativeTrainingImages.at(currentFile - positiveTrainingImages.size()));
// Output progress
if ( (currentFile+1) % 10 == 0 || (currentFile+1) == overallSamples ) {
percent = ((currentFile+1) * 100 / overallSamples);
printf("%5lu (%3.0f%%):\tFile '%s'", (currentFile+1), percent, currentImageFile.c_str());
fflush(stdout);
resetCursor();
}
// Calculate feature vector from current image file
calculateFeaturesFromInput(currentImageFile, featureVector, hog);
if (!featureVector.empty()) {
/* Put positive or negative sample class to file,
* true=positive, false=negative,
* and convert positive class to +1 and negative class to -1 for SVMlight
*/
File << ((currentFile < positiveTrainingImages.size()) ? "+1" : "-1");
// Save feature vector components
for (unsigned int feature = 0; feature < featureVector.size(); ++feature) {
File << " " << (feature + 1) << ":" << featureVector.at(feature);
}
File << endl;
}
}
printf("\n");
File.flush();
File.close();
} else {
printf("Error opening file '%s'!\n", featuresFile.c_str());
return EXIT_FAILURE;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Pass features to machine learning algorithm">
/// Read in and train the calculated feature vectors
printf("Calling %s\n", TRAINHOG_SVM_TO_TRAIN::getInstance()->getSVMName());
TRAINHOG_SVM_TO_TRAIN::getInstance()->read_problem(const_cast<char*> (featuresFile.c_str()));
TRAINHOG_SVM_TO_TRAIN::getInstance()->train(); // Call the core libsvm training procedure
printf("Training done, saving model file!\n");
TRAINHOG_SVM_TO_TRAIN::getInstance()->saveModelToFile(svmModelFile);
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Generate single detecting feature vector from calculated SVM support vectors and SVM model">
printf("Generating representative single HOG feature vector using svmlight!\n");
vector<float> descriptorVector;
vector<unsigned int> descriptorVectorIndices;
// Generate a single detecting feature vector (v1 | b) from the trained support vectors, for use e.g. with the HOG algorithm
TRAINHOG_SVM_TO_TRAIN::getInstance()->getSingleDetectingVector(descriptorVector, descriptorVectorIndices);
// And save the precious to file system
saveDescriptorVectorToFile(descriptorVector, descriptorVectorIndices, descriptorVectorFile);
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Test detecting vector">
// Detector detection tolerance threshold
const double hitThreshold = TRAINHOG_SVM_TO_TRAIN::getInstance()->getThreshold();
// Set our custom detecting vector
hog.setSVMDetector(descriptorVector);
printf("Testing training phase using training set as test set (just to check if training is ok - no detection quality conclusion with this!)\n");
detectTrainingSetTest(hog, hitThreshold, positiveTrainingImages, negativeTrainingImages);
printf("Testing custom detection using camera\n");
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) { // check if we succeeded
printf("Error opening camera!\n");
return EXIT_FAILURE;
}
Mat testImage;
while ((cvWaitKey(10) & 255) != 27) {
cap >> testImage; // get a new frame from camera
// cvtColor(testImage, testImage, CV_BGR2GRAY); // If you want to work on grayscale images
detectTest(hog, hitThreshold, testImage);
imshow("HOG custom detection", testImage);
}
// </editor-fold>
return EXIT_SUCCESS;
}
If i execute it as "./objectdetectmain.cpp", it gives errors as follows:
./objectdetectmain.cpp: line 24: using: command not found
./objectdetectmain.cpp: line 25: using: command not found
./objectdetectmain.cpp: line 29: static: command not found
./objectdetectmain.cpp: line 31: static: command not found
./objectdetectmain.cpp: line 33: static: command not found
./objectdetectmain.cpp: line 35: static: command not found
./objectdetectmain.cpp: line 37: static: command not found
./objectdetectmain.cpp: line 40: syntax error near unexpected token `('
./objectdetectmain.cpp: line 40: `static const Size trainingPadding = Size(0,0);
It seems that you are trying to run the source as a program. You need to compile it into an executable first. E.g.
g++ -Wall -g objectdetectmain.cpp -o objectdetectmain
which will give you an executable file named objectdetectmain (note lack of .cpp extension) which you can run:
./objectdetectmain
I have made a program that runs and I am able to enter in three variables, length, external diameter and internal diameter. After I enter in internal diameter the program freezes and a window pops up saying the program has stopped responding. The program's purpose is to calculate area, volume, mass, weight etc. of a cylindrical pipe given a number of variable inputs.
Any help would be appreciated.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.14159
#define ACC_GRAVITY 9.81 /* metres/sec^2 */
#define FALSE 0
#define TRUE !FALSE
int main(void)
{
/* define the required variables */
float length;
float ext_diam, int_diam;
float ext_rad, int_rad;
float volume;
float weight;
float area;
float mass;
float width;
float flag_1, flag_2, thickness, percent;
double no_sheets;
/* define some constants - could use #define */
const float density_convert = 1.0E3;
const float mm_to_metres = 1.0E-3;
const float density = 8.03; /* grams per cm^3 */
/* prompt and get values */
printf("input the length of pipe in metres: ");
scanf("%f", &length);
do
{
flag_1 = FALSE;
flag_2 = FALSE;
printf("intput the external diameter of the pipe in milimeters: ");
scanf("%f", &ext_diam);
printf("ext_diam: %f\n", ext_diam);
printf("intput the internal diameter of the pipe in milimeters: ");
scanf("%f", int_diam);
printf("int_diam: %f\n", int_diam);
if (ext_diam < int_diam)
{
printf("external diameter must be greater than the internal diameter\n");
flag_1 = TRUE;
}
else
{
percent = thickness / ext_diam * 100.0;
if(percent > 2.5 )
{
/* do calculations - conversions, area of pipe cross-section, volume
** of pipe, mass and weight of pipe */
ext_diam = ext_diam * mm_to_metres;
int_diam = int_diam * mm_to_metres;
ext_rad = ext_diam / 2.0;
int_rad = int_diam / 2.0;
area = (PI * ext_rad * ext_rad) - (PI * int_rad * int_rad);
volume = area * length;
mass = volume * density * density_convert;
weight = mass * ACC_GRAVITY;
}
else
{
printf("Width of pipe too small\n");
flag_2 = TRUE;
}
}
} while(ext_diam > 0.0);
/* output the results */
printf("area of cylinder: %f m^2\n", area);
printf("volume of steel needed: %f m^3\n", volume);
printf("mass of steel needed: %f kg\n", mass);
printf("weight of steel needed: %f newtons\n", weight);
/* compute number of sheets of steel needed - 10m is max length of a
** sheet */
no_sheets = trunc (length / 10.0) + 1;
printf("number of 10m long sheets needed: %d\n", no_sheets);
/* assume width of sheets is based on the average of the internal and
** external diameters */
width = 2.0 * PI * (ext_rad + int_rad) / 2.0;
printf("width of sheets: %f m\n",width);
system("pause");
return 0;
}
There are some issues with your code:
scanf("%f", int_diam);, scanf needs a pointer to the variable, this will work
scanf("%f", &int_diam);
In the line
percent = thickness / ext_diam * 100.0;
thickness is not initialized the first time it is used (did you forget a passage?)
Not sure if the termination when ext_diam is <= 0 is intended.
Finally, there are multiple double-to-float conversions (e.g. area calculus) which might cause loss of data
Change scanf("%f", int_diam); to scanf("%f", &int_diam);
Also, your do while loop seems to go into an infinite loop. Since it depends on the external diameter, either change the loop condition, or ensure that external diameter will reach a value <=0 inside the loop. Your do while loop will only terminate when user enters a non-positive value for ext_diam.
Also, assuming thickness refers to the thickness of the pipe, add this equation before you use this variable thickness=ext_diam-int_diam;, or any other formula you use to calculate the thickness.
I have been trying to compile a code for a accelerometer which is avaiable from two sources but referring to the same code on github:
https://github.com/ayildirim/OpenVR
https://github.com/ptrbrtz/razor-9dof-ahrs/
Both of this sources contain the following arduino code(c++):
#define HW__VERSION_CODE 10736 // SparkFun "9DOF Razor IMU" version "SEN-10736" (HMC5883L magnetometer)
// OUTPUT OPTIONS
/*****************************************************************/
// Set your serial port baud rate used to send out data here!
#define OUTPUT__BAUD_RATE 57600
// Sensor data output interval in milliseconds
// This may not work, if faster than 20ms (=50Hz)
// Code is tuned for 20ms, so better leave it like that
#define OUTPUT__DATA_INTERVAL 20 // in milliseconds
// Output mode definitions (do not change)
#define OUTPUT__MODE_CALIBRATE_SENSORS 0 // Outputs sensor min/max values as text for manual calibration
#define OUTPUT__MODE_ANGLES 1 // Outputs yaw/pitch/roll in degrees
#define OUTPUT__MODE_SENSORS_CALIB 2 // Outputs calibrated sensor values for all 9 axes
#define OUTPUT__MODE_SENSORS_RAW 3 // Outputs raw (uncalibrated) sensor values for all 9 axes
#define OUTPUT__MODE_SENSORS_BOTH 4 // Outputs calibrated AND raw sensor values for all 9 axes
// Output format definitions (do not change)
#define OUTPUT__FORMAT_TEXT 0 // Outputs data as text
#define OUTPUT__FORMAT_BINARY 1 // Outputs data as binary float
// Select your startup output mode and format here!
int output_mode = OUTPUT__MODE_ANGLES;
int output_format = OUTPUT__FORMAT_TEXT;
// Select if serial continuous streaming output is enabled per default on startup.
#define OUTPUT__STARTUP_STREAM_ON true // true or false
// If set true, an error message will be output if we fail to read sensor data.
// Message format: "!ERR: reading <sensor>", followed by "\r\n".
boolean output_errors = false; // true or false
// Bluetooth
// You can set this to true, if you have a Rovering Networks Bluetooth Module attached.
// The connect/disconnect message prefix of the module has to be set to "#".
// (Refer to manual, it can be set like this: SO,#)
// When using this, streaming output will only be enabled as long as we're connected. That way
// receiver and sender are synchronzed easily just by connecting/disconnecting.
// It is not necessary to set this! It just makes life easier when writing code for
// the receiving side. The Processing test sketch also works without setting this.
// NOTE: When using this, OUTPUT__STARTUP_STREAM_ON has no effect!
#define OUTPUT__HAS_RN_BLUETOOTH false // true or false
// SENSOR CALIBRATION
/*****************************************************************/
// How to calibrate? Read the tutorial at http://dev.qu.tu-berlin.de/projects/sf-razor-9dof-ahrs
// Put MIN/MAX and OFFSET readings for your board here!
// Accelerometer
// "accel x,y,z (min/max) = X_MIN/X_MAX Y_MIN/Y_MAX Z_MIN/Z_MAX"
#define ACCEL_X_MIN ((float) -289)
#define ACCEL_X_MAX ((float) 294)
#define ACCEL_Y_MIN ((float) -268)
#define ACCEL_Y_MAX ((float) 288)
#define ACCEL_Z_MIN ((float) -294)
#define ACCEL_Z_MAX ((float) 269)
// Magnetometer (standard calibration)
// "magn x,y,z (min/max) = X_MIN/X_MAX Y_MIN/Y_MAX Z_MIN/Z_MAX"
//#define MAGN_X_MIN ((float) -600)
//#define MAGN_X_MAX ((float) 600)
//#define MAGN_Y_MIN ((float) -600)
//#define MAGN_Y_MAX ((float) 600)
//#define MAGN_Z_MIN ((float) -600)
//#define MAGN_Z_MAX ((float) 600)
// Magnetometer (extended calibration)
// Uncommend to use extended magnetometer calibration (compensates hard & soft iron errors)
#define CALIBRATION__MAGN_USE_EXTENDED true
const float magn_ellipsoid_center[3] = {
3.80526, -16.4455, 87.4052};
const float magn_ellipsoid_transform[3][3] = {
{
0.970991, 0.00583310, -0.00265756 }
, {
0.00583310, 0.952958, 2.76726e-05 }
, {
-0.00265756, 2.76726e-05, 0.999751 }
};
// Gyroscope
// "gyro x,y,z (current/average) = .../OFFSET_X .../OFFSET_Y .../OFFSET_Z
#define GYRO_AVERAGE_OFFSET_X ((float) 23.85)
#define GYRO_AVERAGE_OFFSET_Y ((float) -53.41)
#define GYRO_AVERAGE_OFFSET_Z ((float) -15.32)
/*
// Calibration example:
// "accel x,y,z (min/max) = -278.00/270.00 -254.00/284.00 -294.00/235.00"
#define ACCEL_X_MIN ((float) -278)
#define ACCEL_X_MAX ((float) 270)
#define ACCEL_Y_MIN ((float) -254)
#define ACCEL_Y_MAX ((float) 284)
#define ACCEL_Z_MIN ((float) -294)
#define ACCEL_Z_MAX ((float) 235)
// "magn x,y,z (min/max) = -511.00/581.00 -516.00/568.00 -489.00/486.00"
//#define MAGN_X_MIN ((float) -511)
//#define MAGN_X_MAX ((float) 581)
//#define MAGN_Y_MIN ((float) -516)
//#define MAGN_Y_MAX ((float) 568)
//#define MAGN_Z_MIN ((float) -489)
//#define MAGN_Z_MAX ((float) 486)
// Extended magn
#define CALIBRATION__MAGN_USE_EXTENDED true
const float magn_ellipsoid_center[3] = {91.5, -13.5, -48.1};
const float magn_ellipsoid_transform[3][3] = {{0.902, -0.00354, 0.000636}, {-0.00354, 0.9, -0.00599}, {0.000636, -0.00599, 1}};
// Extended magn (with Sennheiser HD 485 headphones)
//#define CALIBRATION__MAGN_USE_EXTENDED true
//const float magn_ellipsoid_center[3] = {72.3360, 23.0954, 53.6261};
//const float magn_ellipsoid_transform[3][3] = {{0.879685, 0.000540833, -0.0106054}, {0.000540833, 0.891086, -0.0130338}, {-0.0106054, -0.0130338, 0.997494}};
//"gyro x,y,z (current/average) = -32.00/-34.82 102.00/100.41 -16.00/-16.38"
#define GYRO_AVERAGE_OFFSET_X ((float) -34.82)
#define GYRO_AVERAGE_OFFSET_Y ((float) 100.41)
#define GYRO_AVERAGE_OFFSET_Z ((float) -16.38)
*/
// DEBUG OPTIONS
/*****************************************************************/
// When set to true, gyro drift correction will not be applied
#define DEBUG__NO_DRIFT_CORRECTION false
// Print elapsed time after each I/O loop
#define DEBUG__PRINT_LOOP_TIME false
/*****************************************************************/
/****************** END OF USER SETUP AREA! *********************/
/*****************************************************************/
// Check if hardware version code is defined
#ifndef HW__VERSION_CODE
// Generate compile error
#error YOU HAVE TO SELECT THE HARDWARE YOU ARE USING! See "HARDWARE OPTIONS" in "USER SETUP AREA" at top of Razor_AHRS.pde (or .ino)!
#endif
#include <Wire.h>
#include <Compass.h>
#include <DCM.h>
#include <Math.h>
#include <Output.h>
#include <Sensors.h>
// Sensor calibration scale and offset values
#define ACCEL_X_OFFSET ((ACCEL_X_MIN + ACCEL_X_MAX) / 2.0f)
#define ACCEL_Y_OFFSET ((ACCEL_Y_MIN + ACCEL_Y_MAX) / 2.0f)
#define ACCEL_Z_OFFSET ((ACCEL_Z_MIN + ACCEL_Z_MAX) / 2.0f)
#define ACCEL_X_SCALE (GRAVITY / (ACCEL_X_MAX - ACCEL_X_OFFSET))
#define ACCEL_Y_SCALE (GRAVITY / (ACCEL_Y_MAX - ACCEL_Y_OFFSET))
#define ACCEL_Z_SCALE (GRAVITY / (ACCEL_Z_MAX - ACCEL_Z_OFFSET))
#define MAGN_X_OFFSET ((MAGN_X_MIN + MAGN_X_MAX) / 2.0f)
#define MAGN_Y_OFFSET ((MAGN_Y_MIN + MAGN_Y_MAX) / 2.0f)
#define MAGN_Z_OFFSET ((MAGN_Z_MIN + MAGN_Z_MAX) / 2.0f)
#define MAGN_X_SCALE (100.0f / (MAGN_X_MAX - MAGN_X_OFFSET))
#define MAGN_Y_SCALE (100.0f / (MAGN_Y_MAX - MAGN_Y_OFFSET))
#define MAGN_Z_SCALE (100.0f / (MAGN_Z_MAX - MAGN_Z_OFFSET))
// Gain for gyroscope (ITG-3200)
#define GYRO_GAIN 0.06957 // Same gain on all axes
#define GYRO_SCALED_RAD(x) (x * TO_RAD(GYRO_GAIN)) // Calculate the scaled gyro readings in radians per second
// DCM parameters
#define Kp_ROLLPITCH 0.02f
#define Ki_ROLLPITCH 0.00002f
#define Kp_YAW 1.2f
#define Ki_YAW 0.00002f
// Stuff
#define STATUS_LED_PIN 13 // Pin number of status LED
#define GRAVITY 256.0f // "1G reference" used for DCM filter and accelerometer calibration
#define TO_RAD(x) (x * 0.01745329252) // *pi/180
#define TO_DEG(x) (x * 57.2957795131) // *180/pi
// Sensor variables
float accel[3]; // Actually stores the NEGATED acceleration (equals gravity, if board not moving).
float accel_min[3];
float accel_max[3];
float magnetom[3];
float magnetom_min[3];
float magnetom_max[3];
float magnetom_tmp[3];
float gyro[3];
float gyro_average[3];
int gyro_num_samples = 0;
// DCM variables
float MAG_Heading;
float Accel_Vector[3]= {
0, 0, 0}; // Store the acceleration in a vector
float Gyro_Vector[3]= {
0, 0, 0}; // Store the gyros turn rate in a vector
float Omega_Vector[3]= {
0, 0, 0}; // Corrected Gyro_Vector data
float Omega_P[3]= {
0, 0, 0}; // Omega Proportional correction
float Omega_I[3]= {
0, 0, 0}; // Omega Integrator
float Omega[3]= {
0, 0, 0};
float errorRollPitch[3] = {
0, 0, 0};
float errorYaw[3] = {
0, 0, 0};
float DCM_Matrix[3][3] = {
{
1, 0, 0 }
, {
0, 1, 0 }
, {
0, 0, 1 }
};
float Update_Matrix[3][3] = {
{
0, 1, 2 }
, {
3, 4, 5 }
, {
6, 7, 8 }
};
float Temporary_Matrix[3][3] = {
{
0, 0, 0 }
, {
0, 0, 0 }
, {
0, 0, 0 }
};
// Euler angles
float yaw;
float pitch;
float roll;
// DCM timing in the main loop
unsigned long timestamp;
unsigned long timestamp_old;
float G_Dt; // Integration time for DCM algorithm
// More output-state variables
boolean output_stream_on;
boolean output_single_on;
int curr_calibration_sensor = 0;
boolean reset_calibration_session_flag = true;
int num_accel_errors = 0;
int num_magn_errors = 0;
int num_gyro_errors = 0;
void read_sensors() {
Read_Gyro(); // Read gyroscope
Read_Accel(); // Read accelerometer
Read_Magn(); // Read magnetometer
}
// Read every sensor and record a time stamp
// Init DCM with unfiltered orientation
// TODO re-init global vars?
void reset_sensor_fusion() {
float temp1[3];
float temp2[3];
float xAxis[] = {
1.0f, 0.0f, 0.0f };
read_sensors();
timestamp = millis();
// GET PITCH
// Using y-z-plane-component/x-component of gravity vector
pitch = -atan2(accel[0], sqrt(accel[1] * accel[1] + accel[2] * accel[2]));
// GET ROLL
// Compensate pitch of gravity vector
Vector_Cross_Product(temp1, accel, xAxis);
Vector_Cross_Product(temp2, xAxis, temp1);
// Normally using x-z-plane-component/y-component of compensated gravity vector
// roll = atan2(temp2[1], sqrt(temp2[0] * temp2[0] + temp2[2] * temp2[2]));
// Since we compensated for pitch, x-z-plane-component equals z-component:
roll = atan2(temp2[1], temp2[2]);
// GET YAW
Compass_Heading();
yaw = MAG_Heading;
// Init rotation matrix
init_rotation_matrix(DCM_Matrix, yaw, pitch, roll);
}
// Apply calibration to raw sensor readings
void compensate_sensor_errors() {
// Compensate accelerometer error
accel[0] = (accel[0] - ACCEL_X_OFFSET) * ACCEL_X_SCALE;
accel[1] = (accel[1] - ACCEL_Y_OFFSET) * ACCEL_Y_SCALE;
accel[2] = (accel[2] - ACCEL_Z_OFFSET) * ACCEL_Z_SCALE;
// Compensate magnetometer error
#if CALIBRATION__MAGN_USE_EXTENDED == true
for (int i = 0; i < 3; i++)
magnetom_tmp[i] = magnetom[i] - magn_ellipsoid_center[i];
Matrix_Vector_Multiply(magn_ellipsoid_transform, magnetom_tmp, magnetom);
#else
magnetom[0] = (magnetom[0] - MAGN_X_OFFSET) * MAGN_X_SCALE;
magnetom[1] = (magnetom[1] - MAGN_Y_OFFSET) * MAGN_Y_SCALE;
magnetom[2] = (magnetom[2] - MAGN_Z_OFFSET) * MAGN_Z_SCALE;
#endif
// Compensate gyroscope error
gyro[0] -= GYRO_AVERAGE_OFFSET_X;
gyro[1] -= GYRO_AVERAGE_OFFSET_Y;
gyro[2] -= GYRO_AVERAGE_OFFSET_Z;
}
// Reset calibration session if reset_calibration_session_flag is set
void check_reset_calibration_session()
{
// Raw sensor values have to be read already, but no error compensation applied
// Reset this calibration session?
if (!reset_calibration_session_flag) return;
// Reset acc and mag calibration variables
for (int i = 0; i < 3; i++) {
accel_min[i] = accel_max[i] = accel[i];
magnetom_min[i] = magnetom_max[i] = magnetom[i];
}
// Reset gyro calibration variables
gyro_num_samples = 0; // Reset gyro calibration averaging
gyro_average[0] = gyro_average[1] = gyro_average[2] = 0.0f;
reset_calibration_session_flag = false;
}
void turn_output_stream_on()
{
output_stream_on = true;
digitalWrite(STATUS_LED_PIN, HIGH);
}
void turn_output_stream_off()
{
output_stream_on = false;
digitalWrite(STATUS_LED_PIN, LOW);
}
// Blocks until another byte is available on serial port
char readChar()
{
while (Serial.available() < 1) {
} // Block
return Serial.read();
}
void setup()
{
// Init serial output
Serial.begin(OUTPUT__BAUD_RATE);
// Init status LED
pinMode (STATUS_LED_PIN, OUTPUT);
digitalWrite(STATUS_LED_PIN, LOW);
// Init sensors
delay(50); // Give sensors enough time to start
I2C_Init();
Accel_Init();
Magn_Init();
Gyro_Init();
// Read sensors, init DCM algorithm
delay(20); // Give sensors enough time to collect data
reset_sensor_fusion();
// Init output
#if (OUTPUT__HAS_RN_BLUETOOTH == true) || (OUTPUT__STARTUP_STREAM_ON == false)
turn_output_stream_off();
#else
turn_output_stream_on();
#endif
}
// Main loop
void loop()
{
// Read incoming control messages
if (Serial.available() >= 2)
{
if (Serial.read() == '#') // Start of new control message
{
int command = Serial.read(); // Commands
if (command == 'f') // request one output _f_rame
output_single_on = true;
else if (command == 's') // _s_ynch request
{
// Read ID
byte id[2];
id[0] = readChar();
id[1] = readChar();
// Reply with synch message
Serial.print("#SYNCH");
Serial.write(id, 2);
Serial.println();
}
else if (command == 'o') // Set _o_utput mode
{
char output_param = readChar();
if (output_param == 'n') // Calibrate _n_ext sensor
{
curr_calibration_sensor = (curr_calibration_sensor + 1) % 3;
reset_calibration_session_flag = true;
}
else if (output_param == 't') // Output angles as _t_ext
{
output_mode = OUTPUT__MODE_ANGLES;
output_format = OUTPUT__FORMAT_TEXT;
}
else if (output_param == 'b') // Output angles in _b_inary format
{
output_mode = OUTPUT__MODE_ANGLES;
output_format = OUTPUT__FORMAT_BINARY;
}
else if (output_param == 'c') // Go to _c_alibration mode
{
output_mode = OUTPUT__MODE_CALIBRATE_SENSORS;
reset_calibration_session_flag = true;
}
else if (output_param == 's') // Output _s_ensor values
{
char values_param = readChar();
char format_param = readChar();
if (values_param == 'r') // Output _r_aw sensor values
output_mode = OUTPUT__MODE_SENSORS_RAW;
else if (values_param == 'c') // Output _c_alibrated sensor values
output_mode = OUTPUT__MODE_SENSORS_CALIB;
else if (values_param == 'b') // Output _b_oth sensor values (raw and calibrated)
output_mode = OUTPUT__MODE_SENSORS_BOTH;
if (format_param == 't') // Output values as _t_text
output_format = OUTPUT__FORMAT_TEXT;
else if (format_param == 'b') // Output values in _b_inary format
output_format = OUTPUT__FORMAT_BINARY;
}
else if (output_param == '0') // Disable continuous streaming output
{
turn_output_stream_off();
reset_calibration_session_flag = true;
}
else if (output_param == '1') // Enable continuous streaming output
{
reset_calibration_session_flag = true;
turn_output_stream_on();
}
else if (output_param == 'e') // _e_rror output settings
{
char error_param = readChar();
if (error_param == '0') output_errors = false;
else if (error_param == '1') output_errors = true;
else if (error_param == 'c') // get error count
{
Serial.print("#AMG-ERR:");
Serial.print(num_accel_errors);
Serial.print(",");
Serial.print(num_magn_errors);
Serial.print(",");
Serial.println(num_gyro_errors);
}
}
}
#if OUTPUT__HAS_RN_BLUETOOTH == true
// Read messages from bluetooth module
// For this to work, the connect/disconnect message prefix of the module has to be set to "#".
else if (command == 'C') // Bluetooth "#CONNECT" message (does the same as "#o1")
turn_output_stream_on();
else if (command == 'D') // Bluetooth "#DISCONNECT" message (does the same as "#o0")
turn_output_stream_off();
#endif // OUTPUT__HAS_RN_BLUETOOTH == true
}
else
{
} // Skip character
}
// Time to read the sensors again?
if((millis() - timestamp) >= OUTPUT__DATA_INTERVAL)
{
timestamp_old = timestamp;
timestamp = millis();
if (timestamp > timestamp_old)
G_Dt = (float) (timestamp - timestamp_old) / 1000.0f; // Real time of loop run. We use this on the DCM algorithm (gyro integration time)
else G_Dt = 0;
// Update sensor readings
read_sensors();
if (output_mode == OUTPUT__MODE_CALIBRATE_SENSORS) // We're in calibration mode
{
check_reset_calibration_session(); // Check if this session needs a reset
if (output_stream_on || output_single_on) output_calibration(curr_calibration_sensor);
}
else if (output_mode == OUTPUT__MODE_ANGLES) // Output angles
{
// Apply sensor calibration
compensate_sensor_errors();
// Run DCM algorithm
Compass_Heading(); // Calculate magnetic heading
Matrix_update();
Normalize();
Drift_correction();
Euler_angles();
if (output_stream_on || output_single_on) output_angles();
}
else // Output sensor values
{
if (output_stream_on || output_single_on) output_sensors();
}
output_single_on = false;
#if DEBUG__PRINT_LOOP_TIME == true
Serial.print("loop time (ms) = ");
Serial.println(millis() - timestamp);
#endif
}
#if DEBUG__PRINT_LOOP_TIME == true
else
{
Serial.println("waiting...");
}
#endif
}
And well, the code only includes the library which is for I2C communication, but there are 5 more files (.ino which is simply an .cpp) that have few functions being declared.
By just simply trying to compile the code, the following error is given:
Final_arduino_code.ino: In function ‘void read_sensors()’:
Final_arduino_code:427: error: ‘Read_Gyro’ was not declared in this scope
Final_arduino_code:428: error: ‘Read_Accel’ was not declared in this scope
Final_arduino_code:429: error: ‘Read_Magn’ was not declared in this scope
Final_arduino_code.ino: In function ‘void reset_sensor_fusion()’:
Final_arduino_code:450: error: ‘Vector_Cross_Product’ was not declared in this scope
Final_arduino_code:458: error: ‘Compass_Heading’ was not declared in this scope
Final_arduino_code:462: error: ‘init_rotation_matrix’ was not declared in this scope
Final_arduino_code.ino: In function ‘void compensate_sensor_errors()’:
Final_arduino_code:476: error: ‘Matrix_Vector_Multiply’ was not declared in this scope
Final_arduino_code.ino: In function ‘void setup()’:
Final_arduino_code:541: error: ‘I2C_Init’ was not declared in this scope
Final_arduino_code:542: error: ‘Accel_Init’ was not declared in this scope
Final_arduino_code:543: error: ‘Magn_Init’ was not declared in this scope
Final_arduino_code:544: error: ‘Gyro_Init’ was not declared in this scope
Final_arduino_code.ino: In function ‘void loop()’:
Final_arduino_code:675: error: ‘output_calibration’ was not declared in this scope
Final_arduino_code:683: error: ‘Compass_Heading’ was not declared in this scope
Final_arduino_code:684: error: ‘Matrix_update’ was not declared in this scope
Final_arduino_code:685: error: ‘Normalize’ was not declared in this scope
Final_arduino_code:686: error: ‘Drift_correction’ was not declared in this scope
Final_arduino_code:687: error: ‘Euler_angles’ was not declared in this scope
Final_arduino_code:689: error: ‘output_angles’ was not declared in this scope
Final_arduino_code:693: error: ‘output_sensors’ was not declared in this scope
Well, most of those functions have being declared in the other files in the same folder of the this main code, BUT, I have tried making a header (.h) to each of the files, just declaring the functions, it didn't work, I have tried including the files as they are, didn't work, tried to change them to .cpp and including, didn't work.
I posted as an issue to both of the github pages but still got no answer.
Please help me to fix these errors, thanks in advance.
but there are 5 more files (.ino which is simply an .cpp)
It is not that simple, they are not .cpp files. They are supposed to be built with the Ino toolkit, the project's home page is here. Judging from the compiler errors you get, you are not using this toolkit.
The core part that's missing are the .h files that the compiler normally needs to understand what functions like Read_Gyro() look like. Currently the projects you listed have no .h file and no corresponding #include directives. Not actually sure how Ino works but I'd guess it acts like a preprocessor that merges the .ino files into one big ball of source code before letting the compiler lose on it.
Using the toolkit is strongly recommended to get ahead and avoid substantial changes.
As I do not have enough reputation, I'll tell how the Guilherme Garcia da Rosa's answer put me on the right direction.
Unfortunately his contribution appears to be no longer valid with Arduino IDE 1.6.5
I managed to open the project this way :
1- Close Arduino IDE first
2- Create a directory named Final_arduino_code (maybe case sensitive)
3- Open Arduino IDE, and the sketch Final_arduino_code.ino
The IDE will automatically load all files.
The program uploaded successfully for me this way.
The original project owner "Ahmet YILDIRIM" replied to my problem and helped me to compile the project, this was his answer:
You know when you try opening an INO file, Arduino IDE asks you if you
would like to create a new folder for that specific file.
If you click yes, it seperates that file into a new folder.
If I remember correctly you should either press “No” then add other
files as new tabs. If you click “Yes”, then add other files into new
created folder and then open them all in new tabs.
I hope it helps