View unanswered posts | View active topics It is currently Mon May 21, 2018 9:20 am

 Page 2 of 2 [ 20 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Having some trouble understanding the functions for NXTCam.
Author Message
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Re: Having some trouble understanding the functions for NXTC
Thanks for the cleaned up/improved code, I will definately try that out and try to get it to work.

As for you first first post concerning what I am actually trying to do, this is a step by step of exactly what I am trying to get it to do:
The camera is basically just tracking the movements of my head and making the motors mimic the motions of my head.
The "blob" will be connected to the front of my head on a support which is approximately 15 cm away from the center of my head. The next step revolves around properties of a right triangle and using the arc tangent to find the approximate angle that my head is at. So if it is 15 cm from my head and 10 cm to the right of my head, it will know to take arctan of 10/15 which gives me its approximate angle. Then tells the xmotor to move "that number" of encoders. Then do the same for the y-axis with the ymotor and the motors would copy the movements of my head.

That is how I think of it in my head, at least.

Sun Feb 17, 2013 4:38 pm
Site Admin

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Re: Having some trouble understanding the functions for NXTC
I am not sure how well this will work as it's pretty old, but I made something similar a while back:
http://botbench.com/blog/2010/03/21/pan ... are-tests/

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Sun Feb 17, 2013 4:44 pm
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Re: Having some trouble understanding the functions for NXTC
I watched the movie and yes it does seem to be fairly similar to what I am trying to do, It just moves the camera instead of making the motors mimic a person's movements.

I went through the code you gave and I think that there are only a few kinks to be worked out, but for now the main one:
 Code:void moveMotor(tMotor mot, int target){  writeDebugStreamLine("moveMotor called: motor: %d, target: %d", mot, target);  if (target > 0)  {    nMotorEncoderTarget[mot] = target;    motor[mot] = motorspeed;  }  else if (target < 0)  {    nMotorEncoderTarget[mot] = target;    motor[mot] = -motorspeed;  }  else  {    motor[mot] = 0;  }  // Wait for the motor to be done runningwhile  (nMotorRunState[mot] != runStateIdle || nMotorRunState[mot] != runStateHoldPosition)  {    wait1Msec(5);  }}

When the program reaches this point:
 Code: // Wait for the motor to be done runningwhile  (nMotorRunState[mot] != runStateIdle || nMotorRunState[mot] != runStateHoldPosition)  {    wait1Msec(5);  }
it just repeats without end. I tried some other code but that worked even worse. I don't understand why it wouldn't work?

Sun Feb 17, 2013 5:21 pm
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Re: Having some trouble understanding the functions for NXTC
I got it to continue into the program, but now all it does continue in one direction. It goes left on the x-axis and up on the y-axis. Is there a way that you can set the motor encoders to never go above or below certain values?

And also, if the one of the motors is at 70 degrees/encoder units, then the next value is 75, how would I make it only go 5 more degrees and not another 75?

Sun Feb 17, 2013 6:03 pm
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Re: Having some trouble understanding the functions for NXTC
I got it to stop going in the same direction, but now for some reason the encoder target keeps getting set to 0 and it just turns and turns without thinking...

Sun Feb 17, 2013 9:16 pm
Display posts from previous:  Sort by
 Page 2 of 2 [ 20 posts ] Go to page Previous  1, 2

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

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.