View unanswered posts | View active topics It is currently Fri Sep 19, 2014 7:56 pm






Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Having some trouble understanding the functions for NXTCam. 
Author Message
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Post 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
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 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
Profile WWW
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Post 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 running
while  (nMotorRunState[mot] != runStateIdle || nMotorRunState[mot] != runStateHoldPosition)
  {
    wait1Msec(5);
  }
}

When the program reaches this point:
Code:
 // Wait for the motor to be done running
while  (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
Profile
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Post 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
Profile
Rookie

Joined: Sun Jan 27, 2013 8:01 pm
Posts: 18
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 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 forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



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