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










share|improve this question




















  • 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















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










share|improve this question




















  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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












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.






share|improve this answer




























    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.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      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
































      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.






      share|improve this answer

























        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.






        share|improve this answer























          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 19 at 9:56









          Vipin Raj C

          263




          263
























              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.






              share|improve this answer

























                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.






                share|improve this answer























                  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.






                  share|improve this answer












                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Srikar

                  214




                  214






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      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




















































































                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine