|By Jonas Jacobi||
|April 1, 2013 03:31 AM EDT||
At Kaazing, we have been experimenting with using a smartphone as a remote control for quite some time now. Those familiar with our demos may have seen our Zing-Pong demo (which is a “Pong”-style game using smartphones to control the paddles over WebSocket) or our Racer demo (which is a 3D Formula One car rendered in WebGL as a Chrome Experiment, and remotely controlled with a smartphone). These demos, along with the other demos we’ve created with Kaazing’s platform, use no plug-ins. You simply point a browser on your computer to the address of the object you want to control (for example, the gorgeous Formula One car rendered in WebGL) and a browser from your smartphone to the address of the remote control (an ID we generate for you). Once connected, you just…go!
A couple of our Visionary Zingers, Prashant Khanal and David Witherspoon, then experimented with communicating with a Raspberry Pi using WebSocket–or, more specifically, using Kaazing’s JMS-over-WebSocket Gateway to tell Raspberry Pi to turn on and off a lightbulb. When the lightbulb turned on in this experiment, another lightbulb turned on: could we in fact turn a remote, radio-controlled car into a remote, WebSocket-controlled car? By controlling the car over the Web, could we control the car from another room? From another continent?
The Racer Demo
Let’s first take a closer look at the Racer demo. The Racer demo uses the reflector pattern: where we connect devices through a WebSocket server, thus simulating peer-to-peer connectivity, a very easy-to-achieve task using pub/sub. When we developed the Racer demo, we walked through the steps to build it in The Simplest Way to Use Your Smartphone as a Game Controller: A WebSocket Race Car Demo. By examining how to use pub/sub concepts to control a virtual car, it’s not so farfetched to consider doing the same with a radio-controlled car.
After working with the Racer demo, we knew what we wanted to achieve: controlling a “real” car (or at least a good-sized monster truck model) with a simple web app on a smartphone. Something like this, for example:
And something that might move like this:
In just a few hours of hacking and experimenting, we turned this radio-controlled car into a WebSocket-controlled car. Don’t worry, no actual cars (or bunnies) were harmed in the making of this demo, as you’ll see as we walk through the hardware and software we used.
Ingredients: The Hardware
- One RC car. We ended up using a black F150. The bigger the car, the easier it is to connect, position, and hide the building blocks. One thing to pay attention to is that the car you’re about to buy has to have two simple motors, one that drives the vehicle forward/backward, and another one that steers the car: front wheels left/right. The first thing you’ll get rid of is the radio control, so don’t worry about that too much.
- One Raspberry Pi, model B. This piece of hardware is incredible. Runs Linux (and Java), has 512MB RAM, an Ethernet port, 2 USB ports (for keyboard, mouse, WiFi), takes an SD card, has an HDMI out, and has a handful of GPIO (General Purpose Input/Output) pins to drive external devices, like lights, motors, and alike.
- One small breadboard. This simplifies connecting the building blocks.
- Set of male to male and male to female jumper leads.
- L298N Board: It is used to control the car motors. The car is equipped with two motors – one for steering and the other to drive wheels. Each motor is controlled through two GPIO pins.
- A couple of LEDs – optional. This RC car model didn’t come with any lights, but who has seen a serious RC car without lights – so we equipped ours with remote controllable LEDs.
- One smartphone (can be substituted by a tablet, or any Web browser, really). Using a touch-based device makes the controlling more natural, but you can use any laptop/desktop browser with mouse/trackpad as well.
- Battery. Anker Astro 5600 mAh external battery pack powering the Raspberry Pi and connected circuits: LEDs and relays.
The circuit diagram regarding the wiring among the Raspberry Pi GPIO pins, L298N board and the car battery can be found here. The pin numbers specified for the Raspberry Pi in the circuit diagram refers to the physical pin location.
Ingredients: The Software
- WebSocket Java client code. The Kaazing Java client runs on the Raspberry Pi, receiving messages from the WebSocket server, and instructing the Raspberry Pi GPIO pins to control the car. Control of the GPIO pins is achieved through the Pi4J Library.
Reviewing the Hardware
We decided to hide all the electronics in the body of the car, but wanted to have the Raspberry Pi accessible and more importantly, visible. It’s sitting on the truck’s plateau, lightly taped to it, so it doesn’t fall off as the truck accelerates and comes to sudden stops (read: bumps into things).
On the right you can see the WiFi plugged into the top USB port (blue LED). On the left, you see the blue SD card. The GPIO ports are on the top left, connected to drive the two motors and the lights of the truck. The Raspberry Pi is powered through a micro USB port on the bottom left, leveraging a smartphone quick charger battery.
Reviewing the Software
To enable the Raspberry Pi to receive WebSocket messages from the browser client, we had to write some logic that runs on the Pi.
Since we plan to use this demo at trade shows, we wanted to make sure that we have a certain level of control over who controls the car and when. Therefore, we use a “secret” key that the remote control has to know to control the car. This key is sent to the code running on the Pi via a secured admin topic. Every message coming from the smartphone has to contain the same key. If it doesn’t, the message is thrown away.
The remote control client on the smartphone first asks for the key that identifies who can control the car.
Then, the HTML5 remote control code, which runs on the smartphone, first establishes a connection to the WebSocket server. It creates a JMS topic, and a producer (or publisher) for the topic. When done, the client is ready to start sending messages through the WebSocket gateway to the Java code running on the Pi. Every message contains the previously specified key as well, as a custom JMS message property.
Java Code Running on the Raspberry Pi
We chose to program the Raspberry Pi using Java. Instructions to install Java on the Raspberry Pi can be found here. The Java code on the raspberry requires both the JMS Kaazing Websocket Library to receive messages from the client, and the Pi4J library to interact with the car through the Rasbperry Pi’s GPIO .
The code is split into two main classes, CommandReceiver and Car. CommandReceiver is responsible for connecting to the Kaazing JMS Gateway and listening to both on the command and the admin topic. When admin messages are received the CommandReceiver will record which user has valid access to control the car. When a command message is received, its properties will be checked to see if it is the current user in control of the car. If so, the message will be parsed and read, resulting in a corresponding method being called on the Car class.
The Car class is an abstraction of everything the car may do. It has methods such as Steering, Thrust, and Lights that are called with Command parameters such as ON, OFF, LEFT, and RIGHT. When called, the GPIO inputs corresponding to each method and are switched on or off, thereby resulting on the motors of the car moving forward, backwards, or steering left or right.
To check out or download the full source code visit KaazingPi on Github.
Well, we cheated and already showed the video of the result at the beginning. But, if you want to see it in person, come see us at one of our upcoming events:
- HTML5DevConf: 1-2 April 2013. Palace Hotel, San Francisco
- NABSHOW: 6-11 April 2013. Las Vegas Convention Center, Las Vegas
- SIFMA Tech: 18-19 June 2013. Hilton New York, New York
The recent trends like cloud computing, social, mobile and Internet of Things are forcing enterprises to modernize in order to compete in the competitive globalized markets. However, enterprises are approaching newer technologies with a more silo-ed way, gaining only sub optimal benefits. The Modern Enterprise model is presented as a newer way to think of enterprise IT, which takes a more holistic approach to embracing modern technologies.
May. 25, 2015 11:00 PM EDT Reads: 5,915
The true value of the Internet of Things (IoT) lies not just in the data, but through the services that protect the data, perform the analysis and present findings in a usable way. With many IoT elements rooted in traditional IT components, Big Data and IoT isn’t just a play for enterprise. In fact, the IoT presents SMBs with the prospect of launching entirely new activities and exploring innovative areas. CompTIA research identifies several areas where IoT is expected to have the greatest impact.
May. 25, 2015 09:00 PM EDT Reads: 4,741
Every day we read jaw-dropping stats on the explosion of data. We allocate significant resources to harness and better understand it. We build businesses around it. But we’ve only just begun. For big payoffs in Big Data, CIOs are turning to cognitive computing. Cognitive computing’s ability to securely extract insights, understand natural language, and get smarter each time it’s used is the next, logical step for Big Data.
May. 25, 2015 08:00 PM EDT Reads: 1,862
The 4th International Internet of @ThingsExpo, co-located with the 17th International Cloud Expo - to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA - announces that its Call for Papers is open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
May. 25, 2015 07:00 PM EDT Reads: 1,514
There's no doubt that the Internet of Things is driving the next wave of innovation. Google has spent billions over the past few months vacuuming up companies that specialize in smart appliances and machine learning. Already, Philips light bulbs, Audi automobiles, and Samsung washers and dryers can communicate with and be controlled from mobile devices. To take advantage of the opportunities the Internet of Things brings to your business, you'll want to start preparing now.
May. 25, 2015 07:00 PM EDT Reads: 5,705
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
May. 25, 2015 04:00 PM EDT Reads: 2,431
P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at @ThingsExpo, Robin Raymond, Chief Architect at Hookflash, will walk through the shifting landscape of traditional telephone and voice services ...
May. 25, 2015 03:00 PM EDT Reads: 4,197
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
May. 25, 2015 02:00 PM EDT Reads: 4,139
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
May. 25, 2015 02:00 PM EDT Reads: 4,736
All major researchers estimate there will be tens of billions devices - computers, smartphones, tablets, and sensors - connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades. With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo, June 9-11, 2015, at the Javits Center in New York City. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be
May. 25, 2015 01:15 PM EDT Reads: 1,813
The security devil is always in the details of the attack: the ones you've endured, the ones you prepare yourself to fend off, and the ones that, you fear, will catch you completely unaware and defenseless. The Internet of Things (IoT) is nothing if not an endless proliferation of details. It's the vision of a world in which continuous Internet connectivity and addressability is embedded into a growing range of human artifacts, into the natural world, and even into our smartphones, appliances, and physical persons. In the IoT vision, every new "thing" - sensor, actuator, data source, data con...
May. 25, 2015 01:00 PM EDT Reads: 6,151
Container frameworks, such as Docker, provide a variety of benefits, including density of deployment across infrastructure, convenience for application developers to push updates with low operational hand-holding, and a fairly well-defined deployment workflow that can be orchestrated. Container frameworks also enable a DevOps approach to application development by cleanly separating concerns between operations and development teams. But running multi-container, multi-server apps with containers is very hard. You have to learn five new and different technologies and best practices (libswarm, sy...
May. 25, 2015 12:00 PM EDT Reads: 1,799
SYS-CON Events announced today that DragonGlass, an enterprise search platform, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. After eleven years of designing and building custom applications, OpenCrowd has launched DragonGlass, a cloud-based platform that enables the development of search-based applications. These are a new breed of applications that utilize a search index as their backbone for data retrieval. They can easily adapt to new data sets and provide access to both structured and unstruc...
May. 25, 2015 12:00 PM EDT Reads: 1,743
There's Big Data, then there's really Big Data from the Internet of Things. IoT is evolving to include many data possibilities like new types of event, log and network data. The volumes are enormous, generating tens of billions of logs per day, which raise data challenges. Early IoT deployments are relying heavily on both the cloud and managed service providers to navigate these challenges. In her session at Big Data Expo®, Hannah Smalltree, Director at Treasure Data, discussed how IoT, Big Data and deployments are processing massive data volumes from wearables, utilities and other machines...
May. 25, 2015 10:00 AM EDT Reads: 4,045
Buzzword alert: Microservices and IoT at a DevOps conference? What could possibly go wrong? In this Power Panel at DevOps Summit, moderated by Jason Bloomberg, the leading expert on architecting agility for the enterprise and president of Intellyx, panelists will peel away the buzz and discuss the important architectural principles behind implementing IoT solutions for the enterprise. As remote IoT devices and sensors become increasingly intelligent, they become part of our distributed cloud environment, and we must architect and code accordingly. At the very least, you'll have no problem fil...
May. 25, 2015 10:00 AM EDT Reads: 1,728
SYS-CON Events announced today that MetraTech, now part of Ericsson, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Ericsson is the driving force behind the Networked Society- a world leader in communications infrastructure, software and services. Some 40% of the world’s mobile traffic runs through networks Ericsson has supplied, serving more than 2.5 billion subscribers.
May. 25, 2015 09:45 AM EDT Reads: 1,075
The worldwide cellular network will be the backbone of the future IoT, and the telecom industry is clamoring to get on board as more than just a data pipe. In his session at @ThingsExpo, Evan McGee, CTO of Ring Plus, Inc., discussed what service operators can offer that would benefit IoT entrepreneurs, inventors, and consumers. Evan McGee is the CTO of RingPlus, a leading innovative U.S. MVNO and wireless enabler. His focus is on combining web technologies with traditional telecom to create a new breed of unified communication that is easily accessible to the general consumer. With over a de...
May. 25, 2015 06:00 AM EDT Reads: 4,650
Disruptive macro trends in technology are impacting and dramatically changing the "art of the possible" relative to supply chain management practices through the innovative use of IoT, cloud, machine learning and Big Data to enable connected ecosystems of engagement. Enterprise informatics can now move beyond point solutions that merely monitor the past and implement integrated enterprise fabrics that enable end-to-end supply chain visibility to improve customer service delivery and optimize supplier management. Learn about enterprise architecture strategies for designing connected systems tha...
May. 25, 2015 05:00 AM EDT Reads: 5,828
Cloud is not a commodity. And no matter what you call it, computing doesn’t come out of the sky. It comes from physical hardware inside brick and mortar facilities connected by hundreds of miles of networking cable. And no two clouds are built the same way. SoftLayer gives you the highest performing cloud infrastructure available. One platform that takes data centers around the world that are full of the widest range of cloud computing options, and then integrates and automates everything. Join SoftLayer on June 9 at 16th Cloud Expo to learn about IBM Cloud's SoftLayer platform, explore se...
May. 25, 2015 04:45 AM EDT Reads: 3,052
SYS-CON Media announced today that 9 out of 10 " most read" DevOps articles are published by @DevOpsSummit Blog. Launched in October 2014, @DevOpsSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that produce softw...
May. 25, 2015 04:15 AM EDT Reads: 4,027