|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 world's leading Cloud event, Cloud Expo has launched Microservices Journal on the SYS-CON.com portal, featuring over 19,000 original articles, news stories, features, and blog entries. DevOps Journal is focused on this critical enterprise IT topic in the world of cloud computing. Microservices Journal 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. Follow new article posts on Twitter at @MicroservicesE
Mar. 31, 2015 12:00 PM EDT Reads: 1,535
SYS-CON Events announced today that Litmus Automation 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. Litmus Automation’s vision is to provide a solution for companies that are in a rush to embrace the disruptive Internet of Things technology and leverage it for real business challenges. Litmus Automation simplifies the complexity of connected devices applications with Loop, a secure and scalable cloud platform.
Mar. 31, 2015 12:00 PM EDT Reads: 430
Internet of Things (IoT) will be a hybrid ecosystem of diverse devices and sensors collaborating with operational and enterprise systems to create the next big application. In their session at @ThingsExpo, Bramh Gupta, founder and CEO of robomq.io, and Fred Yatzeck, principal architect leading product development at robomq.io, will discuss how choosing the right middleware and integration strategy from the get-go will enable IoT solution developers to adapt and grow with the industry, while at the same time reduce Time to Market (TTM) by using plug and play capabilities offered by a robust I...
Mar. 31, 2015 11:46 AM EDT Reads: 280
SYS-CON Events announced today the IoT Bootcamp – Jumpstart Your IoT Strategy, being held June 9–10, 2015, in conjunction with 16th Cloud Expo and Internet of @ThingsExpo at the Javits Center in New York City. This is your chance to jumpstart your IoT strategy. Combined with real-world scenarios and use cases, the IoT Bootcamp is not just based on presentations but includes hands-on demos and walkthroughs. We will introduce you to a variety of Do-It-Yourself IoT platforms including Arduino, Raspberry Pi, BeagleBone, Spark and Intel Edison. You will also get an overview of cloud technologies s...
Mar. 31, 2015 11:00 AM EDT Reads: 2,200
Containers and microservices have become topics of intense interest throughout the cloud developer and enterprise IT communities. Accordingly, attendees at the upcoming 16th Cloud Expo at the Javits Center in New York June 9-11 will find fresh new content in a new track called PaaS | Containers & Microservices Containers are not being considered for the first time by the cloud community, but a current era of re-consideration has pushed them to the top of the cloud agenda. With the launch of Docker's initial release in March of 2013, interest was revved up several notches. Then late last...
Mar. 31, 2015 09:15 AM EDT Reads: 2,283
The WebRTC Summit 2014 New York, to be held June 9-11, 2015, at the Javits Center in New York, NY, announces that its Call for Papers is open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 16th International Cloud Expo, @ThingsExpo, Big Data Expo, and DevOps Summit.
Mar. 31, 2015 09:00 AM EDT Reads: 1,683
SOA Software has changed its name to Akana. With roots in Web Services and SOA Governance, Akana has established itself as a leader in API Management and is expanding into cloud integration as an alternative to the traditional heavyweight enterprise service bus (ESB). The company recently announced that it achieved more than 90% year-over-year growth. As Akana, the company now addresses the evolution and diversification of SOA, unifying security, management, and DevOps across SOA, APIs, microservices, and more.
Mar. 31, 2015 08:30 AM EDT Reads: 2,100
Wearable technology was dominant at this year’s International Consumer Electronics Show (CES) , and MWC was no exception to this trend. New versions of favorites, such as the Samsung Gear (three new products were released: the Gear 2, the Gear 2 Neo and the Gear Fit), shared the limelight with new wearables like Pebble Time Steel (the new premium version of the company’s previously released smartwatch) and the LG Watch Urbane. The most dramatic difference at MWC was an emphasis on presenting wearables as fashion accessories and moving away from the original clunky technology associated with t...
Mar. 31, 2015 03:00 AM EDT Reads: 1,541
SYS-CON Events announced today that robomq.io will exhibit at SYS-CON's @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. robomq.io is an interoperable and composable platform that connects any device to any application. It helps systems integrators and the solution providers build new and innovative products and service for industries requiring monitoring or intelligence from devices and sensors.
Mar. 30, 2015 06:00 PM EDT Reads: 1,566
The list of ‘new paradigm’ technologies that now surrounds us appears to be at an all time high. From cloud computing and Big Data analytics to Bring Your Own Device (BYOD) and the Internet of Things (IoT), today we have to deal with what the industry likes to call ‘paradigm shifts’ at every level of IT. This is disruption; of course, we understand that – change is almost always disruptive.
Mar. 30, 2015 04:00 PM EDT Reads: 1,179
SYS-CON Events announced today that Solgenia 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, and the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Solgenia is the global market leader in Cloud Collaboration and Cloud Infrastructure software solutions. Designed to “Bridge the Gap” between Personal and Professional Social, Mobile and Cloud user experiences, our solutions help large and medium-sized organizations dr...
Mar. 30, 2015 03:00 PM EDT Reads: 2,961
SYS-CON Events announced today that SafeLogic has been named “Bag Sponsor” of SYS-CON's 16th International Cloud Expo® New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. SafeLogic provides security products for applications in mobile and server/appliance environments. SafeLogic’s flagship product CryptoComply is a FIPS 140-2 validated cryptographic engine designed to secure data on servers, workstations, appliances, mobile devices, and in the Cloud.
Mar. 30, 2015 11:00 AM EDT Reads: 1,539
After making a doctor’s appointment via your mobile device, you receive a calendar invite. The day of your appointment, you get a reminder with the doctor’s location and contact information. As you enter the doctor’s exam room, the medical team is equipped with the latest tablet containing your medical history – he or she makes real time updates to your medical file. At the end of your visit, you receive an electronic prescription to your preferred pharmacy and can schedule your next appointment.
Mar. 30, 2015 10:00 AM EDT Reads: 928
GENBAND has announced that SageNet is leveraging the Nuvia platform to deliver Unified Communications as a Service (UCaaS) to its large base of retail and enterprise customers. Nuvia’s cloud-based solution provides SageNet’s customers with a full suite of business communications and collaboration tools. Two large national SageNet retail customers have recently signed up to deploy the Nuvia platform and the company will continue to sell the service to new and existing customers. Nuvia’s capabilities include HD voice, video, multimedia messaging, mobility, conferencing, Web collaboration, deskt...
Mar. 30, 2015 01:00 AM EDT Reads: 1,520
SYS-CON Media announced today that @WebRTCSummit Blog, the largest WebRTC resource in the world, has been launched. @WebRTCSummit 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. @WebRTCSummit Blog can be bookmarked ▸ Here @WebRTCSummit conference site can be bookmarked ▸ Here
Mar. 29, 2015 10:00 PM EDT Reads: 1,862
SYS-CON Events announced today that Cisco, the worldwide leader in IT that transforms how people connect, communicate and collaborate, has been named “Gold 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 City, NY. Cisco makes amazing things happen by connecting the unconnected. Cisco has shaped the future of the Internet by becoming the worldwide leader in transforming how people connect, communicate and collaborate. Cisco and our partners are building the platform for the Internet of Everything by connecting the...
Mar. 29, 2015 07:00 PM EDT Reads: 5,281
Temasys has announced senior management additions to its team. Joining are David Holloway as Vice President of Commercial and Nadine Yap as Vice President of Product. Over the past 12 months Temasys has doubled in size as it adds new customers and expands the development of its Skylink platform. Skylink leads the charge to move WebRTC, traditionally seen as a desktop, browser based technology, to become a ubiquitous web communications technology on web and mobile, as well as Internet of Things compatible devices.
Mar. 29, 2015 06:00 PM EDT Reads: 1,886
Docker is an excellent platform for organizations interested in running microservices. It offers portability and consistency between development and production environments, quick provisioning times, and a simple way to isolate services. In his session at DevOps Summit at 16th Cloud Expo, Shannon Williams, co-founder of Rancher Labs, will walk through these and other benefits of using Docker to run microservices, and provide an overview of RancherOS, a minimalist distribution of Linux designed expressly to run Docker. He will also discuss Rancher, an orchestration and service discovery platf...
Mar. 29, 2015 04:15 PM EDT Reads: 2,468
SYS-CON Events announced today that Vitria Technology, Inc. will exhibit at SYS-CON’s @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Vitria will showcase the company’s new IoT Analytics Platform through live demonstrations at booth #330. Vitria’s IoT Analytics Platform, fully integrated and powered by an operational intelligence engine, enables customers to rapidly build and operationalize advanced analytics to deliver timely business outcomes for use cases across the industrial, enterprise, and consumer segments.
Mar. 29, 2015 03:30 PM EDT Reads: 2,229
SYS-CON Events announced today that Liaison Technologies, a leading provider of data management and integration cloud services and solutions, 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. Liaison Technologies is a recognized market leader in providing cloud-enabled data integration and data management solutions to break down complex information barriers, enabling enterprises to make smarter decisions, faster.
Mar. 29, 2015 03:00 PM EDT Reads: 3,511