Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
D4-Embedded
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D4-Furlough
D4-Embedded
Commits
73f4fb11
Commit
73f4fb11
authored
4 years ago
by
roaa1g19
Browse files
Options
Downloads
Patches
Plain Diff
made _rodGPS_Distance() function for accurate distance calcs
Signed-off-by:
Rodrigo Amaral
<
roaa1g19@soton.ac.uk
>
parent
f1b4566a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
rodGPS/src/main.cpp
+0
-2
0 additions, 2 deletions
rodGPS/src/main.cpp
rodGPS/src/rodGPS.cpp
+9
-4
9 additions, 4 deletions
rodGPS/src/rodGPS.cpp
rodGPS/src/rodGPS.hpp
+11
-7
11 additions, 7 deletions
rodGPS/src/rodGPS.hpp
with
20 additions
and
13 deletions
rodGPS/src/main.cpp
+
0
−
2
View file @
73f4fb11
...
...
@@ -14,6 +14,4 @@ void setup()
void
loop
()
{
_rodGPS_MakeReading
(
&
gprmc_buff
,
&
test
);
Serial
.
print
(
std
::
atof
(
"32.575"
));
Serial
.
write
(
"
\n\n
"
);
}
This diff is collapsed.
Click to expand it.
rodGPS/src/rodGPS.cpp
+
9
−
4
View file @
73f4fb11
...
...
@@ -26,10 +26,10 @@ void _rodGPS_PrintGPRMC(simple_GPRMC* gprmc_data)
Serial
.
write
(
gprmc_data
->
DATE
[
5
]);
Serial
.
write
(
"
\n
Latitude: "
);
Serial
.
write
((
uint8_t
*
)
&
(
gprmc_data
->
LATI
),
10
);
Serial
.
write
((
uint8_t
*
)
&
(
gprmc_data
->
LATI
),
LATI_SIZE
);
Serial
.
write
(
gprmc_data
->
LATI_DIR
);
Serial
.
write
(
" Longitude: "
);
Serial
.
write
((
uint8_t
*
)
&
(
gprmc_data
->
LONG
),
11
);
Serial
.
write
((
uint8_t
*
)
&
(
gprmc_data
->
LONG
),
LONG_SIZE
);
Serial
.
write
(
gprmc_data
->
LONG_DIR
);
Serial
.
write
(
"
\n\n
"
);
...
...
@@ -42,8 +42,13 @@ double _rodGPS_SimpleDistance(simple_GPRMC* coord_1, simple_GPRMC* coord_2)
return
sqrt
(
dx
*
dx
+
dy
*
dy
);
}
double
_rodGPS_Distance
(
simple_GPRMC
*
coord_1
,
simple_GPRMC
*
coord_2
)
{
return
6378388
*
acos
(
sin
(
std
::
atof
(
coord_1
->
LATI
))
*
sin
(
std
::
atof
(
coord_2
->
LATI
))
+
cos
(
std
::
atof
(
coord_1
->
LATI
))
*
cos
(
std
::
atof
(
coord_2
->
LATI
))
*
cos
(
std
::
atof
(
coord_2
->
LONG
)
-
std
::
atof
(
coord_1
->
LONG
)));
}
static
char
char_buff
[
5
];
byte
_rodGPS_MakeReading
(
simple_GPRMC
*
gprmc1
,
simple_GPRMC
*
gprmc2
)
uint8_t
_rodGPS_MakeReading
(
simple_GPRMC
*
gprmc1
,
simple_GPRMC
*
gprmc2
)
{
while
(
Serial2
.
available
()
==
0
)
{;}
...
...
@@ -102,7 +107,7 @@ byte _rodGPS_MakeReading(simple_GPRMC* gprmc1, simple_GPRMC* gprmc2)
_rodGPS_PrintGPRMC
(
gprmc1
);
Serial
.
write
(
"Distance: "
);
Serial
.
println
(
String
((
_rodGPS_
Simple
Distance
(
gprmc1
,
gprmc2
)),
2
));
Serial
.
println
(
String
((
_rodGPS_Distance
(
gprmc1
,
gprmc2
)),
2
));
Serial
.
write
(
"
\n\n
"
);
for
(
byte
i
=
0
;
i
<
10
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
rodGPS/src/rodGPS.hpp
+
11
−
7
View file @
73f4fb11
#ifndef RODGPS_HPP
#define RODGPS_HPP
#include
<Arduino.h>
#include
<HardwareSerial.h>
#include
<string.h>
#
ifndef RODGPS_HPP
#define
RODGPS_HPP
#
define LATI_SIZE 10
#define
LONG_SIZE 11
typedef
struct
simple_GPRMC
{
...
...
@@ -11,14 +14,15 @@ typedef struct simple_GPRMC
char
DATE
[
6
];
char
VALID
;
char
LATI
[
10
];
char
LATI
[
LATI_SIZE
];
char
LATI_DIR
;
char
LONG
[
11
];
char
LONG
[
LONG_SIZE
];
char
LONG_DIR
;
};
void
_rodGPS_PrintGPRMC
(
simple_GPRMC
*
gprmc_data
);
double
_rodGPS_SimpleDistance
(
simple_GPRMC
*
coord_1
,
simple_GPRMC
*
coord_2
);
byte
_rodGPS_MakeReading
(
simple_GPRMC
*
gprmc1
,
simple_GPRMC
*
gprmc2
);
void
_rodGPS_PrintGPRMC
(
simple_GPRMC
*
gprmc_data
);
/* Print out the GPRMC data */
double
_rodGPS_SimpleDistance
(
simple_GPRMC
*
coord_1
,
simple_GPRMC
*
coord_2
);
/* Quicker distance calculation, good enough for small distances */
double
_rodGPS_Distance
(
simple_GPRMC
*
coord_1
,
simple_GPRMC
*
coord_2
);
/* Accurate distance calculations */
uint8_t
_rodGPS_MakeReading
(
simple_GPRMC
*
gprmc1
,
simple_GPRMC
*
gprmc2
);
/* Make a GPRMC reading from GPS IC */
#endif
/* RODGPS_HPP */
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment