View unanswered posts | View active topics It is currently Sun Jul 21, 2019 9:15 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Location Tracker for NXT Robot Using nMotorEncoder
Author Message
Rookie

Joined: Sun Feb 15, 2015 12:07 pm
Posts: 4
Location Tracker for NXT Robot Using nMotorEncoder
Hey everyone,

For a school project, I am creating a robot that is controlled by a Logitech controller. I have already coded the controller part, but I want to include a feature that returns the robot to the original location automatically when a button is pressed on the controller. The only way I can do this is using the nMotorEncoder to track the location of the robot relative to the original location. When it is going straight forward at speeds of 100 for both motors, I know that I can calculate the distance traveled by doing nMotorEncoder[motorA] * PI * r / 180.

I am stuck on the turning portions however. I'm not sure what equation to use to calculate the heading and distance traveled by the robot during the turns. When turning, the motors are always at a 1/10 ratio (one motor is at 10 speed while the other is at 100). Here is the code for the controller portion if it helps. My plan is to calculate the heading and distance travelled during each time the loop is passed, and then updating the general location relative to the original position. Here is my code so far:

 Code:#include "JoystickDriver.c"#pragma DebuggerWindows("joystickSimple")const int FULL = 100, SLOW = 10;void setMotorSpeeds(int aSpeed, int cSpeed) {   motor[motorA] = aSpeed;        motor[motorC] = cSpeed;}int checkForMove() {         //none    if(joystick.joy1_x1 / 10 == 0 && joystick.joy1_y1 / 10 == 0 ) {            setMotorSpeeds(0,0);            return 0;      }    //forward    else if(joystick.joy1_y1 > 0) {          //left          if(joystick.joy1_x1 < -45) {                setMotorSpeeds(SLOW,FULL);                return 1;          }          //forward          else if (joystick.joy1_x1 < 45) {                 setMotorSpeeds(FULL,FULL);                 return 2;            }          //right          else {  //joystick.joy1_x1 > 0                setMotorSpeeds(FULL,SLOW);                return 3;            }      }      //backward    else if(joystick.joy1_y1 < 0) {          //left          if(joystick.joy1_x1 < -45) {                setMotorSpeeds(-SLOW,-FULL);                return 4;            }          //forward          else if (joystick.joy1_x1 < 45) {                setMotorSpeeds(-FULL,-FULL);                  return 5;            }          //right          else { //joystick.joy1_x1 > 0                setMotorSpeeds(-FULL,-SLOW);                  return 6;            }      }      else {            setMotorSpeeds(0,0);            return 0;       }}task main() {     while(1 == 1) {          getJoystickSettings(joystick);          checkForMove();      }}

Any help would be greatly appreciated. If you need clarification, please ask. I know that this question is kind of weird, but I really want to do this the right way instead of just doing trial by error.

Thanks!

Sun Feb 15, 2015 12:17 pm
Rookie

Joined: Thu Feb 19, 2015 10:24 am
Posts: 3
Re: Location Tracker for NXT Robot Using nMotorEncoder
I am interested to know if you ever figured out this problem? I am trying to work a similar feature into my robot. Please let me know how it works out for you.

Thu Feb 19, 2015 2:35 pm
Rookie

Joined: Sun Feb 15, 2015 12:07 pm
Posts: 4
Re: Location Tracker for NXT Robot Using nMotorEncoder
Unfortunately I couldn't think of a way to make it work in the short timeline that I have, so I have ditched the project idea.

Thu Mar 05, 2015 5:24 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning