Herding Commands Adapted to a Microbit – Andres Malaga

Abstract:

The aim of this experiment is to translate the commands given to herding dogs into instructions given to a robot through a controller device in order to start replicating herding behavior. An example of a herding robot already in development and a mathematical model that describes the principles of herding behavior are discussed as examples of the implementation of the herding commands. The robot used in this experiment was only able to receive and follow commands related to its movement, but further improvements to this have been discussed that could lead to the development of fully autonomous robots that are capable of carrying out the functions of a herding dog.

Bio-Inspiration:

The behavior I am going to investigate is herding behavior such as that observed in herding dogs. A herding dog (or sheepdog) is a dog that has been trained to keep together a group of sheep or cattle through commands. The efficiency of a sheepdog relies on its ability to group the animals and move them forward. When grouping sheep, a sheepdog will attempt to move the sheep close to each other, thus closing the gaps between them, and lead them from the back of the group. This first step is done so that the sheep (or cattle) move in a uniform manner in order to facilitate the second step, which is leading the group from behind. The second step consists of the dog staying behind the group, prompting it to move forward. In order to close gaps between sheep or cattle, the dog will usually go towards the stray sheep or cow and bark at it, prompting it to return to the group. The sheep will always move away from the dog. Herding dogs are trained to herd responding to commands by their owner, which usually include commands that make the dog turn left, right, go straight, get closer or away from the herd, group the animals, stop, and bark.  These commands are often said by the owner or given in the form of a whistle, where different pitches or patterns can symbolize a different command. In this experiment, I will try to make a kittenbot follow instructions similar to the herding commands given by a microbit as the first step towards developing autonomous robots that can carry out herding efficiently, such as the Swagbot.

Herding Robots:

Herding robots are already in use. An example of this is Swagbot, a robot developed in Australia meant to group and lead cows around a pasture. This robot just attempts to keep the group together and lead it around, following the principles of herding behavior. Although it does not follow any external commands like a herding dog would, the actions it needs to do are already programmed so that it follows the principles of herding behavior. This robot is autonomous and can detect the herd and members of the herd getting away from it, prompting it to close the gap and maintain cohesion while leading the group. The behavior of this robot resembles a mathematical model that explains herding behavior, which is essentially derived from how herding dogs follow the commands given to them.

Mathematical model for herding behavior:

The principles of herding behavior have been mathematically modeled and found to be applicable in different fields, since herding behavior can be seen as a way of achieving and maintaining cohesion within a group of elements. The principles are two: the herder (in this case the sheepdog) has to keep the group together, and the herder has to drive the group forward. The sheepdog keeps the group together by closing gaps between members of the group that have gone astray. This is achieved by getting in front of the stray animal, which will always move away from the dog and towards the group. The herder moves the group forward by leading it from behind, as the sheep will always move away from the dog. The dog will cycle between keeping the group together and moving it forward. This mathematical model has been proven to resemble the behavior of real herding dogs, and could be applied in different fields such as human crowd control, cleaning of debris and control of swarm robots. Although my experiment will not center on or implement this mathematical model, a herding robot could be programmed to follow this mathematical model and use computer vision with an ultrasonic sensor to carry out herding on its own, as the mathematical model already takes into account the commands given to a herding dog.

Design and Purpose of the experiment:

Because a robot that replicates herding behavior already exists and so does a mathematical model that explains this behavior, my experiment will center on the commands herding dogs receive and attempt to replicate them with a kittenbot in order to prove that in a larger context a remote-controlled robot will be able to carry out herding as efficiently or more efficient than a herding dog. This would be the first step towards creating an autonomous robot that can carry out herding. While the experiment will be carried out only with microbits (which use radio signals), it is worth stating that it should work with different kinds of communication, such as Bluetooth and voice input, provided the necessary hardware and software is available. The experiment will also focus only on commands related to locomotion, sensors could be added to allow the robot to sense distance on its own and group the herd on its own.  A LearningBot that turns when it detects things in front of its ultrasonic sensor will be used as the subject to be ā€˜herdedā€™ by the kittenbot.

Materials and software needed for this experiment are:

  • Two Microbit microcontrollers
  • One kittenbot (or any robot that supports microbit) fit with two wheels, each attached to a different motor.
  • Microsoft MakeCode (to write the code for the microbit) or MuEditor (to code microbit in python). MakeCode was used for this experiment.
  • One LearningBot, fitted with two Servo Motors attached to wheels and an ultrasonic sensor. The robot was pre-programmed via Arduino to turn right when it detects objects in front of it.

Procedure:

  • Both microbits were programmed using MakeCode to send and receive numbers through their built-in radio transmitters.
  • A different number was programmed to be sent depending on the gesture performed with or on the microbit, such as a button or buttons being pressed or the microbit being physically tilted sideways.
  • The microbits were programmed to receive the numbers and use a series of ā€œif ā€ and ā€œelse if ā€ statements to determine the command the number gives. The same code was flashed into both microbits.
  • One microbit was left connected to the computer (which could be replaced with any other power source, such as a power bank, a wall plug or batteries), and the other one was plugged into the kittenbotā€™s microbit slot.
  • The kittenbot was turned on, able to be controlled via the microbit connected to the computer.
  • If a LearningBot is used, it will turn right when the kittenbot passes in front of it.

Code:

            The microbits were programmed with Microsoft MakeCode. They were programmed using MakeCodeā€™s drag-and-drop feature, which created a version of the code in JavaScript on the background. The JavaScript version of the code is shown below:

  1. let State = 0
  2. onButtonPressed(Button.A, function () {
  3. sendNumber(0)
  4. })
  5. onReceivedNumber(function (receivedNumber) {
  6. if (receivedNumber == 0) {
  7. MotorStopAll()
  8. showString(“F”)
  9. MotorRunDual(
  10. Motors.M1A,
  11. 150,
  12. Motors.M2B,
  13. 150
  14. )
  15. } else if (receivedNumber == 1) {
  16. MotorStopAll()
  17. showString(“B”)
  18. MotorRunDual(
  19. Motors.M1A,
  20. -80,
  21. Motors.M2B,
  22. -80
  23. )
  24. } else if (receivedNumber == 2) {
  25. MotorStopAll()
  26. showString(“S”)
  27. } else if (receivedNumber == 3) {
  28. MotorStopAll()
  29. showString(“L”)
  30. MotorRunDual(
  31. Motors.M1A,
  32. 150,
  33. Motors.M2B,
  34. 90
  35. )
  36. } else if (receivedNumber == 4) {
  37. MotorStopAll()
  38. showString(“R”)
  39. MotorRunDual(
  40. Motors.M1A,
  41. 90,
  42. Motors.M2B,
  43. 150
  44. )
  45. }
  46. })
  47. onGesture(Gesture.TiltLeft, function () {
  48. sendNumber(3)
  49. })
  50. onGesture(Gesture.TiltRight, function () {
  51. sendNumber(4)
  52. })
  53. onButtonPressed(Button.AB, function () {
  54. sendNumber(2)
  55. })
  56. onButtonPressed(Button.B, function () {
  57. sendNumber(1)
  58. })
  59. State = 0
  60. setGroup(1)
  61. forever(function () {
  62. if (true) {
  63. } else {
  64. }
  65. })

 

Carrying out the experiment:

            The kittenbot was supposed to mimic a sheepdog carrying out herding behavior. Through giving it commands with another microbit, the kittenbot displayed the first letter of the action and performed it. For example, if it received the command to go forward it would display an F, if it received a command to go backwards it would display a B, it would display R if it had to turn right and L if it had to turn left, and S if it had to stop. The idea behind having the kittenbot display the commands before executing them was to show that the kittenbot was acknowledging the command before executing it, just like a sheepdog acts when given a command. Because there were no sensors attached to the kittenbot, the commands given to it could only be related to the robot moving, with not much room for commands related to herding itself. This made the kittenbot resemble a remote-controlled car more than a sheepdog, but demonstrated that the robot was able to follow commands, setting the base for more complex features to be added, such as sensors and other methods of control.

Conclusions and possible improvements:

The robot acted with little delay after the action in the other microbit was performed, and while it was not equipped with any sensors to detect and group a group of things, it proved that it would be the first step towards creating a robot that carries out herding behavior, similar to a Swagbot. In an ideal scenario the robot would be much bigger and be mounted with sensors, such as an infrared/ultrasonic sensor in order to allow for more commands to be given to the robot, such as keeping within a certain distance of the group, and would also allow the robot to detect stray sheep/cow to close the gap, allowing it to behave more like a real sheepdog. A microphone could be added so that the robot detects voice commands or whistles of different pitches and acts on them, giving the user more control over the robot. Other types of control may also be experimented with. An analog controller (joystick), for example, gives more control over the movement of the robot. In conclusion, a robot will be able to apply the principles of herding behavior with further improvements such as a different interface from which to control it and sensors that give it more autonomy and increase the number of possible commands that can be given to it. Once this is implemented, a fully autonomous herding robot could be developed that has the herding commands written in its code and applies them to the mathematical model for herding behavior.

Works Cited

Association, Press. Sheepdogs Could Be Replaced by Robots After Scientists Crack Simple Process. 27 August 2014. <https://www.theguardian.com/uk-news/2014/aug/27/sheepdogs-replaced-by-robots>.

Klein, Alice. Cattle-herding Robot Swagbot Makes Debut on Australian Farms. 12 July 2016. <https://www.newscientist.com/article/2097004-cattle-herding-robot-swagbot-makes-debut-on-australian-farms/>.

Strombom, Daniel and Andrew King. Why We Programmed a Robot to Act Like a Sheepdog. 21 May 2018. <http://theconversation.com/why-we-programmed-a-robot-to-act-like-a-sheepdog-96961>.

Leave a Reply