Richard is a Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the aerospace industry.
My pick this week is Sphero Connectivity Package.
If you like MATLAB, then you probably enjoy playing with technical toys. If so, then this post is for you. Sphero is an inexpensive differential-drive robotic ball that can be controlled from a Bluetooth enabled device. It features a number of sensors (accelerometers, gyros, back-emf encoders) which allows it to measure its position and velocity with a fair degree of accuracy. The Sphero’s RGB LEDs allow it to glow in any color of choice, while the blue back LED indicates its current orientation. Two wheels allow the Sphero to roll on the ground and to rotate along its vertical axis.
While playing with the Sphero via your phone or tablet can be fun, being able to use your engineering skills and MATLAB and Simulink to interface with and control the Sphero is a blast.
The Sphero Connectivity package allows us to communicate with a Sphero from within MATLAB (and Simulink), on a computer running either Windows or 64-bit version of Mac OS 10.7 or earlier. The package is mainly based upon a “sphero” class, which in turn relies on the MATLAB Bluetooth class. The class methods and properties allow you to perform (within MATLAB) many operations available with the underlying Sphero API, such as connecting, disconnecting, sleeping, changing LED colors, reading (and/or streaming back) the Sphero’s position and velocity, and commanding each of the 2 motors independently. A higher-level roll command can also be used to move the Sphero with a certain speed and direction. The Simulink library contained in the package also features Simulink blocks for setup, timing, and basic sensing and actuation.
The readme.txt file explains how to pair up the Sphero to your computer, install the package, and create Sphero objects in MATLAB, while several examples are also included to illustrate the use of the available commands and Simulink blocks.
Along with the Sphero class and corresponding Simulink library, the package includes a number of MATLAB examples and Simulink models the user can start from to develop their own custom controls. Below are position plots for a couple of the supplied examples.
What patterns can you get Sphero to trace?
Danvir’s Sphero Connectivity Package provides a great example of how you can interface MATLAB and Simulink with hardware. If you have a Sphero (or just need an excuse to buy one) give it a try and let us know what you think here or leave a comment for Danvir.
Published with MATLAB® R2018a
コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。