View unanswered posts | View active topics It is currently Wed Nov 26, 2014 12:38 pm






Reply to topic  [ 8 posts ] 
POV control 
Author Message
Rookie

Joined: Sun Feb 21, 2010 4:19 pm
Posts: 9
Post POV control
Ok, I know the competition in Atlanta is over, and I know we don't have to do anything till maybe september, but does anyone know how to use values from the POV in the upper left corner of the remote to control robots? I was planning to involve a command with POV in my program but I couldn't find any details on the POV in any sample programs. Is there a command for the POV in the robot - C programming system? I saw that you could see it while you were working the debugger and it looked a lot more precise here than it did in my old NXT-G programming language.


Tue Apr 20, 2010 12:57 pm
Profile
Expert

Joined: Mon Mar 15, 2010 4:24 pm
Posts: 124
Post Re: POV control
What's a POV?


Tue Apr 20, 2010 7:18 pm
Profile
Rookie

Joined: Sun Feb 21, 2010 4:19 pm
Posts: 9
Post Re: POV control
It's the pad in the upper left corner of the remote control (if you are using the standard logitech version from the kit). It's kind of like a joystick except for the fact that you can't scale motion and it only has 8 directions you can press. It's not too good if you want to make a robot that can run at different speeds, or if you want to make a few button functions that people can understand, but I was thinking of making a system that had eight directions of movement so it's great for what I wanted.


Tue Apr 20, 2010 7:30 pm
Profile
Expert

Joined: Mon Mar 15, 2010 4:24 pm
Posts: 124
Post Re: POV control
What does POV stand for?


Tue Apr 20, 2010 9:02 pm
Profile
Rookie

Joined: Sat Nov 22, 2008 8:06 pm
Posts: 48
Post Re: POV control
Point Of View. I think it comes from it's usage to switch view points in PC games that use a joystick (with POV hat on top.)
They look like the black knob on the top middle of the stick in this picture.
Image

And actually, I believe what Techbrick is referring to is a D-pad. The difference is that you push down on a D-pad (think of an NES controller) and sideways on a POV switch.


Wed Apr 21, 2010 12:42 am
Profile
Rookie

Joined: Sun Feb 21, 2010 4:19 pm
Posts: 9
Post Re: POV control
That's wonderful. So does anybody know how to use it in robot-C? I was able to use the button when I was programming with NXT-G, and I can still see the POV in the debugger, but I have never heard of anything to turn that command into an action with the robot.

I think they took the remote design from the PS2 console. I don't know if they name it differently when they use it there.


Wed Apr 21, 2010 6:45 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: POV control
As I recall, the dpad/pov is accessed through the TJoystick struct via the joy1_TopHat and joy2_TopHat which contain an int between -1 and 7 where:
    -1 not pressed
    0 up
    1 up/right
    2 right
    3 down/right
    4 down
    5 down/left
    6 left
    7 left/up

For example, to see if the dpad/pov is not pressed you could do something like:
Code:
if(joystick.joy1_TopHat == -1)
{
   //do stuff
}

Or if you wanted to see if the dpad/pov on the second joystick was pressed to the right, you could do something like:
Code:
if(joystick.joy2_TopHat == 2)
{
   //do stuff
}


You could define an enum to better describe the values for the dpad/pov and it also looks like a good candidate for a switch statement depending on what you want to do with it.
More complex example showing an emum and switch function:

Code:
typedef enum
{
   POV_NOT_PRESSSED = -1,
   POV_UP = 0,
   POV_UP_RIGHT = 1,
   POV_RIGHT = 2,
   POV_DOWN_RIGHT = 3,
   POV_DOWN = 4,
   POV_DOWN_LEFT = 5,
   POV_LEFT = 6,
   POV_UP_LEFT = 7
} POVDirections;

void povControl(int value)
{
   switch (value)
   {
   case POV_NOT_PRESSSED:
      //do stuff
      break;
   case POV_UP:
      //do stuff
      break;
   case POV_UP_RIGHT:
      //do stuff
      break;
   case POV_RIGHT:
      //do stuff
      break;
   case POV_DOWN_RIGHT:
      //do stuff
      break;
   case POV_DOWN:
      //do stuff
      break;
   case POV_DOWN_LEFT:
      //do stuff
      break;
   case POV_LEFT:
      //do stuff
      break;
   case POV_UP_LEFT:
      //do stuff
      break;
   default:
      //error
   }
}


Wed Apr 21, 2010 9:20 pm
Profile
Rookie

Joined: Sun Feb 21, 2010 4:19 pm
Posts: 9
Post Re: POV control
Thanks for that. That will help a lot starting up the -11 season. Do you know where I could find example programs for this, like the ones made for the joystick control and other program controls?


Wed Apr 21, 2010 9:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

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.