ROBOTC.net forums
http://robotc.net/forums/

Camera for ev3
http://robotc.net/forums/viewtopic.php?f=41&t=10950
Page 1 of 1

Author:  CyD [ Mon Apr 20, 2015 5:35 am ]
Post subject:  Camera for ev3

Hi

We are trying to learn how to use the camera. We read that nxtcam supports ev3.

We searched but only found examples for NXT. Would have any examples in ev3 we could see for understand the instructions?

Thanks

Author:  mightor [ Tue Apr 21, 2015 12:25 am ]
Post subject:  Re: Camera for ev3

The examples should work fine for both NXT and EV3. Take a look at the examples in my driver suite: https://github.com/botbench/robotcdriversuite

= Xander

Author:  CyD [ Thu Apr 23, 2015 3:18 am ]
Post subject:  Re: Camera for ev3

Very thanks for you help.

to see if I can understand the programs xD

Author:  CyD [ Mon Apr 27, 2015 4:02 am ]
Post subject:  Re: Camera for ev3

Hello.
How could I know the value taken by the camera as a central position?

Thanks.

Author:  mightor [ Mon Apr 27, 2015 4:11 am ]
Post subject:  Re: Camera for ev3

I am not sure I understand your question.

= Xander

Author:  CyD [ Mon Apr 27, 2015 4:52 am ]
Post subject:  Re: Camera for ev3

I'm trying to follow a ball and I wonder what condition used, to make it go in a direcion or other

Author:  mightor [ Mon Apr 27, 2015 5:13 am ]
Post subject:  Re: Camera for ev3

You follow the biggest blob in your field of vision, as detected by the camera and apply a simply PID algorithm to control the motor that points the camera at the centre of the ball. That means that if you find the centre of the ball moving towards the right of your vision, you move the camera in that direction, proportionally to the offset of the ball's centre in comparison to the desired position of it (the centre of your screen).

= Xander

Author:  CyD [ Mon Apr 27, 2015 7:12 am ]
Post subject:  Re: Camera for ev3

thanks for your helpĀ·

Author:  CyD [ Mon May 04, 2015 5:27 am ]
Post subject:  Re: Camera for ev3

I'm trying to follow a ball with the following program

Code:
#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Sample Programs\EV3\3rd Party Driver Library\include\mindsensors-nxtcam.h"

task main () {
   blob_array _blobs;
   memset(_blobs, 0, sizeof(_blobs));
   bool _condensed=true;
   int _l,_t,_r,_b;
   int _nblobs=0;
   float xcenter=0;

   _l=0;_t=0;_r=0;_b=0;
   eraseDisplay();
   NXTCAMinit(cam);
   while(true)
   {
      eraseDisplay();
      displayCenteredBigTextLine(5,"%f",xcenter);
      _nblobs=NXTCAMgetBlobs(cam,_blobs,_condensed);
      for(int i=0;i<_nblobs;i++)
      {
         
         _l=(_blobs[i].x1);
         _r=(_blobs[i].x2);
         _t=(_blobs[i].y1);
         _b=(_blobs[i].y2);
      }

      xcenter=(_l+_r)/2;

      if (_nblobs >=1 && getUSDistance(S4)>5)
      {
         if(xcenter>97 && xcenter<=120)
         {
            setMotorSpeed(motorC,30);
            setMotorSpeed(motorD,23);
         }
         if(xcenter>120 && xcenter<=140)
         {
            setMotorSpeed(motorC,30);
            setMotorSpeed(motorD,17);
         }
         else if (xcenter>140)
         {
            setMotorSpeed(motorC,30);
            setMotorSpeed(motorD,12);
         }
         else if (xcenter<87 && xcenter>=65)
         {
            setMotorSpeed(motorC,23);
            setMotorSpeed(motorD,30);
         }
         else if (xcenter<65 && xcenter>=45)
         {
            setMotorSpeed(motorC,17);
            setMotorSpeed(motorD,30);
         }
         else if (xcenter<45)
         {
            setMotorSpeed(motorC,12);
            setMotorSpeed(motorD,30);
         }
         else if (xcenter>=87 && xcenter<=97)
         {
            setMotorSpeed(motorC,30);
            setMotorSpeed(motorD,30);
         }
      }
      else if (_nblobs ==0 && getUSDistance(S4)>5)
      {
         setMotorSpeed(motorC,10);
         setMotorSpeed(motorD,-10);
      }
      else if(getUSDistance(S4)<=5)
      {
         setMotorSpeed(motorC,0);
         setMotorSpeed(motorD,0);
      }
   }
}


when I put the ball in front of the camera the robot follows the ball without any problems, but when I throw the ball, the robot does not have time to read it and do not follow.

How I can make the robot follow the ball when I throw?

Sorry my level of englihs

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/