I have a 2 DOF Robot Arm with a camera attached to it. It takes an Image and there's an object in that image, say a glass. Of course, in order to move the arm to the required position to grasp the object, I have to solve the inverse kinematic equations. In order to solve them, I need the x and y, the coordinates where the arm has to reach to grasp the object. My question is how can I find the x and y of say the midpoint of the object from the image. Thanks
What you need is to know the position in (x,y) of the object with respect to your robot's arm. That is, you want to measure distance. You have several options:
- Use a fiducial marker. By placing one of these images on your object, you can use an image processing algorithm to detect the marker and use its relative size and orientation to determine where the object is relative to the camera/your robot arm. Common ones look like this:
Try looking for implementations of algorithms for reading fiducials in either ROS (Robot Operating System) modules or as functions in OpenCV.
Use a distance sensor. Some commonly used ones for hobbyists are ultrasonic and infra-red laser range finders. Place these sensors on your robot arm and have the sensor detect the object by looking for a "bump" in the reading, then calculate the distance to the object.
Use a stereo camera. You'll need to use an image processing algorithm to parse your camera outputs to detect how far away something is. Link
Use a Lidar laser range finder. These are probably out of your budget, as most of them cost between $1000 and several thousand dollars, but they can be used to generate a 3D map of your environment.
Side note: With only a 2DOF arm, you'll be limited to grasping your object in one of two configurations. (elbow in/out) You might consider using a 3DOF robot arm with a wrist so that you can more easily adjust your grasping angle.