slower nrf data rate

This commit is contained in:
interfisch 2019-03-17 20:09:57 +01:00
parent e73c0bc69c
commit 719b0fa7c5
1 changed files with 7 additions and 4 deletions

View File

@ -96,6 +96,7 @@ void setup() {
radio.begin(); radio.begin();
radio.setDataRate( RF24_250KBPS ); //set to slow data rate. default was 1MBPS
radio.setRetries(15,15); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); // optionally, increase the delay between retries & # of retries
radio.setPayloadSize(8); // optionally, reduce the payload size. seems to improve reliability radio.setPayloadSize(8); // optionally, reduce the payload size. seems to improve reliability
@ -166,13 +167,14 @@ void loop() {
//y positive = forward //y positive = forward
//x positive = right //x positive = right
/*
setYaw+=((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*10/127; setYaw+=((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*10/127;
while (setYaw<0){ while (setYaw<0){
setYaw+=360; setYaw+=360;
} }
while (setYaw>=360){ while (setYaw>=360){
setYaw-=360; setYaw-=360;
} }*/
/* /*
Serial.print("setYaw="); Serial.print("setYaw=");
@ -190,9 +192,9 @@ void loop() {
//out_speed=(int16_t)( (lastnrfdata.y-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX ); //out_speed=(int16_t)( (lastnrfdata.y-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX );
//out_steer=(int16_t)( -(lastnrfdata.x-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX ); //out_steer=(int16_t)( -(lastnrfdata.x-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX );
out_speed=(int16_t)( ((int16_t)(lastnrfdata.speed)-NRFDATA_CENTER)*1000/127 ); //-1000 to 1000 out_speed=(int16_t)( ((int16_t)(lastnrfdata.speed)-NRFDATA_CENTER)*1000/127 ); //-1000 to 1000
//out_steer=(int16_t)( ((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*1000/127 ); out_steer=(int16_t)( ((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*1000/127 );
//Test Mag //Test Mag
double yawdiff=(setYaw-180)-(yaw-180); //following angle difference works only for angles [-180,180]. yaw here is [0,360] /*double yawdiff=(setYaw-180)-(yaw-180); //following angle difference works only for angles [-180,180]. yaw here is [0,360]
yawdiff += (yawdiff>180) ? -360 : (yawdiff<-180) ? 360 : 0; yawdiff += (yawdiff>180) ? -360 : (yawdiff<-180) ? 360 : 0;
//yawdiff/=2; //yawdiff/=2;
int yawdiffsign=1; int yawdiffsign=1;
@ -204,6 +206,7 @@ void loop() {
yawdiff*=yawdiffsign; //redo sign yawdiff*=yawdiffsign; //redo sign
out_steer=(int16_t)( yawdiff ); out_steer=(int16_t)( yawdiff );
*/
/* /*
Serial.print("Out steer="); Serial.print("Out steer=");
Serial.println(out_steer);*/ Serial.println(out_steer);*/