Go Down

Topic: Deep Think Project - Artificial Intelligence Research Project (Read 23866 times) previous topic - next topic

goodinventor

26 > 8.3, although it cannot be compared with 8.3 in this case because there is no size "8.3" for variables. It must be an integer.

AWOL

Eight-dot-three refers to the DOS filename format supported by the SD library, pointed out in reply #186.

goodinventor

Aha! So my file name needs to be made shorter, right?

goodinventor

Is this what you are talking about? Are there any other issues besides that?

AWOL

Code: [Select]
LogFile = SD.open("Deep_Think_Log_0_0_0_3.txt", FILE_WRITE);
Do the logging after starting the initialisation of the thing you're debugging?
No.
Not clever.

And that filename - you've really not been paying attention, have you?

goodinventor

I'm pretty sure I cannot open a file before the SD card interface is even initialized. Is that correct? I changed the file name to a shorter one: "log.txt".

AWOL

Code: [Select]
// set up DC motors (feet)
  if (MainLeftFoot.SetLeftFootPin(LEFT_FOOT_PIN))
  {
    if (MainRightFoot.SetRightFootPin(RIGHT_FOOT_PIN))
    {
      // set up the arms
      if (MainLeftArm.SetLeftArmPin(LEFT_ARM_PIN))
      {
        if (MainRightArm.SetRightArmPin(RIGHT_ARM_PIN))
        {
          // set up eye
          if (MainEye.SetEyePin(LED_EYE_PIN))
Do the logging after starting the initialisation of the thing you're debugging?

Is that any clearer?

goodinventor

Got it! So I initialize the SD card and open the file before I set up the DC motors in setup().

goodinventor

After doing some research, it appears that my board doesn't write to the SD card because the program built into the Flash never runs. The board automatically tries to boot from the SD card first, so it could be that it is doing nothing because no program is on the SD card and not executing the code on the built-in Flash. I think I can work around this by using ROS, which handles the SD card work for me, in my program. There is a debug message system for use on the SD card and a better solution for encapsulating different parts of the robot. I'll try this and get back to you on how it went.

Thank you,
goodinventor

goodinventor

To simplify things I removed the SD card log calls so I could identify the problem. It seems that the power source I am using (a 9V battery) doesn't supply enough current for my controller, servos, and other electronics. I will see if I can find a power supply that has enough current (I'm thinking 2A at least for everything). Meanwhile I will also work on implementing a basic sensor system and create a simple event-driven program for controlling the servos based on sensor input. For this I will use the ROS API along with my own libraries.

MorganS

This is kind of a big robot isn't it?  2A will only run one or two servos. Add up the power consumption of all your components, add 25% for safety and get a power supply with more amps than that.
"The problem is in the code you didn't post."

goodinventor

I was thinking of 2A as minimal. I prefer 3A at least because I expect to add more stuff in the future. It also wouldn't be a bad idea to reinforce it with some form of renewable energy, such as a solar panel to charge my main battery.

goodinventor

I am working on using ROS to drive the robot, but I have run into one problem. Here is the output generated by the compiler.

Arduino: Coding 211 (Windows 7), Board: "86Duino ONE"

Deep_Think_0_0_0_4.ino:104:1: error: 'LeftFoot' does not name a type
Deep_Think_0_0_0_4.ino:105:1: error: 'RightFoot' does not name a type
Deep_Think_0_0_0_4.ino:106:1: error: 'LeftArm' does not name a type
Deep_Think_0_0_0_4.ino:107:1: error: 'RightArm' does not name a type
Deep_Think_0_0_0_4.ino: In function 'void setup()':
Deep_Think_0_0_0_4.ino:122:7: error: 'MainLeftFoot' was not declared in this scope
Deep_Think_0_0_0_4.ino:124:9: error: 'MainRightFoot' was not declared in this scope
Deep_Think_0_0_0_4.ino:127:11: error: 'MainLeftArm' was not declared in this scope
Deep_Think_0_0_0_4.ino:129:13: error: 'MainRightArm' was not declared in this scope
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Attached are the files. I did not have this problem last time, so what do you think is wrong? For adding these libraries I used "New Tab" in the IDE.

goodinventor

I have recently started working on the machine learning part of the software. I am using a basic logistic regression algorithm for now. I compiled and loaded the program successfully (see below), but I get no output. After looking over it myself, I could not figure out why there was no output shown, so I am posting it here in hopes that a second pair of eyes (or even more) can point out to me the problem. For your information, no outputs are used except the Serial (for the Serial monitor only), so you should be able to run this program on most Arduino and Arduino-compatible boards. Thank you all!

Code: [Select]

//
// Deep Think 0.0.0.5
//
// programmed by George Andrews
//
// NOTE: This program is designed for the Meccanoid G15 (combined
// with the 86Duino One). It is a part of the Deep Think Project
// (first version of the software for the project). The Deep Think
// Project is designed to advance the intelligence (as well as
// motion and structural capabilities) of humanoid robots. This
// version of the program is designed to do the following.
//
// 1. Implement a basic deep learning algorithm (created by the
//    programmer) to choose what course of action to take (a
//    limited number of options).
// 2. Implement a basic system for conversation via the Serial port
//    (this means the robot generates output in response to the
//    user's input).
//
// This version of the program starts dealing with a different
// problem than the previous versions. It handles the
// intelligence aspect of the robot rather than the motors and
// sensors. Later versions will incorporate both once the
// intelligence capabilities have matured. I expect this will be a
// valuable learning process that will help the project succeed in
// the future.
//

//
// Preprocessor Section
//

//
// Let the file be included only once in compilation.
//
#pragma once

//
// Makes sure the appropriate compiler is being used.
//
#ifndef __cplusplus
  #error "A C++ compiler is required."
#endif

//
// Makes sure the appropriate Arduino header is included.
//
#if (ARDUINO >= 100)
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

//
// The other necessary headers are included here.
//
#include <vector>

//
// Namespaces
//
using namespace std;

//
// Classes
//

class Node
{
  public:
    //
    // This is the training set for use of the algorithm. It contains
    // the y values for every integer value of x (starting with 1 and
    // going on up).
    //
    vector<float> TrainingSet;
       
    //
    // The output set for the cost function values.
    //
    vector<float> CostFunctionOutputSet;
   
    //
    // Loads the training data set.
    //
    void LoadTrainingSet()
    {
      TrainingSet.push_back(1.0);
      TrainingSet.push_back(1.1);
      TrainingSet.push_back(1.3);
      TrainingSet.push_back(1.3);
      TrainingSet.push_back(1.4);
    }
   
    vector<float> CalculateCostFunction(vector<float> training_set)
    {
      //
      // Creates containers for place of the next y value element,
      // the x value, and the y value.
      //
      int y_element = 1;
      float x_value = 1.0;
      float y_value = training_set.at(y_element);
     
      //
      // Loops through and calculates the cost function for the values
      // in the training set.
      //
      for (x_value = 0.0; x_value <= 1.4; x_value += 0.1)
      {
        //
        // Create a value for the sum to update the cost function value
        // for each successive x value.
        //
        float CurrentSumCostFunctionValue = 0;
       
        //
        // Here is the formula for evaluating the cost function value.
        //
        float CostFunctionValue = (1 / (2 * training_set.size())) * (pow(2 * x_value - y_value, 2));
       
        //
        // Update the sum here.
        //
        CurrentSumCostFunctionValue += CostFunctionValue;
       
        //
        // Add an element to the output vector which contains the updated
        // sum value. These values will show how each successive iteration
        // of the algorithm (logistic regression in this case) will affect
        // the  progress of the learning.
        //
        CostFunctionOutputSet.push_back(CurrentSumCostFunctionValue);
      }
    }
};

//
// Class Objects
//

//
// Create a Node class object here.
//
Node *MyNode;

void setup()
{
  Serial.begin(9600);
 
  //
  // Here is our x value which will be updated to create a table
  // of values later.
  //
  float OutputTableXValue = 0;
 
  Serial.println("x Value   Cost Value");
  delay(100);
 
  //
  // Now print the contents of the output vector for analysis.
  //
  for (vector<float>::const_iterator i = MyNode->CostFunctionOutputSet.begin(); i != MyNode->CostFunctionOutputSet.end(); ++i)
  {
    Serial.print(OutputTableXValue);
    delay(100);
    Serial.print("       ");
    delay(100);
    Serial.print(*i);
    delay(100);
  }
}

void loop()
{
}


Regards,
goodinventor

pert

I couldn't test it because "fatal error: vector: No such file or directory" but I'd just start commenting things out until it starts working and then add things back in until you find out what is causing the problem.

Go Up