Calculate Heading with two GPS Devices
up vote
1
down vote
favorite
Hi I am planing to use two RTK-GPS devices to get the position and heading of a outdoor robot. The two devices are placed on the left and the right side of the robot with a distance of 2m. The heading should be a value between 0 and 2*PI. 0 if the robot is facing north.
I am trying the following:
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dx = x2-x1;
double dy = y2-y1;
// get the normal of the line
double nx = dy*-1;
double ny = dx;
double angle = atan2(ny ,nx);
somehow the angle always stays the same even if i rotate the robot
gps robotics robot
add a comment |
up vote
1
down vote
favorite
Hi I am planing to use two RTK-GPS devices to get the position and heading of a outdoor robot. The two devices are placed on the left and the right side of the robot with a distance of 2m. The heading should be a value between 0 and 2*PI. 0 if the robot is facing north.
I am trying the following:
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dx = x2-x1;
double dy = y2-y1;
// get the normal of the line
double nx = dy*-1;
double ny = dx;
double angle = atan2(ny ,nx);
somehow the angle always stays the same even if i rotate the robot
gps robotics robot
1
It might be useful to add some examples ofx1
,y1
,x2
, andy2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.
– Mark Booth
Aug 14 '17 at 16:10
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Hi I am planing to use two RTK-GPS devices to get the position and heading of a outdoor robot. The two devices are placed on the left and the right side of the robot with a distance of 2m. The heading should be a value between 0 and 2*PI. 0 if the robot is facing north.
I am trying the following:
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dx = x2-x1;
double dy = y2-y1;
// get the normal of the line
double nx = dy*-1;
double ny = dx;
double angle = atan2(ny ,nx);
somehow the angle always stays the same even if i rotate the robot
gps robotics robot
Hi I am planing to use two RTK-GPS devices to get the position and heading of a outdoor robot. The two devices are placed on the left and the right side of the robot with a distance of 2m. The heading should be a value between 0 and 2*PI. 0 if the robot is facing north.
I am trying the following:
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dx = x2-x1;
double dy = y2-y1;
// get the normal of the line
double nx = dy*-1;
double ny = dx;
double angle = atan2(ny ,nx);
somehow the angle always stays the same even if i rotate the robot
gps robotics robot
gps robotics robot
edited Aug 14 '17 at 14:46
asked Aug 14 '17 at 14:21
blasalat
464
464
1
It might be useful to add some examples ofx1
,y1
,x2
, andy2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.
– Mark Booth
Aug 14 '17 at 16:10
add a comment |
1
It might be useful to add some examples ofx1
,y1
,x2
, andy2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.
– Mark Booth
Aug 14 '17 at 16:10
1
1
It might be useful to add some examples of
x1
, y1
, x2
, and y2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.– Mark Booth
Aug 14 '17 at 16:10
It might be useful to add some examples of
x1
, y1
, x2
, and y2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.– Mark Booth
Aug 14 '17 at 16:10
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dy = y2-y1;
double nx = cos(x2)*sin(dy);
double ny = cos(x1)*sin(dy) - sin(x1)*cos(x2)*cos(dy);
double angle = atan2(nx,ny);
Can you try this?
0 - heading north,
90 - heading east,
180 - heading south,
270 - heading west.
add a comment |
up vote
0
down vote
Like @Mark Booth the resolution might not be enough. We had a similar issue, so we used a magnetometer to fix this. Using this heading information from a magnetometer and GPS we were able to navigate successfully.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dy = y2-y1;
double nx = cos(x2)*sin(dy);
double ny = cos(x1)*sin(dy) - sin(x1)*cos(x2)*cos(dy);
double angle = atan2(nx,ny);
Can you try this?
0 - heading north,
90 - heading east,
180 - heading south,
270 - heading west.
add a comment |
up vote
0
down vote
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dy = y2-y1;
double nx = cos(x2)*sin(dy);
double ny = cos(x1)*sin(dy) - sin(x1)*cos(x2)*cos(dy);
double angle = atan2(nx,ny);
Can you try this?
0 - heading north,
90 - heading east,
180 - heading south,
270 - heading west.
add a comment |
up vote
0
down vote
up vote
0
down vote
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dy = y2-y1;
double nx = cos(x2)*sin(dy);
double ny = cos(x1)*sin(dy) - sin(x1)*cos(x2)*cos(dy);
double angle = atan2(nx,ny);
Can you try this?
0 - heading north,
90 - heading east,
180 - heading south,
270 - heading west.
double x1 = gps_left->latitude;
double y1 = gps_left->longitude;
double x2 = gps_right->latitude;
double y2 = gps_right->longitude;
double dy = y2-y1;
double nx = cos(x2)*sin(dy);
double ny = cos(x1)*sin(dy) - sin(x1)*cos(x2)*cos(dy);
double angle = atan2(nx,ny);
Can you try this?
0 - heading north,
90 - heading east,
180 - heading south,
270 - heading west.
answered Jan 19 at 9:56
Vipin Raj C
263
263
add a comment |
add a comment |
up vote
0
down vote
Like @Mark Booth the resolution might not be enough. We had a similar issue, so we used a magnetometer to fix this. Using this heading information from a magnetometer and GPS we were able to navigate successfully.
add a comment |
up vote
0
down vote
Like @Mark Booth the resolution might not be enough. We had a similar issue, so we used a magnetometer to fix this. Using this heading information from a magnetometer and GPS we were able to navigate successfully.
add a comment |
up vote
0
down vote
up vote
0
down vote
Like @Mark Booth the resolution might not be enough. We had a similar issue, so we used a magnetometer to fix this. Using this heading information from a magnetometer and GPS we were able to navigate successfully.
Like @Mark Booth the resolution might not be enough. We had a similar issue, so we used a magnetometer to fix this. Using this heading information from a magnetometer and GPS we were able to navigate successfully.
answered yesterday
Srikar
214
214
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45676694%2fcalculate-heading-with-two-gps-devices%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
It might be useful to add some examples of
x1
,y1
,x2
, andy2
values that your robot has captured. My suspicion is that both GPS units may be returning the same values, given their likely resolution and the separation of the devices.– Mark Booth
Aug 14 '17 at 16:10