I know this was asked months ago, but since nobody seems to be providing any answers, I just recently have been working on a robot to farm cocoa beans so I found out a bit about how to do this the hard way... Easy answer is to utilize a geolyzer component, and run the analyze function to get the metadata of the crop, comparing it to the metadata for a full grown crop that you can find on the Minecraft wiki. Complicated answer follows:
local analyze = component.geolyzer.analyze(3) -- 3 is the front of the robot
function getFacing() -- Get the facing of the cocoa bean
for k,v in pairs(