Close

RF capability actual first success

A project log for Quadruped learning project

Quadruped robot learning.

tsmspacetsmspace 01/23/2017 at 05:400 Comments

This log is to describe my first experiment related RF capability success.

I have managed to mostly replicate the success from my previous 3 joystick axis, 3 servo, xyz coordinate kinematics engine experiment,,, onto a wireless controller to servo driver rig.

I used the nrf24L01 module, which I suppose is the cheapest module that will easily send full interger values within the library support. (it is possible to send interger values using the cheap rf links, but not using the libraries simple commands,, it IS possible to use these easy commands with the nrf24L01).

This module is incidentally the same as the one on the Sunfounder quadruped, (I sent one of those to my dad, and studied it a little, I may buy one for myself but will wait until I have mine working,, I think that custom programming on that robot is much more difficult because of the limited equipment add-on capability,, although the sunfounder quadruped is much more well engineered set of legs than my robot will have).

My current experiment still has some issues that need to be addressed before I start playing with my little plastic robot. The leg still tries to reach where it can't for at least ONE reason, but I think more,, sometimes the kinematics engine assigns a "nan" value to the servos, and sometimes it just gets barky and I don't know exactly why, but usually towards an extreme reach. The rate of change in xyz is much to rapid, I need to tone it down. The z axis is still inverted. The leg itself is probably not exactly as my measurements suggest, resulting in some movements that don't really make the straight lines I want them too,,, and one more thing,, I think that the joysticks need to be somehow isolated from eachother's voltage inputs, because it still seems like moving x can move y when it shouldn't be. This is a hardware fix, probably using resistors, but I probably won't do anything about that sort of engineering during these phases of my experimentation.

I will post my demonstration video at the bottom, it's hard to perceive that I am trying to drive the foot in straight lines to show that the legs are bending to allow straight foot motion, but it doesn't show that well, and it doesn't show to me when I'm sitting right here either,, but I am absolutely confident that it IS doing it to some degree, so I will still post the video.

please excuse my ranting about wizards and their hands in my activity, I don't appreciate it when people affect my material and act like they aren't up to it,, but there's just nothing I can do to control my area, I don't have that kind of power. I basically can only watch it happen.

here are my two codes for this experiment.

transmit side

#include<SPI.h>

#include<RF24.h>

#define joyStick_x A0

#define joyStick_y A1

#define joyStick_z A2

RF24 radio (7,8);

byte addresses [][6] = {"1Node","2Node"};

struct dataStruct {

int Xposition;

int Yposition;

int Zposition;

} myData;

void setup() {

// put your setup code here, to run once:

Serial.begin(115200);

radio.begin();

radio.setChannel(108);

radio.setDataRate(RF24_250KBPS);

radio.setPALevel(RF24_PA_LOW);

radio.openWritingPipe(addresses[0]);

radio.openReadingPipe(1, addresses[1]);

radio.startListening();

}

void loop() {

// put your main code here, to run repeatedly:

radio.stopListening();

myData.Xposition = analogRead(joyStick_x);

myData.Yposition = analogRead(joyStick_y);

myData.Zposition = analogRead(joyStick_z);

Serial.println(myData.Xposition);

radio.write(&myData, sizeof(myData));

radio.startListening();

}

--------------------------------------------------------------------------------------------------------

receive side

#include <SPI.h>

#include "RF24.h"

#include <SoftwareServo.h>

float hipServo = 30;

float femur = 100;

float tibia = 90;

float coxaout = 40;

float coxaback = 10;

float coxadown = 30;

float L;

float A;

float B;

float G1;

float G;

float D;

float D2;

float x = 90;

float y = 0;

float z = 0;

RF24 radio (7,8);

SoftwareServo HipRotate;

SoftwareServo HipBend;

SoftwareServo KneeBend;

byte addresses[][6] = {"1Node","2Node"};

int XJoystick;

int YJoystick;

int ZJoystick;

struct dataStruct {

int Xposition;

int Yposition;

int Zposition;

} myData;

void setup() {

// put your setup code here, to run once:

Serial.begin(115200);

HipRotate.attach(3);

HipBend.attach(5);

KneeBend.attach(6);

radio.begin();

radio.setChannel(108);

radio.setDataRate(RF24_250KBPS);

radio.setPALevel(RF24_PA_LOW);

radio.openWritingPipe(addresses[1]);

radio.openReadingPipe(1, addresses[0]);

radio.startListening();

}

void loop() {

// put your main code here, to run repeatedly:

if (radio.available()){

while(radio.available()){

radio.read(&myData, sizeof(myData) );

}

}

Serial.println (myData.Xposition);

SoftwareServo::refresh();

XJoystick=myData.Xposition;

YJoystick=myData.Yposition;

ZJoystick=myData.Zposition;

Serial.print(XJoystick);Serial.println(" ");

int xShift = map(XJoystick, 0, 1023, -10, 10);

int yShift = map(YJoystick, 0, 1023, -10, 10);

int zShift = map(ZJoystick, 0, 1023, -10, 10);

if (xShift == -1 || zShift == 1) xShift = 0;

if (yShift == -1 || yShift == -1) yShift = 0;

if (zShift == -1 || zShift == -1) zShift = 0;

x = x + xShift; y = y + yShift; z = z + zShift;

Serial.print("x: "); Serial.print(x);Serial.print(" y: "); Serial.print(y); Serial.print (" z: ");Serial.println(z);

if (x >=180) x = 180; if (x <= 0) x = 0;

if (y >= 180) y = 180; if (y <= -180) y = -180;

if (z >= 160) z = 160; if (z <= -200) z = -200;

G1 = atan(x/y) ;

float G2 = degrees (G1);

if (G2 <= 0) {G2 = 180 + G2;}

D = sqrt ((x*x) + (y*y));

D2 = sqrt (((D+coxaback)*(D+coxaback))+(coxaout*coxaout));

L = sqrt((D2*D2)+((z+coxadown)*(z+coxadown)));

A = acos(((femur*femur)+(tibia*tibia)-(L*L))/(2*femur*tibia));

B = (acos(((femur*femur)+(L*L)-(tibia*tibia))/(2*femur*L))+acos(((L*L)+((z+coxadown)*(z+coxadown))-(D2*D2))/(2*L*(z+coxadown))));

Serial.print ("G2: "); Serial.print(G2); Serial.print(" B: ");Serial.print(degrees(B));Serial.print(" A: ");Serial.println(degrees(A));

HipRotate.write(G2);

HipBend.write(degrees(B));

KneeBend.write(degrees(A));

}


Discussions