Sessions is temporarily moving to YouTube, check out all our new videos here.

Hacking Animatronic Dinosaurs with the Raspberry Pi and Node-RED

Neil Ford speaking at Bristol JS in April, 2017
26Views
 
Great talks, fired to your inbox 👌
No junk, no spam, just great talks. Unsubscribe any time.

About this talk

See what you can do with a Raspberry Pi and Node-Red to juice up your robot t-rex (you've got one of those, right?)


Transcript


Neil Ford: Thank you everybody for coming. That's me. That's where you can find me online and that's what I'm going to talk to you about today, hacking dinosaurs for fun and profit. We'll go through this and I've got some demos and hopefully you'll see that you can use something like Node-RED to do something a bit more fun than just industrial robotics or playing with some internet things, censors. Firstly I've got to make a confession. I do [00:00:30] not do JavaScript. Sorry, don't know one JavaScript programme from the other so don't go asking me really horribly technical questions about the backend because I know nothing. I do code in some Python but that's just good enough to teach kids GCSE. I don't really, I haven't been a professional programmer for nearly 20, 25 years and my last professional programing experience was on IBM midrange equipment. [00:01:00] IBM AS/400s writing for an insurance company. That was a long, long time ago. Just so that you know, if I make mistakes you'll understand it's because I don't actually know what I'm talking about. Okay. The premise. What was the idea? What was the project that we were asked to work on? There is a theme park on the Isle of Wight called Blackgang Chine. It's right on the south coast just near Ventnor. It's continually falling off into the sea because it literally is on the cliffs and they erode [00:01:30] each year. They used to have big fibreglass dinosaurs that were installed in the 1970's, featured on Blue Peter because they were flown in by helicopter by the Royal Air Force. Those had fallen apart. They'd all kind of crumbled to almost nothingness hence why there's no pictures. They decided to replace them, update the attraction, and they got these big robotic dinosaurs. [00:02:00] That's the head of the T-Rex. That T-Rex wouldn't fit in here. It definitely wouldn't fit height wise. It's huge. It's not the biggest one. The brontosaurus is even bigger. They come from China, they look awesome. Chinese, the artists that make them, they look absolutely fantastic. The engineering, it's okay but you do have to be a bit careful because apparently the Chinese don't know what an angle grinder is [00:02:30] and don't worry about leaving sharp edges and rough welds and all that stuff. Inside they're a little bit rough. Basically the problem was that the electronics they came with were, I'm being video'd so I'll be good, rubbish. Absolutely useless. They were 80's technology, solid state boards. They did only one thing and they kept breaking down, they kept blowing up. The boards just kept going bang. [00:03:00] The only thing the Chinese factory could do was send the park new boards and all the engineers had to do is run out into the park, open the cabinets, replace the electronics as quickly as they could, start the thing back up again and hope it didn't blow up in the next 25 minutes which on a couple of occasions happened. The owner of the park who you'll meet in a bit because I've got a video for you, basically wanted a better solution. Long story short I was contacted by [00:03:30] a colleague, lady by the name of Dr. Lucy Rogers who if any of you have watched Robot Wars you'll know who Lucy is. She's one of the judges. She knows the park's owner. He said, "Can you help? We want to use Raspberry Pis." She said, "Yeah, I know people who can help," contacted me, and said, "Do you want to go the Isle of Wight and hack dinosaurs?" "Yeah." "Oh, and they'll pay you." "You had me at hack dinosaurs but yeah." Since October 2014, yeah, yeah. We're [00:04:00] in our third year. We've been going out about twice a year working with the park staff and basically helping them to replace the rubbish electronics with reliable electronics. As I said, basis of the project is the Raspberry Pi. Does everybody know what a Raspberry Pi is? Yeah? I don't need to do the this is a Raspberry Pi thing, right? Picture in the corner but I mean I do have, that's an original one with the old model B. That's the latest iteration which is [00:04:30] the Pi Zero which is the size of a stick of gum and yours for about a fiver or nine quid if you want the one with built in wi-fi. Great, single board, general purpose computer. Made in the UK, designed in the UK, and actually remarkably capable and it allows you to plug stuff into it easily with the pins. The GPI pins which when you want to drive motors and listen to sensors is great. The other part of [00:05:00] the puzzle was Node-RED written by IBM, made available as open source software, and it is basically a way of plugging together internet of things devices, predominantly that's kind of what they designed it for. It's been used for lots of other interesting things but it's basically a way of just easily joining lumps of code together into what they call a flow, because the stuff usually flows one [00:05:30] side to the other and it's really easy to get to grips with if you're a non-programmer, which the guys who work at the park are. They aren't programmers, they're mechanical engineers. They know how to fix a theme park ride but what they don't know is how to code. We could have done this in Python because that's what most people use when they start talking about the Raspberry Pi and wanting to access the GPIO but trying to teach guys Python and having them have to go in and ... No. This turned out to be the ideal solution. [00:06:00] What could possibly go wrong? We're going to hack some dinosaurs. This thankfully is not one of ours. This belongs to a jewellery shop on the Isle of Wight and one Friday night a bunch of wags from the pub that you can just see in the background of that picture decided to move it and they stuck it in the middle of the road. This appeared on Twitter, this gentleman here, and it went all over and we started getting tweets. "Is this one of yours? Are you guys responsible?" [00:06:30] "No, no, no. It's nothing to do with us." What could possibly go wrong? We're going to hack some dinosaurs. What actually happened? We went out, as I said, we went out in October 2014 and we spent some time with the guys showing how Node-RED works, what we could do with the Raspberry Pi, figuring out what we needed to be able to interface with the motors. The dinosaurs use 24 volt truck wiper [00:07:00] motors on a simple cam. Yeah? Chinese really go for kind of like basics. They could get a load of truck motors cheap, that's what they were going to use. But they actually work and they're quite reliable. They go around quite happily, but it's obvious 24 volts and you have to be a bit careful. Hopefully if everything goes according to plan I've now got a very short video which will probably explain just as well as I can what happened. Thanks to Reuters for this. It's one a number. Reuters: [00:07:30] Until recently the animatronic dinosaurs ... Neil Ford: Oh, volume. Reuters: ... were looking a bit tame. They with a limited sense of reprogrammed, predictable motions. Owner Alexander Dabell wanted to figure out a way to give them more bite. Dabell: How do we get more out of our dinosaurs? How do we get them to be more interactive? How do we get them to be more intuitive to what it is that we want? Reuters: [00:08:00] Dabell put a message on Twitter looking for someone to hack his dinosaurs. IBM's Andy Stanford-Clark jumped at the chance. Installing Raspberry Pi min computers and using IBM's cognitive computing platform, new randomised routines for different scenarios are now programmable. Dabell: Technology such as the Raspberry Pis are integral into how we can adapt the lighting, the sound, [00:08:30] the pyrotechnics to make everything come more to life, seem more realistic. Reuters: Andy Stanford-Clark works advancing to make the park interactive and more connected. Stanford-Clark: One of the examples in the operation of the park is the brontosaurs has a very long neck, he needs a neck brace when the wind is high to stop it falling over. We're getting data from the weather station sending alerts out to people's mobile phone to say, "Send the crew out with the neckbrace to prop the dinosaur up." The maintenance and operation of the dinosaur with a complicated [00:09:00] seven motors and control logic is exactly the same as we see in factory automation or in a pumping station or in a water company or any number of things. What appears to be having fun with dinosaurs here has actually got some serious applications for the internet of things. Reuters: Founded in 1843, based on the south side of Britain's Isle of Wight, Blackgang Chine is one of the world's oldest theme parks. By injecting new life into their robo-lizards the team here hopes they [00:09:30] won't be next to go extinct. Neil Ford: This some links to some other videos. The mid one's the video you've just seen. The top one is a nice video that's been put together by IBM. They sent a professional film crew out with a drone and did a really nice video. The bottom one is from our very first trip, a friend of mine who's video crew came out with us and shot a five minute video of what we got up to. I'm going to put all these links online so if you want to look at them later you can but just so you can have a look. Yeah. [00:10:00] As you saw from that video Andy joined us, Andy Stanford-Clark who is an IBM distinguished engineer and master inventor. He's got one of the coolest job titles ever and he basically gets to do this stuff for a living for IBM. He just gets to muck about with stuff. As I say, we spent two years. What we have done as we say we've gone from these rubbish Chinese electronics. Every single dinosaur on the park now has had its controlling electronics replaced [00:10:30] by a Raspberry Pi with a wi-fi connexion, so they're all on the network. Then we are using a custom designed board, it's actually built for another project. It was built for testing rocket engines would you believe? We're using a custom board that controls the motors and handles the inputs. At the moment all the dinosaurs are triggered by simple passive infrared sensors, so the kind of things you see in burglar [00:11:00] alarms. Probably one in here somewhere. They're positioned around the park and when the guests pass them that triggers the appropriate dinosaur. One advantage of the controller boards that we're using is there are opto-isolated, which means they're using optical relays to open and close connexions to the motors. That allows us to completely keep the 24 volts that the motors run at and the five volts [00:11:30] the Raspberry Pi runs at completely separate. There's no risk of 24 volts jumping across and blowing up the Raspberry Pi. That's made a big difference because that was one of the things we were really worried about initially is a lot of the initial boards we started looking at to control the relays weren't isolating and there was a risk of the voltage coming back, especially when we took the power supply out of one of ... Chinese supplied power supplies out and [00:12:00] our electrical engineer starting putting a metre over it and went, "I'm surprised somebody hasn't been electrocuted." It turned out that the power supplies were rubbish as well, so they've all been replaced. In actual fact the biggest problem we've found is the amount of juice that the motors draw on startup, the T-Rex draws about a thousand watts when you power it up. It's had to have a really massive power supply put in just to make it start up properly every morning. That's the beauty. By doing this we've been [00:12:30] able to kind of go around and make sure that each of the dinosaurs is properly configured. The Raspberry Pi also handles playing the audio file, so it plays MP3s out through car stereos, amplifiers, because again it's what the Chinese factory found. It's got car stereo, got car stereo amps, and they're playing out the MP3 files and using Node-RED it means that the dinosaurs are completely [00:13:00] reprogrammable. They can be changed on the fly in real time if necessary, made to do different things. As Andy mentioned in the video able to do random things. The biggest problem was that the dinosaurs when they arrived only have one fixed set of motions and they did the same thing every time they were triggered. The first thing we started looking at was how do we add random functionality so that one time it moves its head, one time it moves its arms, it wags [00:13:30] its tail, or does a combination thereof and changes each time around? We got to that point. As I said, big point is that is being done by the guys that work at the park, the technical team and the engineers. It's not being done by me, it's not being done by Andy, it's not being done by Lucy. We're not involved on a day-to-day basis. The park can look after this themselves and they can quite easily make those changes and do different things and add new bits and pieces. [00:14:00] That's what we got. Top left hand corner, that's DD, desktop dinosaur. She's also featured on Robot Wars. She came about because the first time we were there I went, "It'd be really cool if we could take one of these to school because kids would love this and we could change the programming." I go back the next time, Alec's going, "I've ordered your dinosaur." I go, "What one?" "The desktop one. Take it to schools." "Oh, I was kidding." "I'm not," He says. "I think it's a really good idea." We now have DD and she goes all [00:14:30] over the place, actually primarily she's been going around to conferences with IBM because they love her and they go, "Look what people are doing with that cool software and they're not doing industry robots, they're doing fun stuff." She goes around and she's used as a part of a workshop exercises we can do with kids. We can get kids to write programme. Little dinosaurs, like the ones you see in front of you. Yours from Maplins or even just simple representations with LEDs, so they turn LEDs on and off instead of driving motors. [00:15:00] But then they can take the software that they've done with that, put the SD card in DD's Raspberry Pi, power up, and she'll run their software. In actually fact she is configured with the same number of outputs as one of the real dinosaurs in the park so if we ever do a workshop on site we can take the kid's SD card out of DD, take them all out into the park, swap the SD card over with the real dinosaur, and that dinosaur will boot up and run the kid's code. Again, we've built this idea [00:15:30] of getting people kind of interested in what we do, in computing, in programing, but doing it in a way that's kind of a bit different. It's like you want to be a programmer you don't have to work in an office. You could be working on big robotic dinosaurs. I think the park's now got 20 dinosaurs. I'm actually back there on Friday. We're going out again on Friday so I must [00:16:00] remember to would around and count them so next time I do this I'll know exactly how many they've got. Yeah, so they've got about 20 dinosaurs and we're kind of doing some interesting stuff with them. Always dangerous when you do a talk, live demos. For those of you that have not seen Node-RED in action what I'm going to try and do now is show you, actually do some live, kind of live coding. Put together a little Node-RED flow and show you how [00:16:30] you use Node-RED. Then I've got a couple of live kind of examples of finished projects. Everything goes according to plan I can find my browser. Right, okay. When you run Node-RED or when you connect to Node-RED for the first time this is what you would normally see. Now this is Node-RED running on a Raspberry Pi. Doesn't have to run on a Raspberry Pi. It's a node application so you could run it on your laptop. If it'll run Node it'll run Node-RED. [00:17:00] You can run it on a server instance in the cloud and connect to their remotely. You just need a browser, that's all you need. That's one of the nice features about this. It means there's no running out to dinosaur with a laptop and a cable. Guys can sit in their office and monitor the dinosaurs and make changes from their office and seeing it. This is running on ... You probably can't see it very well. There's a Raspberry Pi 2 sitting back here that I've got connected via an ethernet cable just to be safe, because I didn't want to really try and do this over the wi-fi. [00:17:30] That's plugged in and driving this little dinosaur, this one here on my right, your left. Yours for 10 quid from Maplins. It's called the Action Dino and when you buy it it comes with a battery box and a switch and the motor and the address. It basically just teaches you how to build the electrical circuit and then when you flip the switch on the dinosaur nods and [inaudible 00:17:53] All we're doing is replacing that very simple switch with a slightly more complex box of tricks [00:18:00] and a little controller board. I'm using a board called the Pibrella in this case. Tiny little board that sits on top. It's got outputs that are capable of driving a motor which is kind of handy. It's also got a button and some LEDs and these are great for kids getting them to learn how to turn LEDs on and off and there's a little buzzer on it that buzzes. I've also plugged in a little speaker so that hopefully we can make it roar. One nice feature, Node-RED on the Raspberry Pi, if you [00:18:30] use a relatively up-to-date installation of Raspbian, which is the kind of official operating system for it which is a version of Debian, it comes with Node-RED pre-installed so you don't even have to do apt-get instal or anything like that or MPM instal. It's all there. It's in the menu. Just go up to the menu, do Node-RED, it fires up for the first time and then says do you want it to run all the time? Yeah, bang. It runs permanently. How do you do things in Node-RED? Simply, as I said, [00:19:00] it's drag and drop. As an example down the left hand side we've got all these kinds of nodes, input nodes. As you can see you can have different times of input. Inject is a simple kind of click on button. It's a way of manually causing something to happen. Most of the time you're going to use it with some kind of possibly external feed, if that's a sensor a button or a switch. It could be, [00:19:30] as you can see, it could be an MQTT feed so if you've used MQTT, the messaging protocol, you can have this connect to an MQTT broker, subscribe to a topic, and when that topic gets a new message you can bring it it, pass it, and do something with it. It'll work with HTTP, it'll work with websockets, you can even send it straight TCP, UDP. Even if you've got ... Actually Raspberry Pi could do it with [00:20:00] Zero or as you can see at the very bottom, and this is the one that IBM are really pushing and what we're going to be start playing with is Watson IoT. Taking input from Watson, IBM's machine learning platform Watson and pulling in information. You can also send it out. The next section down, outputs. Again debug is what it says it is. You plug that on the end you can see what your flow is generating and all the usual kind of things. Again, you can [00:20:30] publish MQTT messages so you could even have a flow on a publish to an MQTT broker and have a separate M read it back in. Or in the case where you might do that is with the Watson one. You might send something out to Watson, have a Watson process that's doing something and then you're reading back the feed. Then you've also got functions and you can do things like triggers and delays and you'll see what they're like in a minute. Lots of different [00:21:00] ways of ... You can even do things with files, with CSVs and JSON files, and that one just there. Random. They added that. We had to hand code that the first time because that wasn't there. We had somebody who actually did do JavaScript and able to write a random ... Move it up. Random. Now you can get it to generate a random value and have multiple outputs [00:21:30] so at the moment that just has one but as you'll see in a minute you can do multiples. Then you've got some social connexions. You've got email, Twitter, so it can receive emails, it can receive tweets, and it can send them. There are others and you can add more nodes. I'll show you in a minute that there's a load of stuff you can add. You can do things with files. You can even get input from a tail command. A few other bits and pieces. Then [00:22:00] the ones that are a bit specific to our purposes are the Raspberry Pi ones. You've got ones for input, GPIO. Ones for output. It will read a mouse click. You can read the keyboard and then the others are specific to particular pieces of hardware. In this case the Pibrella, that's the board I'm using. Rather than me having to know the specific GPIO pins that I want to access this allows me to select inputs and outputs [00:22:30] based on how they're labelled on the board. They're nice and simple so I don't have the know that output E is GPIO pin 24. I can just say I want to output E or I want to turn on the red LED. The same ... Outputs. There's LED board, which is a little LED, it's a multi-colored LED which is really cool because you can just send it through code and it changes colour. Then the sense HAT which is the board that Foundation produced which is the one that went up in the space [00:23:00] shuttle which has got an LED colour matrix on it and accelerometer and buttons and a few other sensors. It was used to do some stuff on the space shuttle but you can buy that yourself now. This, again, just hides some of the complexity behinds some simple drop-downs. There's the basics. Let's actually do something. We're going to start. I'm going to take an inject node and when you drag a node you can double click on it. It brings up what you can do. [00:23:30] You can tell it what kind of ... The thing you want to send. Default is a timestamp but you can say a string, a number, Boolean, a few other bits and pieces. I'm going to say a number though in this case it really doesn't make much difference. I give it a value, so I'm going to say one, and you can have it repeat. You can tell it [00:24:00] when it starts up the first time inject but I'm going to leave that. You can rename things. You can call things, give things names. I'm just going to call that start. Done. When I click the little ... I know you can't see it very well. There's a button on the left hand. I click it. That will ... I haven't deployed it. When you've made changes you need to click deploy. That sends it, turns the little button blue and that means I can now activate it so when I click it [00:24:30] it sends the one out of the output to whatever I connect to next. In this case simply what I'm going to do is I can't drive the ... If I try to drive the motor directly what would happen is it would just go on and it would stay on and I'd then need to pull the mains to turn it off. What I'm going to do is I'm going to use a trigger node to turn the motor on, then turn [00:25:00] the motor off. Okay? What I do is I drag the block across and then I drag a line between the two so that's now saying, as I send it out, and you can obviously do the one to many trick. You can have one input trigger many outputs. You could have one output, the other way around. You could have one to many and many [00:25:30] to one. You could have these all going in to triggering the same output if we wanted to. But for now we're just going to do the one. I'm just going to go in and it says what do I want to send. I send a number. Now if I was just turning something on or off I would probably send it one or zero, yeah? One to turn it on, zero to turn ... High and low. If I was doing an LED that would be great. Turn it on, turn it off. We'll [00:26:00] start with the LED. Turn the LED on and let's change the value, let's change that to three seconds because then you might just see it happen. Then send to Zero and on then ... Oops. On then off, and done. [00:26:30] Before I deploy it I'll grab an output so I'm going to grab the Pibrella output like that and then double click. It says what out? Select an output. In this case I'm going to grab the red LED. It's a digital output, just a simple high or low. Do I want to initiate the output state? Yeah, I'll leave it at zero [00:27:00] and again, just for neatness is name it. Now once you click start it should turn it off then off and it should affect the red LED. Deploy. Then when that's successfully deployed hopefully, I click start, some of you will be able to see hopefully that the red LED came on. If I do it again, [00:27:30] it came on for about three seconds and went off. That is Node-RED in its simplest form. Turn something on, triggered it by an input, triggered it on. Add a bit more ... Now I'm going to take another input node, so in this case this is a Pibrella input node and I'm going to use the button and get into [00:28:00] the habit of naming my nodes like that. Deploying. Now what should happen is push the button, the LED comes on, goes off. Push the button, LED goes on, goes off. There again as we saw earlier we had one to many, many to one. I've got two different inputs, both which will cause the same effect. What [00:28:30] we then want to do is ... That's great with the LED. What we're here to talk about is how we hacked the dinosaurs so what do we do differently with the dinosaurs, so it's driving the motors. Back up, find my trigger node again. I'm going to create a new one. Now, difference here is the value that I'm initially sending to [00:29:00] the next, the output node. The reason why I've used 15 is because the outputs on this board, as well as being driven as a digital output, as a simple on and off, they can also be done as a PWM output. Pulse width modulation, which allows you to control the way that the ... How long the circuit is open and closed for. The reason we're [00:29:30] using that rather than just turning the motor on and off is because the motor on these dinosaurs is actually designed to run at one and a half volts. It's not designed to run at the five volts that the Raspberry Pi's outputting. If I just turn it on the motor goes potty. Yeah? It would eventually just break. What we're doing here is going to be telling the Raspberry Pi only turn on the pin for 15% of [00:30:00] the cycle. Each 50 kilohertz? Yeah, 50 kilohertz. Only turn it on for 15%. That's about right to get the motor to drive as if it was running at one-and-a-half volts. It's just a way of cheating the system and I'm just going to call that motor trigger, just so that we ... Say done. Then connect that up. [00:30:30] Then grab a new output. Go down to Raspberry Pi section, grab another Pibrella output, connect it up. Which one? Now in this case I happen to know that I've plugged the wires into output E, so again as I said to you earlier no need to know which pins that is on the Raspberry Pi, just tell it which output on the board and Node-RED, the Node-RED node knows about [00:31:00] PWM output so we can tell it and we can just say motor. And deploy. Whoops. Deploy. Now hopefully what should happen is push the button and the motor doesn't run. This is probably because it's got stuck. Crowd: [inaudible 00:31:27] Neil Ford: Should work on the button you see so it could very well be that the motor ... Crowd: [inaudible 00:31:29] hit the button just hooked [00:31:30] up to the input. Neil Ford: Well done. Yes, thank you. See, I told you live demos, not very good. Let's start by testing the button in the ... Because sometimes also I think these motors do stick. Yeah, that's just the problem. Crowd: [inaudible 00:31:44] Neil Ford: See, I don't do live demos. It never works. Right. There we go. That's the motor running. Now if I reconnect the little cam, as you can see it is literally just a simple plastic ... It's just got a pivot and a simple cam [00:32:00] so very similar in actually fact to how the real ones work except they're on a much bigger ... Oh, hello. What's going on there. They're on a much bigger scale with much bigger motors. Effectively it's just the same fundamental, which is great because we can use these in the classroom. About 10 quid a pop. We can use these in the classrooms or at workshops and it at least gives people the ... Right, so now hopefully [00:32:30] and indeed one nodding dinosaur. That's a dinosaur ... Oh, and we're running ... Crowd: [inaudible 00:32:41] Neil Ford: Right, okay. That's the simplest, at its basic, yeah? The last thing we can add is I can make use of the exec one which basically allows you to run any [00:33:00] system command or any limit command and I'm going to have to do this. Give me a second. Dinosaur is capitalised. I thought it was. In this case I'm going to use it to ... MPG321-home-pi-dinosaur-roar.mp3. [00:33:30] Done. Bother renaming it so we can actually see the command. Deploy. Assuming I can type properly, which I probably can't, it hasn't played the MP3 file. It was working earlier. I know the MP3 [inaudible 00:33:57] If I do it from the command line it works so what have I got [00:34:00] wrong. Crowd: Spelling. Neil Ford: Ah, thank you. Oh yes, there it is. See? Should have saved that somewhere and just copied and pasted it. It would have been easier wouldn't it? I'm going to cheat. I'm just going to push, leaning over, Okay? Very simply and obviously on the park we've got much, much more complicated flows. As you will see in a second. [00:34:30] That should stay there. Here's one I prepared earlier. Now this, that looks like a nightmare doesn't it? That's because it's kind of a bit messy and I'll explain why it's messy in a second. This is live, this is the live flow that's running on the dinosaur on my left, so the one that's standing on top of the box. This one actually is using the battery to drive the motor using a slightly different controller board inside, [00:35:00] a tiny little board that's effectively just acting as an electronic switch and also there's a speaker inside. As before we've got an on so if I click on. Ah, didn't even need to do that because what happened was as you can probably see just here there's a Twitter input which is looking at Twitter and looking for various hashtags and/or the word Bristol JS. [00:35:30] If somebody Bristol JS, if the Bristol JS account tweets and I poll Twitter at the right point it will pick up the tweet and that's what triggers it. It also subscribes to an MQTT broker, one that's run by IBM that has a raw channel and if you send that channel to raw there's dinosaurs all over the country that if they're plugged in will all get turned off. They'll all get set off at the same time, they're all subscribed to that broker. As you can see that's a bit more [00:36:00] complicated. There's some delays in there. It's also rate limited. That's a quite useful one so I built a demonstration and I foolishly didn't put a rate limit in it and I tested it on the day that Davie Bowie passed and I thought, "I'll just try putting #Bowie and see what happens." The thing went mental. I learned about rate limits and I learned whatever you do don't pick a trending hashtag to test your project on because it will trigger it and it will trigger it lots. The thing that's in the middle that's a bit [00:36:30] messy with this, and I'll explain why it's a bit messy, is all this code in the middle and that looks like a nightmare. That's to make the LEDI's that I added to this dinosaur flash. That's one thing that Node-RED was never really designed to do was that rapid on/off that you need to make LEDs. It was never designed to do that. It was like, it's supposed to be kind of nice logical flows, maybe turn something on for a bit and then turn it off. That's why you've got the trigger. [00:37:00] What this is doing is effectively every 250 milliseconds it's using this switch statement to trigger the on and off. This function is coming back and it's basically going around in a horrible ... It's basically turning the pin high, low, high, low, high, low, high, low, high, low for two-and-a-half seconds which is roughly how long the MP3 takes to play and it should be how long the motor's running for. [00:37:30] Again, if I go back to the left hand edge and click on on again, oh, something's broken. What's broken? Something's broken. Could be the battery's run out. See, live demos. If it was working then, yeah, no response from server. I suspect that means it's either dropped off the wi-fi or something's died. If I clicked that on you would have noticed ... There we go. It's woken up again. Love these [00:38:00] things. I got the Dremel out, put two little holes in, two LEDs wired through it's body and it's got flashing eyes just to give it a bit more kind of a spectacle. I take this to events and I leave it plugged and I change the hashtags for the event, just leave it plugged in on a desk somewhere and every so often it roars. Then finally very quickly because I'm ... That's what's running the little trundle-y thing on the floor and that's using [00:38:30] a Pi Zero in this case. One of the original ones, not the new wireless one. It's got a wi-fi adapter plugged into it's USB port using a shim because obviously Pi Zeros have micro-USB, most wi-fi adapters are standard USB, just got shim. Effectively, again, it's listing to Twitter. It's also listing to the raw message queue for just shits and giggles but again it is ... What it does is it picks a random, generates a random [00:39:00] number and then based on that random number it triggers either both motors or the left motor, the right motor, and it basically spins. You'll notice there's four outputs but six outputs out of the movement one. That's because it drove off the table once. It now basically is weighted [00:39:30] so that it will more likely choose a left or right motion rather than forwards and backwards. If I put it on a table it should stay on the table. It did once drive itself off the edge and batteries went everywhere. It's running off four AAs, it's four AAs in the base of the motor, which actually runs it for quite a reasonable amount of time remarkably, because the Pi's not particularly energy efficient. It's not designed to be. It's designed to be run off a mains adapter. It will actually run, drive the motors [00:40:00] and run the Pi and the wi-fi and everything else for quite some time, quite happily off four AAs. There we go. It's been looking at ... Must be listing to Isle of Wight or something. I know I had some interesting Twitter ... Again, I've just got it debugging the Twitter output just so that I can see what it's doing. Very quickly, come on, give me [00:40:30] a new window. Right, no. Thank you. Node, assuming it loads. Node-RED website. It's under flows I believe. The reason why I brought this up is because I said earlier you could add extra things. People create new nodes for all sorts of really useful things and sometimes not so [00:41:00] useful things but if you've got a piece of hardware and you think, "Can Node-RED talk to it?" Chances are somebody's already done the work and there's load of this. You can MPM instal any of these so this is just, I think it just picks a random ... You can search, so I could search Raspberry Pi. Somebody obviously done something for PI GPIOD. Must be the demon. There's a Wemo, which is the little Belkin thing so you can control inputs and outputs from Wemos. [00:41:30] There's all sorts, all sorts of different bulletin. In actually fact I don't even know if it's on here but we've got dedicated ... We've written, or had written I should say because again earlier as I said, I can't do any of this, we've had written dedicated Node-RED nodes for the boards that we're using. Then the touch bridge board that we're using to drive the motors to read the sensors, we've had custom nodes written. Again the park guys don't have [00:42:00] to know GPIOs, they just have to know ... One of the things about the board we're using is it's actually chainable so each of the output boards has eight outputs but we can actually chain up to eight of those and have 64 outputs, which are then individually addressable. It's just a great big drop down list. You just go, "I want to drive output one, I want to drive output two, I want to drive output 44." I think the most we've actually gotten ... The T-Rex is the biggest dinosaur and that's got ... A minute. That's got eight but we have got the ability [00:42:30] to go on to bigger and bigger. Again, Nodered.org. You will find all sorts of really useful stuff so you want to play with Node-RED and you've got a particular piece of kit you want to play with chances are it's available. As I said, you don't have to run it on Pi, you can run it on your laptop. You can run it on a cloud instance. It's just a node JS app. That's kind of it for the demos. What's next? What are we up to now that we've done that? As I said to you I'm going back on Friday, [00:43:00] I'm on the ferry bright and early Friday morning. I've got three days on the island. These are some of the things we're working on, some of the things we're looking at. As well as having Blackgang Chine, Alex also owns another site which is called Electric Woods at Robin Hill. It's about 80 acres of woodland. It's designed as a woodland park and you walk through but it's also all lit up. There's lighting installations all over the space and twice a year for Chinese new year and Diwali they turn, [00:43:30] they light the place up at night and people go around and you can have a really nice time. They want to start looking at how we can use Node-RED and the Raspberry Pi to control some of that lighting, to make that lighting more interactive. To add audio, because again as you saw it can play MP3 files, and do all kinds of interesting bits and pieces with that, so we're looking at that. There is an interesting side to that is Electric Woods or Robin Hill Park is where Bestival is held. It's actually held in the field next door which he also owns and one of the things we want [00:44:00] to do is they actually have a couple of dinosaurs that are ... Portable's the wrong word. They're movable. They're about the size of this, well about the length of this space but they can be put in a van, taken over. We want to take the dinosaurs and we want to wire the dinosaurs into the sound system at Bestival and have dinosaurs boogieing to whatever's on the main stage. Some of you might know Ruth John, yeah? Well Ruth wants to make bikinis for the dinosaurs and I went, "Yeah." As you know she does some really interesting stuff with MIDI [00:44:30] and visualisations so MIDI inputs and Node-RED, the lighting, the sound system, the whole ... Alex is still a bit touchy about that one but anyway. They've just opened a new feature at Blackgang Chine called Underwater Kingdom. It's a new attraction. It's literally only open for the Easter Holidays and that's one of the things we're going to work on is seeing how we can add more interactivity to that so I haven't even seen what the installations are yet. I know they've got this crab, [00:45:00] big pink crab, that obviously talks to you but I don't know what else is there. Friday morning when we get there first thing we're doing is heading to the park with the kids and finding out what the park's got and, "How can we hack this? What can we do to it?" You've got a moose head there, that's the version without its skin. There is a version with its skin. This is so we could see how the motors are wired up. One of the things the Chinese is actually started doing is adding switches in so that the cam triggers a switch so you know whether or not it's open or closed. It's actually [00:45:30] designed to be mounted on the wall looking at you and we're starting to look at things like using Watson to do voice recognition and text-to-speech so that the heads when they're mounted could talk to you, tell you jokes, tell you what the weather is, and actually we had two guys from IBM. IBM have been really, really helpful. They're kind of going, "Yeah, you guys did some really cool stuff. Can we help you?" "Yeah, yeah, yeah,. We need somebody who knows how to do this." "We'll send you some engineers." And they did. Two of the I guys were told, "Right, you're going to the Isle of Wight for the weekend, all expenses paid. [00:46:00] You're going to go play with dinosaurs and moose heads." They spent two days hacking the head and by the end of it we had it, it was telling rude jokes and could tell you what the weather was. You could speak to it and go, "What's the weather like on the Isle of Wight?" It would go, "It's moosely fine." Okay, right, okay. Once we got rid of the kids we then started having it tell rude jokes. That's what we're working on is getting those so that we can start to ... Even looking at then doing computer vision so that we can do object tracking. Not necessarily face recognition but actually notice if somebody's walked past and have [00:46:30] the head move and say hello and things like that. Or even simple like is it a big person or a little person? If it's a big person you ignore them, if it's a little person say, "Hello," so the kids get ... Yeah? We're also looking at how we can do monitoring using MQTT so that we can start to tell if the dinosaurs, as Andy said in that video, about does the head need, does the brontosaur need it's neck brace? Also can we monitor the dinosaurs? Can we see if the dinosaurs are upright incorrectly? Also we want to get the dinosaurs [00:47:00] to start to communicate to each other so that if the T-Rex roars all the other dinosaurs shit themselves. They can't actually do that but you get the idea so that we can have dinosaurs ... There is actually a family of, there's a family of triceratops. There's a mom and there's a teenager and this little baby and we want them to all interact so when mom roars the baby and the teenager may or may not do something. If they do their mom will do something or not, or if the baby squeals then mom roars because somebody's upset the baby and all this kind of thing. We're looking at how we can use the networking features to have [00:47:30] the dinosaurs ... Again, just adding more and more interactivity. We're also looking at ways in which we can use pixel lighting, so this tiny little addressable LEDs to do really cool stuff. Did anybody ever see the Lexus car? Lexus covered a car with loads of pixels. Robin Hill have some of those Renault Twingos and we want to take one of those and put LEDs on that so it's driving around the park at night with colours going like this. It will just be awesome. We're also looking at how we can use micro-controllers, so Arduinos, [00:48:00] and similar boards because the Raspberry Pi's great but it does have some power problems and in certain instances it'd be better if we could run it off batteries and stuff like that. That's what we're working ... One of the other things we've got working on is the newer dinosaurs and this will not only just have motors but are now being fitted with pneumatics. You get a completely automated ... Oh, look. Two, three questions. Automated, much more flowing movement except we had to learn how to turn the valves down because the first time we triggered that we almost knocked somebody over with its [00:48:30] tail because it was at full whack. That's what we're doing, that's what we're playing with. Some of the people I mentioned earlier. Dr. Lucy Rogers. She was the person that really got ... I know the video said Andy responded to Twitter, that's not really true. Lucy was the person that kicked it off. Andy's obviously been a big help with IBM and he lives on the island, he lives just down the road so he was great. Obvious Blackgang Chine, that's where you can find them, and the Node-RED website. I will put these you online, I will put the slides online. Very quickly, [00:49:00] I think I'm allowed a couple of questions and again if you want to get a hold of me, you want to find me, you want to ask me questions that's where I am. Hopefully that was interesting. Yeah? Anybody got any questions or have I baffled everybody? Question 1: Node-RED, was the developed specifically for an open source application or was it [crosstalk 00:49:23] Neil Ford: I believe so. I mean, IBM have had a history of releasing stuff as open source. Some of it they [00:49:30] developed initially as in-house stuff and then were persuaded to release it, like MQTT. MQTT's now an open protocol, it's open source. It's what actually, it drives Facebook Messenger. It's the underlying technology behind Facebook Messenger. It was originally designed for oil platforms. Not oil platforms, oil pipelines to work over GSM connexions, so monitoring all the pipelines with mobile phones. IBM were persuaded to open it up and they did and I think they've seen the benefits and they've kind of ... My understanding is that Node-RED was always designed [00:50:00] to be an open thing. It was never designed to be completely closed. I'm not an IBMer so I can't say that for definite. Anybody else or are we done? One at the back. You're going to have to really throw that now. Oh, whoa. [inaudible 00:50:15] Question 2: Caught it first time. I imagine with those dinosaurs there's quite a complex chain of sequences that you might want to replicate. Can you, with Node-RED, can you build into a deployable artefact and then develop it on one machine and then deploy it [00:50:30] to a thousand? Neil Ford: Well, you can because you can export the flows. It's basically a JSON file so you can build the flow, export it, and then just import it and yes it'll, as long as everything ... Like I have backups of the dinosaur and I have backups of the little robot and yeah, you can. Again on the Node-RED website under that flow section as well as being able to find nodes you can find flows that people have created to do specific things and you can import them and import [00:51:00] just the whole flow. Yes, there is a way to do that. One of the things I hadn't shown you because it's not anyway near production quality is one of the things one of the teams has been working on is actually writing an API for the dinosaurs so that we can actually build dinosaur reactions in a ... I don't want to say a spreadsheet but effectively it's like a spreadsheet and then deploy that, send that to the node flow and the node flow will then use that to drive [00:51:30] it so we can say, "Move head, move tail." Tick the boxes and it builds but that's still in very, very rudimentary forms. Question 2: Never make that API public because I will be trying [crosstalk 00:51:39] Neil Ford: Yeah, it's like making ... Like we could hook the T-Rex up to Twitter but you could just imagine what would happen? People will go brah, rah, rah. We have talked about it. Or using voice activation so that Alex can sit in his office and go, "Make the dinosaurs roar," and they all roar at once, you know? Or listening to the ISS feeds so when the International Space Station comes over they all look [00:52:00] up. There's all kind of cool things that we want to play with so yeah, you could do all sorts of things but the API, that API, the dinosaur API's definitely in-house. I think that's me done, yeah? Yeah, that's me done. Thank you very much. Question 3: I've got one more. Neil Ford: Go ahead. Question 3: I hope I didn't miss this when I popped out. You talked before about open days where you can come along and hack the dinosaurs? Neil Ford: Yeah, we're doing ... That hasn't happened yet. As I said, we're back on Friday. [00:52:30] We have got a Raspberry Jam on the Sunday. That is one of the things that we kind of want to get to is with the Raspberry Jams is having people come and actually be able to connect to one of the live dinosaurs and play with it, or even if maybe not with the live ones at least with the portable ones, because we can get those indoors. We can actually bring them into where we work and they sit on the floor. We could quite happily have people come in and go, "Yeah, you want to reprogram the dinosaur? Not a problem." That is something we're working towards [00:53:00] but it's just persuading the boss that he thinks it's a cool idea. He's really keen to get kids involved. Little people as he calls them. He's really keen to get the kids involved and have them doing stuff so that's one of the things we're working on. Question 3: I want to hack dinosaurs. Neil Ford: I get to go and I get to do stuff. I'm a STEM ambassador so I go out to schools and I go, "Yeah, I hack dinosaurs." "What do you mean hack dinosaurs? Oh, really?" "Yeah, and you could do this too." Yeah, hopefully we'll have open days but like I say, I have got Raspberry Jam on Sunday [00:53:30] so we will hopefully have members of the public in and we can let you loose and play with at least one of the dinosaurs and tweak its programming and see it work. Question 3: Thank you very much. Neil Ford: Thank you.