Now that the machine itself can navigate autonomously, it's time to get the weeding mechanism doing the same.
In the last log, I got the machine to recognise a barcode, which can be used to stop the machine and allow a weeding routine to be carried out.
First task is to get the X,Y and Z axis's to 'index' or 'register' on limit switches so that it knows exactly where it is before it starts trying to do a task.
The code to achieve this fairly simple and no special libraries are used. The only deviation from my normal procedure was using a 30 ms delay at one point, which will probably be replaced with a 'millis' or 'micros' command which will then allow all the axes to be registered simultaneously.
void CNC_SETUP()
{
unsigned long currentMicros = micros();
//////////////////////////////////////////////////////////////////////////////////////////
speedCNCX = 1600; //1 = one Hz.
XZeroingStepsTotal = 5000;
dirStateCNCX = LOW; // LOW is Forwards.
// controlState==HIGH is autonomous mode.
// Initial movement forward for zeroing:
if((controlState==HIGH)&&(XZeroingState==LOW)) // Forwards and backwards switch open.
{
XZeroingStep=0;
intervalCNCX = 1000000/speedCNCX; // interval is smaller for faster speed.
if ((currentMicros - previousMicrosCNCX) >= intervalCNCX)
{
LSFX = Fast_digitalRead(49); // Limit switch X forwards
if (stepStateCNCX == LOW)
{
stepStateCNCX = HIGH;
}
else
{
stepStateCNCX = LOW;
}
//DEBUG_PORT.print("XZeroingState = ");DEBUG_PORT.println(XZeroingState);
digitalWrite(53,dirStateCNCX);
digitalWrite(35,stepStateCNCX);
digitalWrite(39,stepStateCNCX); // Orange LED
previousMicrosCNCX = currentMicros;
}
}
else
{
digitalWrite(35,LOW);
} // Initial movement forward for zeroing ends
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////if((LSFX==HIGH)&&(controlState==HIGH)) // Either x switches closed autonomous(HGH)
{
delay(30); // Need this delay for reliable operation ofswitchfor some reason.
XZeroingState=HIGH;
}
if(controlState==LOW)
{
XZeroingState=LOW;
}
if((XZeroingState==HIGH)&&(XZeroingStepsTotal > XZeroingStep))
{
dirStateCNCX = HIGH; // LOW is Forwards.
if((LSBX==HIGH)&&(controlState==HIGH)) // backwards switch open.
{
intervalCNCX = 1000000/speedCNCX; // interval is smaller for faster speed.
if ((currentMicros - previousMicrosCNCX) >= intervalCNCX)
{
XZeroingStep++;
LSFX = Fast_digitalRead(49); // Limit switch X forwards
if (stepStateCNCX == LOW)
{
stepStateCNCX = HIGH;
}
else
{
stepStateCNCX = LOW;
}
//DEBUG_PORT.print("XZeroingState = ");DEBUG_PORT.println(XZeroingState);
//DEBUG_PORT.print("XZeroingStep = ");DEBUG_PORT.println(XZeroingStep);
digitalWrite(53,dirStateCNCX);
digitalWrite(35,stepStateCNCX);
digitalWrite(39,stepStateCNCX); // Orange LED
previousMicrosCNCX = currentMicros;
}
}
else
{
digitalWrite(35,LOW);
}
} //if(XZeroing == HIGH)
////////////////////////////////////////////////////////////////////////////////////////
} // CNC
Barcodes can be placed on the soil to instruct the machine to do a particular task. In the video below, barcode '3' is detected by the Pixy2 camera and the machine stops dead when that barcode image reaches a certain position in the camera's view. The machine can then perform any number of operations such as weeding and then move forwards once more to the next barcode.
It's the first week of July here at +53 ° latitude, planet Earth and we're all enjoying being outside in the sunshine tending our vegetables. There's no robots in sight - not even on the neighbouring farms ….. yet.
Then again, there's no people visible on the neighbouring farms either, just sheep and a lot of grass. Already, mechanisation has dramatically reduced the number of people working on farms by about 95% in the last 50 years, depending on which country we are in. I remember travelling through Romania 20 years ago and seeing maybe 50 people in a long line digging over a field with sticks. It looked like extremely hard work!
So today, maybe it's more of a lifestyle choice if we want to work outside or not? We don't have to use the WEEDINATOR every day for every job if we don't want to. If the choice is available, maybe some of us would actively choose to weed some brassicas rather than play computer games or endlessly browse social media?
This time next year, the WEEDINATOR will be capable of performing the job in the photo above and in reality, it's a job that 99% of us don't want to do, for whatever reason. If people do actually want to do the job, it's perfectly ok to leave the machine in the garage. There is hope for us to both produce cheap high quality food and enjoy working in the fields. It's just a matter of choice.
One of the debates that came out of the Liverpool Makefest was whether it would be better to use a computer eg Raspberry Pi or microcontroller such as Arduino for the control system? ….. I tried a Google search, but nowhere could I find a definitive answer.
In my mind, the Raspberry Pi, or the 'RPi', is great for complex servers or handling loads of complex data such as Ai based object recognition …… Or a complex robot with very many motors running at the same time. In contrast, the Arduino, or 'MCU', will handle simpler tasks with greater efficiency and reliability.
The RPi works with a huge operating system composed of a vast, almost indecipherable, network of inter-dependable files, using a very large amount of precious silicon. The problem here is that computers are prone to crashing due to their sheer complexity whilst a MCU, with only a few thousand lines of code, is at least one order of magnitude more reliable. The other question that was posed is that if the system, whatever it is, does crash, how long will it take to reboot?
As development of the machine continues, some of the tasks will be assigned to a small computer, the Nvidia TX2, hosting an enormous graphics processor for Ai based object recognition. More critical tasks such as navigation and detecting 'unexpected objects' will be done on MCUs. One of the major tasks is writing / finding code to get reliable communication between these devices. We might also want a simple 'watchdog' MCU to check that all the different systems are working properly. Maybe each system will constantly flash a 'heartbeat' LED (or equivalent) and the watchdog will monitor this. A small robotic arm would then move across to press the relevant reset button.
Up at 5.00 am and off on the road - We met a whole load of interesting people in Liverpool today, with interesting questions asked and some potential technical solutions suggested:
* Use RFID chips in the ground for super accurate positioning on the beds of vegetables.
* Install ballast resistor in regenerative circuit in motor drives for absorbing current generated when going downhill.
* Use spiral metal shroud on lead. Crews to protect from dust
* Dial up a WEEDINATOR like an Uber cab to come and weed your garden.
* Add voice message "Get off my land" followed by "Click Clunk" sound of shotgun reloading.
* Stistically, more people will come to your event / stand if you offer them free pizza.
The current drive motors are just about ok for testing the navigation and some of the other tooling, but eventually they'll need to be upgraded ….. The project needs to win a few more Hackaday prize rounds or get some online subscribers!
The motors above are used in heavy duty 'combat robots' as seen on TV programs such as 'robot wars' etc.
Food production ……. As the human population grows ever larger, the pressure on land resources increases and food production will need to be more efficient. The 'Elephant in the Room' is MEAT. I'm not a vegetarian, but eating meat protein is incredibly inefficient compared to vegetable protein. Current levels of world meat consumption are very possibly not sustainable and certainly not necessary - we do not need to eat meat every day.
So what's this got to do with the WEEDINATOR? …… The machine is designed to increase vegetable / cereal production efficiency and enable small farms to compete with larger ones using more traditional 'monster' tractors.
So what's wrong with 'monster' tractors? ……. Cereal crops, particularly, are often grown on huge fields where extremely large machines can work without too many corners and turns and driving between fields. One person is employed to drive the machine and he and the machine can work incredibly efficiently, producing very cheap food. The downside is that all other lifeforms except the human being and the crop are pretty much destroyed, including bacteria and other lifeforms in the soil itself. This is considered to be bad for the environment.
Why is meat production an inefficient way of producing protein? ……… In these time (2018), meat animals are often kept in massive sheds where the animal hardly ever sees natural sunlight. Apart from the very dubious ethical considerations, the animals are fed those cereal crops that could otherwise be eaten directly by us humans. The cost in terms of loss of efficiency is massive - somewhere in the order of 90 % of the food value of the cereal is lost and wasted in the process of feeding it to animals. Even animals grazing out on open fields are a loss in efficiency - probably even greater than those kept in sheds - as that land could possibly be used to produce food crops for humans rather than food crops for animals.
The WEEDINATOR, and other similar machines, enable the farmer to have smaller fields or break up the mono crop on large fields with areas beneficial to wildlife. Part of the idea is to use zero pesticides, so there would need to be a balanced environment with enough natural predators to keep the caterpillars / aphids under an acceptable level of control without having to completely destroy that caterpillar or completely exclude the predator.
Wildlife also lives inside the soil itself and can, again, maintain a natural balance between friends and foe and also nutrients. Bacteria / fungus in the soil can produce, for example , nitrates if the soil's health is maintained. Much of the soil's biodiversity lives in the top 3" and ploughing or other heavy cultivation can destroy soil health drastically. Whilst I'm not personally against ploughing, the opportunity to reduce heavy cultivation by using a precision machine such as the WEEDINATOR is very exciting! This kind of machine can target weeds on the surface or limit it's effect on the soil to the top 1".
Machines such as the WEEDINATOR are agile enough to navigate between areas set aside for rejuvenation of soil structure or proliferation of wildlife and literally have a very light 'touch' on the soil. There's no wheel compaction of the soil due to heavy machines and they may well be even more efficient than monster tractors due to not needing a driver, pesticides and less need for artificial fertilisers such as nitrates. In theory, all artificial fertilisers could be negated and ….. get this ….. all animal manure could also be negated so that the whole system gets rid the reliance for inefficient animal meat production.
The WEEDINATOR et al offer new and exciting ways of producing food where a total 'no fertiliser import' regime can be created, which means no artificial chemical fertiliser or animal manure brought on to the farm ….. AND ……. The farm itself has no, or very few, animals. This regime would be achieved by using ultra precision machines which preserve a natural soil health and using new crop / fallow rotation cycles to maintain nutrient levels in a more natural way.
I've always found the chunky cable drag chains on CNC machines rather sexy so getting the cables to move properly was a major priority, right from the initial design concept.
Unlike all other CNC machines to date, the 'Y' axis motor for the WEEDINATOR runs inside the chassis of the machine rather than on top, which results in a massive reduction in overall height of the machine. How the cables within the chassis would behave was indeed a major concern. Would the drag chains have enough room to swivel around within the narrow confines of the chassis? In the end, I need not have worried as the cable management performs perfectly.
The photo below shows the CNC in maximum 'Y' axis travel with the drag chain curled up nicely on the far right.
In the true spirit of open source, the WEEDINATOR is going to be exhibited at various exhibitions / hack fests around the UK, including Liverpool Makefest on 30th June 2018.
I spent a couple of days making a special trailer for transportation. I'm not sure exactly what the machine weighs, but it's definitely under the 750 kg weight limit for braked trailers in the UK.
It will be interesting trying to get it into Liverpool central library, but we'll take an angle grinder and sledge hammer just in case!
The WEEDINATOR uses advanced, super accurate GPS to navigate along farm tracks to the start of the beds of vegetables with an accuracy of about plus/minus 20 mm. Once on the bed, accuracy needs to be even greater - at least plus/minus 5 mm.
Here, we can use object recognition cameras such as the Pixy2 which can perform 'on chip' line recognition without taxing our lowly Arduinos etc.
This test was done in ideal, cloudy conditions and eventually the lighting would need to be 100% controlled by extending the glass fibre body of the machine over the camera's field of view and using LEDs to illuminate the rope. Other improvements include changing the rope colour to white and moving the camera slightly closer to the rope.