Page 1 of 1

SOLVED: Navigation (gyro and accelerometer) not working?

Posted: Mon Feb 12, 2018 1:38 am
by gpvillamil
Apparently you need to call the NavigationXY() or SimpleNavigation() functions to update the accelerometer and gyro functions.

==============================================

I'm trying the accelerometer and gyro functions in the Navigation tab, and it seems to not be working.

While running the sketch I moved Spirit in all axes. An equivalent sketch on an Arduino with an accelerometer generated very clear changes in values.

I've included the NavigationBegin() function as specified in the Ringo documentation. Not sure what is wrong here.

Here's the output:

Code: Select all

Heading: 0 Acc X: 0 Acc Y: 0 Acc Z: 0
Heading: 0 Acc X: 0 Acc Y: 0 Acc Z: 0
Heading: 0 Acc X: 0 Acc Y: 0 Acc Z: 0
...


and here is the sketch:

Code: Select all


/*

Spirit Rover Robot
Spirit_BaseSketch_Rev01
Version 1.1 10/2017

Significant portions of this code written by
Dustin Soodak for Plum Geek LLC. Some portions
contributed by Kevin King.
Portions from other open source projects where noted.
This code is licensed under:
Creative Commons Attribution-ShareAlike 2.0 Generic (CC BY-SA 2.0)
https://creativecommons.org/licenses/by-sa/2.0/
Visit http://www.plumgeek.com for PiSpirit information.
Visit http://www.arduino.cc to learn about the Arduino.

*/

#include "Hardware.h"

void setup(){

  // ************ THE SETUP ITEMS BELOW SHOULD GENERALLY BE USED FOR ALL SPIRIT SKETCHES **************
 
  hardwareBegin();                    //initialize Spirit's Arduino processor to work with his circuitry
  SPI_Reset();                        //resets and turns on the SPI port
  playStartChirp();                   //Play startup chirp and blink eyes
  servoCenters();                     //Place all servos back in default position
 
  // ************ THE SETUP ITEMS BELOW CAN BE CUSTOMIZED FOR YOUR SPECIFIC SPIRIT SKETCH **************


  // add your own setup code here

NavigationBegin();

    Serial.begin(57600);   
}


void loop(){

  // add your own loop code here
 
  Serial.print("Heading: ");
  Serial.print(GetDegrees());
  // Serial.print(PresentHeading());
  // Serial.print(GyroRawToDegrees(GyroPosition[0]));
  Serial.print(" Acc X: ");
  Serial.print(GetAccelerationX());
  Serial.print(" Acc Y: ");
  Serial.print(GetAccelerationY()); 
  Serial.print(" Acc Z: ");
  Serial.println(GetAccelerationZ());
  delay(1000);

} // end of loop() function


Re: SOLVED: Navigation (gyro and accelerometer) not working?

Posted: Fri Feb 16, 2018 4:45 am
by gpvillamil
This code does seem to work now.

It returns heading + acceleration in X, Y, Z and then rotates the rover back & forth 90 degrees. It's not super accurate, but is not bad. The MoveWithOptions() function seems to use the gyro, so calling that function with the current heading as the intended heading will keep the rover moving in a straight line.

Code: Select all

#include "Hardware.h"

void setup(){

  // ************ THE SETUP ITEMS BELOW SHOULD GENERALLY BE USED FOR ALL SPIRIT SKETCHES **************
 
  hardwareBegin();                    //initialize Spirit's Arduino processor to work with his circuitry
  SPI_Reset();                        //resets and turns on the SPI port
  playStartChirp();                   //Play startup chirp and blink eyes
  servoCenters();                     //Place all servos back in default position
 
  // ************ THE SETUP ITEMS BELOW CAN BE CUSTOMIZED FOR YOUR SPECIFIC SPIRIT SKETCH **************


  // add your own setup code here

NavigationBegin();
Serial.begin(57600);   
}


void loop(){

  // add your own loop code here

  NavigationXY(70,200); // apparently need to call this periodically
 
  Serial.print("Heading: ");
  Serial.print(GetDegrees());
  // Serial.print(PresentHeading());
  // Serial.print(GyroRawToDegrees(GyroPosition[0]));
  Serial.print(" Acc X: ");
  Serial.print(GetAccelerationX());
  Serial.print(" Acc Y: ");
  Serial.print(GetAccelerationY()); 
  Serial.print(" Acc Z: ");
  Serial.println(GetAccelerationZ());

  RotateAccurate(90,2000);

RotateAccurate(-90,2000);

} // end of loop() function

Re: SOLVED: Navigation (gyro and accelerometer) not working?

Posted: Fri Feb 16, 2018 4:42 pm
by Kevin
Thanks for posting that gp. I appreciate your help on this! :)

Re: SOLVED: Navigation (gyro and accelerometer) not working?

Posted: Sun Mar 18, 2018 6:15 pm
by headamage
Kevin wrote:Thanks for posting that gp. I appreciate your help on this! :)

is this currently exposed to raspberry pi and supported in the python scripts?
I would love to add this to my cloud robotics code.

SOLVED Navigation gyro and accelerometer not working

Posted: Wed Sep 19, 2018 8:51 pm
by KSenijawib
Do I need to make any other changes?

It seems after changing the directadmin port number the self-signed ssl not working?