now why cant i get more than xx.xx is it because of the float > byte > float conversion?
now why cant i get more than xx.xx is it because of the float > byte > float conversion?
Not at all. It is because the Serial.print() function defaults to printing only 2 digits after the decimal place.
Try
Serial.print(inRollrf.imuRoll, 47);
and see what happens.
Also think about whether you are actually able to measure pitch, roll, and yaw to more than 2 decimal places.
more to the point i asked my self if i WANT that much precision and i found i told my self to kiss off. ]
that said xx.xx is juuuust fine. now i just need to transmit this heap of wholesome goodness
$GPRMC,140053.00,A,4454.1740,N,09325.0143,W,000.0,128.7,300508,001.1,E,A*2E
$GPGGA,140053.00,4454.1740,N,09325.0143,W,1,09,01.1,00289.8,M,-030.7,M,,*5E
$GPGSA,A,3,21,15,18,24,26,29,06,22,,03,,,02.0,01.1,01.7*04
$GPGSV,3,1,12,21,75,306,40,15,59,075,46,18,57,269,49,24,56,115,46*79
$GPGSV,3,2,12,26,48,059,43,29,27,188,48,06,25,308,41,22,18,257,33*7D
$GPGSV,3,3,12,08,14,060,,03,11,320,32,09,06,144,,16,04,311,*7C
$GPRMC,140054.00,A,4454.1740,N,09325.0143,W,000.0,128.7,300508,001.1,E,A*29
$GPGGA,140054.00,4454.1740,N,09325.0143,W,1,09,01.1,00289.8,M,-030.7,M,,*59
$GPGSA,A,3,21,15,18,24,26,29,06,22,,03,,,02.0,01.1,01.7*04
$GPGSV,3,1,12,21,75,306,40,15,59,075,46,18,57,269,49,24,56,115,46*79
$GPGSV,3,2,12,26,48,059,43,29,27,188,48,06,25,308,41,22,18,257,33*7D
$GPGSV,3,3,12,08,14,060,,03,11,320,32,09,06,144,,16,04,311,*7C
Hmmm let's see if me missed anything.. floats/doubles check, chars and ints yup got plenty of those and most of shift + 1-9 yup got me some of those in spades. yeah there so has to be a better way of cramming that into the NRF FIFO and sucking it back out on the other end. please tell me there is PaulS please? ![]()
floats/doubles check, chars and ints yup got plenty of those
floats/doubles? Not a single one in sight. Chars? Plenty of those. Fortunately, they are the same size as bytes. Ints? Not a one of those in sight.
What is the problem with using Mirf.send()?
4454.1740, 09325.0143, -030.7 not a float because of the decimal point? i was under the impression arduino stored numbers as integers?
4454.1740, 09325.0143, -030.7 not a float because of the decimal point? i was under the impression arduino stored numbers as integers?
4454.1740 could be a float. The stuff you posted, though, looks like data received from a GPS. Unless you have a really off-the-wall GPS, the data that it sends to the Arduino is character data. There is no indication that you have parsed that data to make floats and doubles from it, nor is there any indication that the device that receives the data from the GPS should parse it.
yes it's a GPS Locosys LS20031 it's a serial ( yes i just realised what i just said) so because it comes in serial it's not a float? if so what makes a float a float?
is it not till it's in a calculation like 2.32 * 2 = float * int and 2.32 by it's self is just a num period num num char string?
gunna laugh alot in a min if i find out that is true. if so why did i need to store my roll pitch yaw as floats and not chars?
because it comes in serial it's not a float?
No, it's because the data is sent as characters, not floats.
if so what makes a float a float?
Declaring a variable as the correct type.
is it not till it's in a calculation like 2.32 * 2 = float * int and 2.32 by it's self is just a num period num num char string?
No. There are functions like atoi() and atof() to turn arrays of characters into ints and floats.
if so why did i need to store my roll pitch yaw as floats and not chars?
Because you have that data AS floats, not characters. You could convert the float to an array of characters, using dtostrf(), and send that array of characters. On the other end, you'd need to use atof() to convert the characters back to a float.
Sending more than one float that way becomes a challenge, because where one value as string ends and other value as string starts is an issue. Also, it takes time to convert from float to string and from string to float. And, finally, a float as 4 bytes is smaller than a float as a character string, so it takes less time to send (and is more accurate, since no translations have occurred).
i get it. so the incoming NMEA GPS data is char and given the amount of it i dont think i would want to make an array for it or i would eat up loads of memory correct?
i would love to clock the data in at like 3 or 4 sec intervals local on the bot and toss it out ( GPS not being that precise, mine seems to be off here and there by about 1.2metersish) .
Is there any efficent wat of packing up the full NEMA set and sending or should i just "streem" it one by one across the radios like it comes in from serial.
i think i would need to convert from char to byte befor Mirf will eat it and crap it out the other end yes/no?.
geting a sentence is easy gps.sentence() and a initialize NMEA gps (type) ALL or GPRMC or any of the standard NEMA.
i remember you said before something about a lying to mirf about the real type the data was?
i think i would need to convert from char to byte befor Mirf will eat it and crap it out the other end yes/no?.
No. char and byte are the same size. You just tell Mirf that the char array is really a byte array.
Mirf.send((byte *)gps_data, strlen(gps_data));
Assuming, of course, that gps_data is a char array and contains the data from the GPS.
so i make a char array for incoming GPS data stuff the array and refer to it as a byte array?
(byte *)gps_data, [gps_data]that is realy a char array and (byte *) says hey hop in there and pull the value because we are the same size anyhow?
strlen(gps_data) is something like sizeof() but it's get the string gps_data that is size of gps_data? or is the lack of sleep catching up now? lol
so i make a char array for incoming GPS data stuff the array and refer to it as a byte array?
Not "refer to it as", but "tell Mirf that it is".
(byte *)gps_data, [gps_data]that is realy a char array and (byte *) says hey hop in there and pull the value because we are the same size anyhow?
Something like that.
strlen(gps_data) is something like sizeof() but it's get the string gps_data that is size of gps_data?
It gets the number of characters in the array, up to the terminating NULL. It does not "get the string".
great so step one char array of size to fit a gps.sentance in fill it call it with a (byte *) call, get it's count with strln() "string length?" transmit refill the array and repeat till all the NEMA is sent.
sound like i missed anything?
great so step one char array of size to fit a gps.sentance in
Yes.
fill it
Yes.
call it with a (byte *) call,
No. You don't call an array. You call a function, like Mirf.send().
get it's count with strln()
Well, strlen() will produce fewer errors...
sound like i missed anything?
Capital letters, punctuation, sleep, and probably some other stuff. ![]()
Welp can check "some" sleep of the list :). anyhow im feeling a bit dorky more than usual i cant seem to grasp how to stuff gps.sentence into an array or some buffer.
gps.sentence returns a string with \0 terminate as a char * ( char ptr?).
so i keep getting invalid conversions from char* to char errors. so am i to understand i am dealing with output from gps.sentence that is in the form of a char ptr and need to (read) it some how into some string then convert the string into regular char array?. as im typing this i can hear your groan as you ask "does this guy like over complicating things a little?".
because i know your going to go NO you just need to reference some ptr and read the individual chars and put them into your array. or not LOL.
i just know i am gonna love your reply i just know it!
BTW thank you so much for all the help i have been learning so much from your guidance.
gps.sentence returns a string with \0 terminate as a char * ( char ptr?).
So:
char *gps_data = gps.sentence();
Mirf.send((byte *)gps_data, strlen(gps_data));
gps_data IS a string. No need to copy it anywhere else or try to "read it to a string".
"does this guy like over complicating things a little?".
I wasn't think that at all. I was thinking "a lot". 8)
PaulS:
gps.sentence returns a string with \0 terminate as a char * ( char ptr?).
So:
char *gps_data = gps.sentence();
Mirf.send((byte *)gps_data, strlen(gps_data));
gps_data IS a string. No need to copy it anywhere else or try to "read it to a string". > "does this guy like over complicating things a little?". I wasn't think that at all. I was thinking "a lot". 8) LOL. hard to believe. anyhow thanks for the help so far. but since i went and mucked around anyhow can you tell my why the output of this is always this outputgpsS Array contains: ««««
code#include <nmea.h>
NMEA gps(ALL); // GPS data connection to all sentence types
char* gpsS[76];
void setup() {
Serial.begin(57600);
Serial2.begin(57600);
}
void loop() {
if (Serial2.available() > 0 ) {
if (gps.decode(Serial2.read())) {
for (int i = 0; i < 76; i++){
gpsS[i] = gps.sentence();
delay(500);
}
}
}
Serial.print("gpsS Array contains: ");
Serial.print(gpsS[0]);
Serial.print(gpsS[1]);
Serial.print(gpsS[2]);
Serial.print(gpsS[3]);
Serial.println();
// serial monitor spits out.... gpsS Array contains: ««««
}
TX
void loop() {
char *gps_data = gps.sentence();
if (Serial2.available() > 0 ) {
// read incoming character from GPS and feed it to NMEA type object
if (gps.decode(Serial2.read())) {
Mirf.setTADDR((byte *)"base1"); // set name of Reciever
char *gps_data = gps.sentence();
Mirf.send((byte *)gps_data);
while(Mirf.isSending()){
Serial.println("send GPS DAta");
Serial.println(gps_data);
}
delay(10);
}
}
}
Serial.print output on TX side
$GPGLL,4328.5356,N,07625.7447,W,015842.800,A,D*42
send GPS DAta
$GPGSV,3,2,11,46,38,210,32,06,26,159,,20,25,242,19,13,24,313,*70
send GPS DAta
$GPGSV,3,3,11,32,23,216,,29,17,043,20,03,15,178,*4D
send GPS DAta
$GPGGA,015843.000,4328.5356,N,07625.7447,W,2,5,3.72,124.2,M,-34.2,M,0000,0000*66
send GPS DAta
$GPGLL,4328.5356,N,07625.7447,W,015843.000,A,D*4B
send GPS DAta
$GPGSV,3,2,11,46,38,210,32,06,26,159,,20,25,242,19,13,24,313,*70
send GPS DAta
$GPGSV,3,3,11,32,23,216,,29,17,043,20,03,15,178,*4D
seems to be working fine.
on the RX side however
RX
void loop(){
byte inData[Mirf.payload];
if(Mirf.dataReady()){
do{
Mirf.getData(inData);
byte* gps_data = inData;
Serial.println(*gps_data);
delay(10);
}
while(!Mirf.rxFifoEmpty());
}
}
Serial output is.
im assuming that it's coming in fine but my method of extracting chars from data ( is byte at this time)
36
36
36
36
36
im guessing it's this byte* gps_data = inData; i though sense inData is coming in as bytes that i needed to reference gps_data as pointer to bytes and print it anyhow as a char?
if into Mirf like this
char *gps_data = gps.sentence();
Mirf.send((byte *)gps_data);
then should not out of Mirf like this
Mirf.getData(inData);
char gps_data = *inData;
Serial.println(gps_data);
it does print the first char a $ to the serial but that's it. or is it some kind of an array in inData like inData[sizeof(payload)] kind of deal and i need to scan the with of inData the size of payload and pull each char?
well got the first 6 anyhow
char inGPS[27];
byte inData[Mirf.payload];
if(Mirf.dataReady()){
do{
Mirf.getData(inData);
inGPS[0] = inData[0];
inGPS[1] = inData[1];
inGPS[2] = inData[2];
inGPS[3] = inData[3];
inGPS[4] = inData[4];
inGPS[6] = inData[5];
inGPS[7] = inData[6];
inGPS[8] = inData[7];
inGPS[9] = inData[8];
inGPS[10] = inData[9];
inGPS[11] = inData[10];
inGPS[12] = inData[11];
inGPS[12] = inData[12];
inGPS[13] = inData[13];
inGPS[14] = inData[14];
inGPS[15] = inData[15];
inGPS[16] = inData[16];
inGPS[17] = inData[17];
inGPS[18] = inData[18];
inGPS[19] = inData[19];
inGPS[10] = inData[20];
inGPS[21] = inData[21];
inGPS[22] = inData[22];
inGPS[23] = inData[23];
inGPS[24] = inData[24];
inGPS[25] = inData[25];
inGPS[26] = inData[26];
//char gps_data = *inData;
for (int i = 0; i < 27; i++) {
Serial.print(inGPS[i]);
spits out $GPVT amd $GPRMC etc and some other junk i cant even copy LOL much lest paste.
so inData is an array of incoming bytes = to playload size?