Comments (14)
Very nice!
Did you add the new fix pieces to GPSfix.h
? The above code seems to show that they are GPS_FIX options (in GPSfix_cfg.h
) and are part of m_fix
(fromGPSfix.h
).
If you want the example programs (or your modded versions) to print them from Streamers.h
, it's just a matter of picking where you want them to appear in the CSV line. You will need #ifdef
sections in the header string (line 24+).
You also need a new #ifdef
section in operator <<
(line 134+), in both the FLOAT and NOT FLOAT sections. Be careful not to use float
in the NOT FLOAT section.
In your sketch, you should be able to use those new members if they are declared in GPSfix.h
and enabled in GPSfix_cfg.h
.
from neogps.
I don't need to add anything in
Streamers.h
(¿?)
Correct. The modifications to Streamers.cpp
look correct.
gps_fix::valid_t has no member named 'distance' if (fix.valid.distance)
There is a structure in GPSfix.h
(valid_t
on line 248) that contains all the valid flags. You need to add one new bool
for each piece you want to mark as valid or invalid. Use the same names you used in parseNavODO
.
If I change the name
What name?
You may need to review which UBX sentence arrives last in each interval, in ubx_cfg.h
. Your new sentences can affect this choice.
nothing displays, only
acquiring...
If you look at ublox.ino
, you'll see that it needs to receive a few sentences before it will ask for locations (line 80). If your sketch is based off of that, make sure you are still requesting those sentences. That message means that it is waiting for a STATUS message. Make sure UBLOX_PARSE_STATUS
is enabled in ubx_cfg.h
. If it is, you might check the return value at line 130:
if (requestNavStatus) {
// Turn on the UBX status message
if (!enable_msg( ublox::UBX_NAV, ublox::UBX_NAV_STATUS ))
DEBUG_PORT.println( F("enable STATUS failed!") );
}
from neogps.
I had some problems, mainly, with #define UBX_LAST_MSG_CLASS_IN_INTERVAL ublox::UBX_HNR.
ok.
If last message is UBX_NAV goes blank data (but received ok).
I don't understand "goes blank data (but received ok)."
Also I have used the same GPSfix defines with the same instructions, per example, GPS_FIX_DATE from NAV-TIMEUTC is invalidated by GPS_FIX_DATE from HNR-PVT.
Yes, any part of a fix can be invalidated/validated multiple times. This happens when the same fix member is in two different messages.
With this I have more info with less messages ( I think).
I'm not sure.
I need to redirect Streamers trace_all() function into my sketch (I will show distance in SSD1306 oled display)
Not usually. The Streamers functions are just for displaying the CSV format lines:
3,2016-05-24 01:21:29.00,472852332,85652650,,138,,,1,0,66,
Is that what you want to see on the display?
If not, just print the pieces you want. Don't use the Streamers functions. Tabular.ino
, NMEAloc.ino
and NMEAsimple.ino
do not use Streamers functions. All of the pieces in the fix (see Data Model page) can be printed to the display. Just set the cursor position and print one piece.
from neogps.
Do not use gps.fix()
, because it changes as characters are received. You should just use the fix
structure returned from gps.read()
:
while (gps.available( gps_port )){
//trace_all( DEBUG_PORT, gps, gps.read() );
gps_fix fix = gps.read();
if (fix.valid.distance){
DEBUG_PORT.print(fix.distance);
DEBUG_PORT.print(fix.speed3D);
DEBUG_PORT.println(fix.timeNano);
}
I had disabled all messages except NAV-ODO and HNR-PVT, and your example sketch needs NAV-STA to start (I think) sending messages. The last question is how can I disable/change NAV-STA by another (example NAV-ODO) to start? (I don't need NAV-STA because HNR-PVT send me the status values)
The method get_status
requests the NAV-STA message here:
void get_status()
{
static bool acquiring = false;
if (fix().status == gps_fix::STATUS_NONE) {
...
if (requestNavStatus)
// Turn on the UBX status message
enable_msg( ublox::UBX_NAV, ublox::UBX_NAV_STATUS );
When it finally receives that message, it doesn't turn it off, but you could:
} else {
if (acquiring)
DEBUG_PORT << '\n';
DEBUG_PORT << F("Acquired status: ") << (uint8_t) fix().status << '\n';
disable_msg( ublox::UBX_NAV, ublox::UBX_NAV_STATUS );
Then it asks for TIMEGPS and TIMEUTC, and then calls start_running
. That is where you would enable the HNR-PVT. I don't think I would use the HNR-PVT to get the status during start-up (get_status
). You could, but you have to be careful not to use the time members without knowing leap seconds and UTC-to-TOW (time of week).
I just realized that ublox.ino uses fix()
during start-up instead of reading a fix structure. This is not safe, so I need to update that start-up sequence: get_status
, get_leap_seconds
and get_utc
need to change.
from neogps.
Ah, I just noticed how you were accumulating 32-bit values:
#ifdef GPS_FIX_ODO_TOTAL_DISTANCE
case 12: case 13: case 14: case 15:
NMEAGPS_INVALIDATE( total_distance );
((uint32_t *)&m_fix.total_distance) [ chrCount-12] = chr;
m_fix.valid.total_distance = true;
break;
#endif
That invalidates and validates on every character. Instead, you need to invalidate on the first character (chrCount == 12) and validate on the last character (chrCount == 15):
#ifdef GPS_FIX_ODO_TOTAL_DISTANCE
case 12:
NMEAGPS_INVALIDATE( total_distance );
case 13: case 14: case 15:
((uint32_t *)&m_fix.total_distance) [ chrCount-12] = chr;
if (chrCount == 15)
m_fix.valid.total_distance = true;
break;
#endif
Do this for all 3 multi-byte pieces. This does not explain why total_distance
is always <= 255. This could be a memory corruption. You don't have any *_cfg files in the sketch directory, do you?
Are you using the nav_dop_t
structure I defined in ubxGPS.h
?
from neogps.
Yes, that's it.
((uint8_t *)&m_fix.spd) [ chrCount-20 ] = chr;
That assignment statement:
-
Takes the address of the member (a 32-bit int or whatever) with the
&
operator ("address-of"). That's the RAM location of the bytes for that member. The&
operator returns a pointer of typeuint32_t *
, the address of a uint32_t. -
The
(uint8_t *)
converts (i.e. casts) that pointer to a pointer-to-byte, not a long. -
The
[ n ]
array index uses the pointer as the starting address of an array, and returns the nth element of that array. It steps through the array by the number of bytes in each element. Because the pointer is "declared" to be an address ofuint8_t
, each element is one byte. The address of each successive element increase by 1. -
The character value from
chr
is assigned to that element.
The member is treated as a byte array, so that it can put one byte at a time into a specific place in the member (a 32-bit int of 4 bytes).
Since you cast it to a pointer-to-uint32_t, the [ ]
operator steps by 4 bytes at a time through the array. The first character goes in the right place, but the other three are stepping on something else. The assignment also copies 4 bytes at a time (instead of one) by extending the chr
from 8-bits to 32-bits.
Change yours to uint8_t *
and I'll bet it works a lot better. Sorry I didn't notice.
from neogps.
ouuch!. nop, Thanks!!
I have wrote this code in GPSfix.h:
#ifdef GPS_FIX_ODO_DISTANCE
uint32_t distance;
#endif
#ifdef GPS_FIX_ODO_TOTAL_DISTANCE
uint32_t total_distance;
#endif
#ifdef GPS_FIX_ODO_DISTANCE_STD
uint32_t distanceSTD;
#endif
And this in GPSfix_cfg.h:
#define GPS_FIX_ODO_DISTANCE
#define GPS_FIX_ODO_DISTANCE_STD
#define GPS_FIX_ODO_TOTAL_DISTANCE
but compilation fails with: Streamers.cpp:261:21: error: 'const struct gps_fix::valid_t has no member named 'distance' if (fix.valid.distance)'
In Streamers.h, as I put ODO messages as FIX, I understand that I don't need add nothing in this (¿?)
In Streamers.cpp, I add this:
- In
gps_fix_header[]
:
#if defined(GPS_FIX_ODO_DISTANCE)
"ODO,"
#endif
#if defined(GPS_FIX_ODO_TOTAL_DISTANCE)
"D. Total,"
#endif
#if defined(GPS_FIX_ODO_DISTANCE_STD)
"D. STD,"
#endif
And 'operator <<' lines:
- In
USE_FLOAT
#ifdef GPS_FIX_ODO_DISTANCE
if (fix.valid.distance)
outs.print( (fix.distance * 0.001), 3 );
outs << ',';
#endif
- And the fails says here: In
not USE_FLOAT
:
#ifdef GPS_FIX_ODO_DISTANCE
if (fix.valid.distance)
outs << fix.distance;
outs << ',';
#endif
If I change the name in GPSfix_cfg.h
and GPSfix.h
compile OK, but nothing displays, only acquiring...
And curious question, I have worked with some libraries but this is advanced library that I had touched, which IDE have you worked with? Intellisense (or similar) would be essential I sense. 😅
Thanks again for your time.
from neogps.
Great SlashDevin!
I had wroten NAV-ODO and HNR-PVT, your library works great. I obtain HNR-PVT messages at 20Hz and NAV-ODO at 10Hz at 115200bps, great performance!
I had some problems, mainly, with #define UBX_LAST_MSG_CLASS_IN_INTERVAL ublox::UBX_HNR
. If last message is UBX_NAV
goes blank data (but received ok). Also I have used the same GPSfix defines with the same instructions, per example, GPS_FIX_DATE
from NAV-TIMEUTC
is invalidated by GPS_FIX_DATE
from HNR-PVT
. With this I have more info with less messages ( I think).
Finally and following your first comment, I need to redirect Streamers trace_all()
function into my sketch (I will show distance in SSD1306 oled display), but Streamers.h does not let me return nothing. I see some example to call data from sketch, that I have modified, for example inside loop()
, if I want to show distance (distance travelled from NAV-ODO
):
while (gps_port.available()) {
if (gps.decode( gps_port.read() ) == NMEAGPS::DECODE_COMPLETED) { // <-- Is HNR and ODO inside NMEAGPS class?
if (gps.fix().valid.distance)
distance = gps.fix().distance / 1000;
}
Is correct this method?
Thanks again!
from neogps.
Thanks for your info!
In the display, I show distance travelled, time and speed (3D), I try with this in loop():
while (gps.available( gps_port )){
//trace_all( DEBUG_PORT, gps, gps.read() );
gps_fix fix = gps.read();
if (fix.valid.distance){
DEBUG_PORT.print(gps.fix().distance);
DEBUG_PORT.print(gps.fix().speed3D);
DEBUG_PORT.println(gps.fix().timeNano);
}
My last question has relation with "blank screen" (I called "blank screen" from my ignorance, sorry) I had disabled all messages except NAV-ODO and HNR-PVT, and your example sketch needs NAV-STA to start (I think) sending messages. The last question is how can I disable/change NAV-STA by another (example NAV-ODO) to start? (I don't need NAV-STA because HNR-PVT send me the status values)
Thanks again for your answers!
from neogps.
Thanks again for your excellent work and answer! Works perfect!
from neogps.
Hi again, sorry by reopen this thread.
All works perfectly, but when I saw Distance (from NAV-ODO) values, only goes to 255 (uint8_t). In the code I did put:
case 8: case 9: case 10: case 11:
NMEAGPS_INVALIDATE( distance );
((uint32_t *)&m_fix.distance) [ chrCount-8] = chr;
m_fix.valid.distance = true;
break;
And the sketch I have declared:
uint32_t distance;
[..]
while (gps.available( gps_port )) {
gps_fix fix = gps.read();
if (fix.valid.distance) {
distance = fix.distance;
#ifdef DEBUG_ON
DEBUG_PORT.print( F("Distancia: ") );
DEBUG_PORT.println(distance);
#endif
And GPSfix.h
#ifdef GPS_FIX_ODO_DISTANCE
uint32_t distance;
#endif
[...]
#ifdef GPS_FIX_ODO_DISTANCE
bool distance NEOGPS_BF(1);
#endif
[...]
#ifdef GPS_FIX_ODO_DISTANCE
distance = 0;
#endif
[...]
#ifdef GPS_FIX_ODO_DISTANCE
if (r.valid.distance)
distance = r.distance;
#endif
I have not problem with show it in meters, I understand that I don't need transformate this values. But I don't know why distance values seem uint8_t
.
from neogps.
Yes, I am using your nav_odo_t
structure from ubxGPS.h
.
I think that my problem can be related to using ((uint32_t *)&m_fix.total_distance)
because I have been studying your others parses, and I don't understand well, by example, in speed from parseNavVelNED, you assign uint8_t
to uint32_t
gSpeed (from Ublox M8 Protocol Manual)
// Temporarily store the 32-bit cm/s in the spd member
((uint8_t *)&m_fix.spd) [ chrCount-20 ] = chr;
In my case, the variable total_distance
increase (by GPS motion) to 255 and then start in 0 continuously.
from neogps.
Yes sir, uint_8
change works perfectly!
Thanks again! I don't know if there is any possibility to thank you the time that you have dedicated to my help, you don't doubt to say me it
from neogps.
Glad to help
from neogps.
Related Issues (20)
- And if GPS loose the fix? HOT 5
- Distance skipping heavily, even when stationary
- Confused??? how getting higer refresh rate? HOT 1
- possible incorrect counting of GNSS satellites
- NMEA senteces not valid? HOT 2
- listen() function on NeoSWSerial not working
- ubloxRate example and send_P
- LAST_SENTENCE_IN_INTERVAL is not properly defined in NMEAGPS_cfg.h although I think it is? HOT 1
- add up distances? (odometer) HOT 1
- Doesn't build when using ESP32 core 2.0.4 with Arduino
- use on LGT8F328P
- running velocity NED
- Using with nrf52832
- Is this repo still active?
- Documentation for location_t.OffsetBy is incorrect
- How to query RTK Status? HOT 1
- Can't compile error in file NMEAGPS.cpp
- Keyword for Weekday ?
- GPS week rollover bug
- E220_400MM22S Sending Lat and Long
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neogps.