LEGO Mindstorms robots are fun robotics. Why use a USB cable to connect the LEGO® MINDSTORMS® EV3 Brick to your computer when Bluetooth connectivity exists? Connecting RoboCam to EV3

This section presents various Lego robots. Starting with Mindstorms - a robot for advanced users and even professionals, ending with legendary characters: Hero Factory, Ninjago, Chima, etc.


Let's start our story with an unusual Lego toy - an electronic interactive robot based on the NXT 2.0 processor! Even a 10-12 year old child can assemble it with the help of instructions! LEGO Robots mindstorms will appeal not only to children, but also to their parents, as it is very functional and its programming possibilities are truly endless! You can design your own programmable models!

It is very convenient to program the robot through a user-friendly program interface that can be installed from a disk! If desired, a set of functions can be selected by a combination of keys on the central control unit. Robot has very good functionality, which is achieved through interactive servo motors and special sensors that respond to light, sound, mechanical stress and other external stimuli!

Mindstorms can move in different directions, play sounds, distinguish colors, solve Rubik's cube, pick up non-heavy objects, guard a room, control a Lego train or car from a distance, and much more! In addition to the usual sensors that are supplied in the initial kit, you can buy other various accessories: various sensors, adapters, motors, batteries and much more, which will significantly expand the capabilities of your Lego robot!

The instruction, which is on the software disc, offers several initial, easy-to-assemble models of mindstorms: Robogator, Colored Ball Sorter, Room Guardian and some others.

Your child will never get bored, and learning design and programming skills in a playful way is also a very informative lesson!

Another episode is the Hero Factory. Heroes from the Hero Factory series are very colorful creatures, they are a hybrid of a human and a robot and their name is cyborgs! Figures of robots have movable arms and legs, they hold various weapons that help them fight the hordes of mutants that serve the Fire Lord.

This Hero Factory series is an analogue of Bionicles, so fans of cartoons about robots will gladly accept it.

Among the characters there are both good ones: Stormer, Fourno, Breeze and others, and negative heroes: Drilldozer, Jetbag, Von Nebula, who obey the powerful and evil Fire Lord. Try to collect the entire collection of Lego Robot Hero Factory figurines and arrange your battle for the triumph of good and justice!

The robot, assembled from the LEGO Mindstorms EV3 constructor, you can easily control remotely from the first person. To do this, you will additionally need two smartphones with the RoboCam app installed on one of them. Let's take a closer look at the RoboCam app and learn how to use it.

This article describes the new features introduced in the first version 1.0 of the RoboCam app. You can find all articles dedicated to the RoboCam application. The RoboCam app can be installed from the Google Play store.

First, let's watch a video showing a first-person robot I call the EV3 Explorer. In addition to the fact that the robot can travel in any direction, it can raise and lower its head, i.e. the frame to which the smartphone is attached. This means that you can look not only around, but also up / down.

What do you need to conduct an experiment?

To repeat the experiment that you see in the video, you need the following:

  1. Robotbuilt from the LEGO Mindstorms EV3 construction set.
  2. Android Smartphone with a camera and the RoboCam app installed on it. Supports Android 2.3 and above. The smartphone must have at least one camera, as well as Bluetooth and Wi-Fi modules.
  3. Smartphone or tablet with a modern browser with HTML5 support. Fit well and tested google browsers Chrome, Yandex Browser, Firefox and Opera latest versions... The operating system, in principle, can be any (Android, iOS or Windows), but full tests were carried out only on Android. A smartphone or tablet should have at least touch screen (preferably with recognition of at least 2 touch points) and a Wi-Fi module.

Connection diagram

First, let's see how all of the above devices are connected to each other. This is best illustrated in the figure below.

As you can see, the RoboCam app is installed on Smartphone 1. This Smartphone is attached to the robot and connected to it via Bluetooth. From smartphone 1 to the EV3 are commands that control the motors, information from the sensors comes back.

2nd smartphone or tablet, connects to smartphone 1 via Wi-Fi. Smartphone 1 and Smartphone or Tablet 2 must be connected to the same router. From smartphone or tablet 2, the coordinates of the joysticks go to smartphone 1, and the video stream from the camera goes back.

How EV3 is controlled

To get a better understanding of how the EV3 Robot is controlled, take a look at the following diagram.

When you start touching joysticks A and B, smartphone or tablet 2 transmits the coordinates of the touches to smartphone 1, which converts them into commands for the EV3 motors. How the coordinates are converted depends on the settings in the RoboCam app. We'll talk more about the settings below.

Assembling the robot

To repeat the experiment, first of all, you need to assemble a robot that you will control. It can be a simple two-wheeled robot, a robot car, or a robot with a complex movement mechanism. By and large, it doesn't matter what your robot will be, because the RoboCam program is flexible and you can use it to control a robot of any design. The main thing is that you can fix the smartphone on your robot so that the camera is directed forward, in the direction of travel.

I recommend starting with a simple model. If you have a LEGO Mindstorms EV3 educational set, then you can build the EV3 Explorer, which you see in the photo and video at the beginning of the article. Here is the assembly diagram for the EV3 Explorer:

Instructions for building the EV3 Explorer Version: 2

Instructions for building an EV3 Explorer Robot from the LEGO Mindstorms Education EV3 Basic Educational Set (45544).

In version 2: the frame is fixed more firmly and does not fall off.

04.06.2016 4.95 MB 5783

Preparing an Android smartphone and the RoboCam application

The RoboCam app works on smartphones or tablets running Android 2.3 or higher. The device must have any built-in camera and Bluetooth and WiFi modules. The app is free, you can install it using the Google Play store. Here is the RoboCam app page. To install, click the "INSTALL" button, and accept the required permissions by clicking the "ACCEPT" button.

After installation, open the app. On Android 6 and up, you will immediately see a prompt asking if you want to use the camera. We definitely need a camera, so click "ALLOW".

After the application opens, you will see three round buttons for basic actions, and in the background a picture from the camera.

The green button on the left is responsible for starting and stopping the RoboCam server, which is needed to connect a smartphone or tablet 2, see the diagram above. At the same time, the button shows whether the server is running or not. In the picture, the background of the button is white, it means that the server is down. The tip from above says the same. You can start or stop the server at any time by clicking on this button.

The middle purple button is responsible for connecting to the EV3 Robot. At the same time, the button shows whether the smartphone is connected to the robot or not. In the picture, the background of the button is white, which means that the robot is not connected. This button also has a hint, right under the button, where the connection status is displayed in the upper line (in the picture it is the inscription "EV3 not connected"), and in the lower line - the name of the current robot settings (in the picture it is "EV3 Explorer").

The button on the right opens the RoboCam settings. If you will be using my EV3 Explorer, there is no need to configure anything additionally. Right after the first launch of the application, the default settings will be called “EV3 Explorer”. If you have a different robot, then first you have to dig deeper into the settings. But let's talk about this below.

Launching and connecting to the RoboCam server

I must say right away that it doesn't matter what you do first, start the RoboCam server or connect your smartphone to the robot. This can be done in any order.

So, after the application is installed on smartphone 1 (see the diagrams above) and open, you can start the RoboCam server. To do this, click on the green button on the left, the button will start blinking, and the prompt will say "Initializing the RoboCam server ...". After a while, after the server starts up, the background of the button will turn green, and the prompt will say "The RoboCam server is running."

If the smartphone is not yet connected to your Wi-Fi router (like we have in the picture), then it's time to do it. Once connected, the top prompt on the second line will display the address to connect to the RoboCam server. When you turn on the server, it makes no difference what to turn on first, RoboCam server or Wi-Fi.

You can now connect to the RoboCam server. To do this, take a second smartphone or tablet (I will use a tablet), make sure that it is connected to the same Wi-Fi router, open the browser and go to the page with the address shown in the tip in the RoboCam application (in the picture it is “http : //192.168.1.153: 8088 "). You need to use a browser one of those described above. If you did everything correctly, the page for entering your username and password will load in the browser. Enter your username and password here and click the "Login" button. If after installation you did not change anything in the settings, then the default login is “admin” and the password is “123”.

After that, the main page of the RoboCam server will open, where you will see a picture from the smartphone camera 1 (see the diagram above).

As you can see, the orientation of smartphone 1 is portrait, and my tablet is landscape. You can turn smartphone 1 over so that it is also in landscape orientation... In this case, the picture on the tablet will automatically change to landscape.

Please note that orientation does not change if you have locked your smartphone 1.

To now make the image full screen, click on the icon in the upper right of the page. This will remove all unnecessary buttons, browser bookmarks, etc., and the image from the camera will become larger.

Connecting RoboCam to EV3

Before connecting the RoboCam App to the EV3, make sure your EV3 Robot and Smartphone have Bluetooth enabled and are paired. Also make sure that the motors are connected to the exact ports specified in the robot settings. The name of the current settings is written in the tooltip to the middle button on the second line, in the picture below, it is “EV3 Explorer”. If you assembled the EV3 Explorer according to my scheme (see above) and after installing the RoboCam application did not change the settings, then be sure that everything is configured correctly. More details about the settings will be written below.

So, if you're done, click on the center purple button. If you have bluetooth smartphone turned off, you will see a prompt to turn it on. Click Yes.

Then you will see that the button will start blinking, and instead of a hint, a list of devices paired via Bluetooth will appear. Select your EV3 robot here (in the picture it is “EV3”, but you may have a different name in your EV3 settings).

The app will then connect to the EV3.

If at this time the client is connected to the RoboCam server, then you will see the joysticks appear (rectangular and round joysticks in the picture below). After that, you can immediately control the robot.

In the default settings for the EV3 Explorer you will have two joysticks: round and vertical (see picture above). The vertical joystick controls the smartphone holder, and the round joystick controls the robot's movements. The palm icon on the top right, swaps joysticks to quickly switch between left and right handed controls. More details about joysticks will be written below.

Stopping the RoboCam Server and Turning Off EV3

After you have finished controlling your robot, it is recommended that you stop the RoboCam server and disconnect the EV3 from your smartphone before closing the RoboCam App. This can be done in any order. To stop the server click on the green button on the left. The background of the button will then turn white and the tooltip will show “RoboCam Server is Off”. To turn off the EV3, press the center purple button. After that, the background of the button will turn white, and on the prompt on the top line you will see the inscription “EV3 not connected”. In this case, the motors will stop or return to their original position, depending on the settings.

To go to settings, click on the gray button on the right.

The settings are divided into 2 parts: server settings and robot settings. First, let's see what's in the server settings. Select "Server".

Server settings are divided into 2 groups: camera settings and security settings. In the camera settings, you can select the camera (front or rear), image size and JPEG quality. The smaller you set the image size, the smoother and faster the video transmission to the client will be, but the picture quality will deteriorate. Video transmission and JPEG quality have a similar effect: how better quality JPEG (90 percent or more), the better the picture, but the slower the speed, and vice versa, the worse the JPEG quality (40 percent or less), the faster the speed, but the worse the picture. Choose what is best for you.

In the security settings, you can change the driver's name and password (by default, the name is “admin” and the password is “123”). Observers are also enabled by default. Observers can see the camera image in parallel with you, but they cannot control the robot. For the observer, you can also set a name and password (by default, the name "guest" and the password "123" are used). To disable observers, uncheck the "Allow observers" checkbox.

The number of drivers and observers is not limited, however, connecting more than one driver can cause conflicts while controlling and transmitting the video stream. It is not recommended to connect more than one driver to the RoboCam server. Large numbers of onlookers can also negatively impact video transmission. It is advisable to reduce the number of observers to a minimum or disable this function altogether.

After changing the settings, you can save them by clicking on the "SAVE" button on the top right or exit without saving by clicking on the "CANCEL" button or the arrow on the top left. After saving the server settings, clients may be disconnected and will need to connect again.

List of robot settings

The second part of the RoboCam software settings is the robot settings. Click Robot to go to the list of robot settings.

In the list of robot settings, you can see the settings for all your robots. You can add or remove settings at any time by clicking, respectively, the "ADD" or "DELETE" button at the top right. And right below the buttons, you can see the current settings. Using this item, you switch between the settings for your robots. Now let's take a look at the EV3 Explorer settings. To do this, select the EV3 Explorer from the list.

At the very top is indicated general information: robot name and description. The title and description are displayed in a list so you can easily find the settings you want. The name is also displayed in the main screen of the program under the center button with which you connect to the EV3. Below are the joystick settings.

In total, you can configure up to 4 joysticks, but at the same time, the client will see only one pair of 1-2 or 3-4 joysticks on the screen. However, if you use joystick 1 and 3, they will still not be visible at the same time, because belong to different pairs, and you will see either joystick 1 or joystick 3. The visibility of each joystick is turned on with a tick “ Visibility". If you have turned on 2 pairs of joysticks, a button will appear on the client's screen to switch between pairs.

So, in the settings you can see the groups "Joystick 1", "Joystick 2", "Joystick 3" and "Joystick 4". Each of them contains settings for one joystick. Let's see the settings for Joystick 1. The "Visibility" checkbox, as you already understood, shows or hides the joystick. If the checkbox is not checked, then the settings for this joystick will be hidden.

Slightly lower in the drop-down list “ The form»You can choose the shape of the joystick, and together with the shape and its characteristics. The following joystick shapes are available: vertical, horizontal, round, square, arrows, vertical arrows, and horizontal arrows. This is what the listed joysticks look like:

The vertical joystick perceives only the height of touching it, i.e. he doesn't care whether you touched him to the left or to the right, the main thing is at what height. The touch coordinate for it will range from -100 at the lowest point to 100 at the highest point with 0 in the middle.

The horizontal joystick works the same way, but horizontally. For him, it does not matter at what height the touch occurs, the main thing is left or right. Here, the tangency coordinate is calculated horizontally from -100 at the leftmost point to 100 at the rightmost point with 0 in the middle.

The round and square joysticks are similar. Here the coordinates of the touch along the horizontal and vertical axes are determined, also in the range from -100 to 100 s 0 in the center. But in a round joystick, touches cannot go beyond the circle. Those. if the tangent point is outside the circle, the point will be taken at the intersection of the line from the tangent point to the center of the circle with the circle. This can be seen more clearly in the figure below.

Joystick-arrows are not sensitive to the point of contact, the main thing is which arrow you touch. If you touch the up arrow, the vertical position of the joystick is considered to be 100 and the horizontal position is 0. For the down arrow, the horizontal position of the joystick will also be 0, and the vertical position will turn to -100. Likewise with the left and right arrows: the vertical coordinate of the joystick will be 0, and the horizontal coordinate will be -100 and 100, respectively.

Right below the form, select the type of joystick in the drop-down list “ A type". Here you can select one of the following: Independent Motors, Taxi 1, Taxi 2, and Mailbox.

Joysticks with types " Taxiing 1"And" Taxiing 2»Allow you to control a robot with two independent driving wheels, such as the EV3 Explorer. The coordinates of touching such joysticks will be automatically transformed into motor commands. For the joystick, you only need to choose which port will have the left and which will have the right wheels. But this will be written about below.

"Taxiing 1" will allow you to drive a two-wheeled robot like a car. Here, you cannot deploy the robot in place. The closer the touch is to the vertical center, the lower the speed. Steering 2 allows the robot to spin in place.

Joystick type " Independent motors»Converts the horizontal coordinate of the touch to motor commands regardless of the vertical coordinate. For the joystick, you will need to specify which motor will be controlled when the horizontal coordinate changes, and which when the vertical coordinate changes. This type of joystick can be used to control a car in which one motor turns the steering wheel and the other motor turns the drive wheels. In this case, the change in the horizontal coordinate must be configured for the rotation of the first motor, and the change in the vertical coordinate for the rotation of the second motor.

Joystick type " Mailbox"Will simply pass the coordinates of the touch to mailboxes EV3. In order for your robot to come to life, you will need to write an EV3 program that processes these coordinates. With this type of joystick, you can make more complex robot control models, because You can implement your own algorithm for converting the coordinates taken from the joystick into motor commands. For example, you can make the EV3 Gyrobal control. Joystick 1 transfers coordinates to mailboxes named x and y, joystick 2 - to mailboxes w and z, joystick 3 - to mailboxes a and b, and joystick 4 - to mailboxes c and d.

The next two settings " End of touch (for horizontal axis)"And" End of touch (for vertical axis)»Determine what happens when you stop touching the joystick. Here you can choose one of two options: "Back to zero" or "Keep position". Return to zero makes sense to use in most situations, for example, if you need the robot to stop when you stop touching the joystick, the “Return to zero” option is just the right one. The save position option is useful when you need to remember the last touch coordinate. This option is used, for example, to tilt the EV3 Explorer frame. This setting is available for all joystick shapes except arrow joysticks.

If you are using the "Independent Motors", "Taxi 1" or "Taxi 2" joystick type, below you will find the port settings for that joystick. Ports that will be controlled by the joystick can be added and removed. For this, there are buttons "ADD" and "DELETE". The number of ports is not limited. The first figure below shows the settings for a joystick with the "Independent motors" type, and the second figure for a joystick with the "Steering 1" and "Steering 2" types. As you can see, there is a slight difference.

Let's go over the port settings. Setting " Joystick axis"Appears only for the" Independent motors "type joystick. There are two options here: "Horizontal" and "Vertical". If you have selected "Horizontal", then the motor will react only when the touch coordinate along the horizontal axis is changed, and if you have selected "Vertical", then it will respond to touching along the vertical axis.

Setting " Motor"Appears only for joystick with the" Taxi 1 "or" Taxi 2 "type. Here you choose between "Left" and "Right".

Setting " EV3 Brick"Will be needed if you have assembled a robot using several EV3 Bricks connected in a" string ". Here you can select a Brick number from 1 to 4. If you only have one EV3 Brick, this should always be 1.

By setting “ Port number»You can select the motor port from A to D.

Setting " Variable value"Appears only for the" Independent motors "type joystick. There are two options here: "Motor power" and "Motor rotation angle". If you chose “ Motor power», The joystick will affect the motor power, ie. the farther you touch from the center of the joystick, the faster the motor will spin. If you chose “ Motor rotation angle", The joystick will affect the angle of rotation of the motor, ie. the farther you touch from the center of the joystick, the greater the angle the motor will turn. In this case, the power for the motor will be adjusted by setting “ Power". The higher this number is, the faster the motor will respond to changes in the touch coordinate, and the better it will keep the angle.

Setting the checkbox " Invert"Will invert the calculated power or angle, and" Coefficient»Increase or decrease the calculated value.

When checking the box " To brake», The motors will stop quickly; will slow down. When this checkbox is unchecked, the motors will spin for some time by inertia until they come to a complete stop.

Here are all the settings that are in the RoboCam program. If something is not clear, write in the comments.

Connecting without a router

Now, here are some tricks that can make using the RoboCam app a little more convenient. If there is no router nearby, for example, if you are on the street, you can establish a connection between smartphone 1 and smartphone or tablet 2 directly. To do this, you need to enable the access point on smartphone 1 (the access point in the Android system is usually enabled in the network connection settings). After switching on, smartphone 1 will turn into router W-Fi and you can easily connect a tablet or smartphone to it 2. This is how the connection will look schematically.

You can find out the RoboCam server address in the same way from the button tip. In most cases, for such an access point, the address will always be http://192.168.43.1:8088.

Using smartphone 1 as a joystick

There is one more trick you can do with the RoboCam app. On smartphone 1 (on which you have the RoboCam application installed), start the server, connect to the robot, and then on the same smartphone launch a browser (of course, one that supports HTML5) and go to http: // localhost: 8088. You will see a page for entering your username and password. Log in as a driver. After entering, you will see joysticks and will be able to control the robot. However, in this case, the image from the camera will not be transmitted. Wi-Fi can be turned off.

Outcome

Hopefully I've provided enough information on how the RoboCam app can be used. If you have any questions about the program or have suggestions, you can leave them in the comments to this article or in the community

What is the most famous construction set in the world? Of course Lego! What is the most famous platform for teaching robotics? Lego Mindstorms of course! Let's figure out why.

Lego: from the craft of a carpenter to leadership in the world of toys

Company Lego founded in 1932. Its founder is a Dane Ole Kirk Christiansen... As a carpenter, he first founded a firm for the production of household products, and later also took up the production of wooden blocks for children. The firm was named Lego, combining Danish words leg - to playand godt is good.

In 1947, the Lego company began producing plastic toys, and already in 1949 the famous Lego snap-on bricks appeared.

Lego's main ideas are modularity and compatibility. Although the bricks have changed design and shape over the 65 years of their existence, they are absolutely compatible with each other. Modern elements can easily be added to elements from 40 years ago.

Today, Lego is certainly much broader than toy manufacturing. The company creates clothes, films, games, organizes competitions, including robotic ones. Lego museums are open in the world, theme parks of amusement - Legends, which are almost entirely built from Lego bricks.

From Lego, you can collect models of cars, planes, ships, buildings, and, of course, robots. Since the end of the last century, Lego has been producing a special robotic construction set, which today has become the leader in educational robotics.

Lego Mindstorms: robotics for everyone

The idea of \u200b\u200badding an electronic programmable block, sensors and electric motors to the standard Lego parts, making programming simple and understandable for children and developing a special construction kit for creating robots revived not only Lego constructions, but the entire company. Since 1991, the company has suffered losses for 11 consecutive years. And it was the robotic direction that saved the situation.

For the first time a robotic constructor Lego mindstorms was introduced in 1998. In 2006, the second version of the constructor was released - NXT, and at the beginning of 2013 appeared EV3 (short for Evolution 3).

From left to right boxed versions of Lego Minstorms 1998, 2006, 2013

The heart of the designer is a microcomputer (microcontroller), aka P-brick, or P-brick (from Programmable brick - programmable brick). Standard Lego parts (beams, gears, axles, wheels) change little with the development of the constructor; it is the microcomputer that undergoes the greatest changes.

The first version of the constructor was completed with a microcomputer RCX, the second - NXT, and as part of the modern version - EV3.

From left to right Lego microcomputers: RCX (1998), NXT (2006), EV3 (2013)

With the development of the constructor, the manufacturer adheres to the policy of backward compatibility, i.e. parts from old versions can be used in conjunction with the new constructor. So, for example, sensors from the NXT version can be used with the EV3. The development of the constructor in step with the times is, first of all, the development of the microcomputer and programming environment. An important feature of the modern EV3 Brick is that it runs on the free Linux operating system.

Lego EV3 Microcomputer Specifications:

  • Processor - ARM9 (ARM7 was used in the NXT 2.0 constructor);
  • rAM - 64 megabytes;
  • FLASH memory - 16 megabytes;
  • sD expansion slot;
  • USB 2.0 with support for Wi-Fi connection;
  • Bluetooth 2.1;
  • monochrome screen with a resolution of 178 × 128 pixels;
  • four input ports;
  • four output ports;
  • six-button control interface;
  • high quality integrated speaker;
  • autonomous power supply from six AA batteries, or using a rechargeable battery direct current EV3 2050 mAh;
  • operating system Linux.

Video review of the Lego EV3 microcomputer:

Lego Mindstorms EV3 Roster

Lego Mindstorms Is a set of standard Lego parts, a microcomputer and sensors.

Lego Mindstorms EV3 Components

The builder was developed for two target audiences: for home use (children and lovers) and for use in educational institutions (students and teachers). A basic set has been created for each group - accordingly boxed version of Lego EV3 and educational version of Lego EV3.

There are also several additional kits available for each group. For example, a resource kit that is optional is simply a set of additional standard Lego parts that expand the capabilities of the constructor. There is no clear boundary between the boxed version and the educational version - this is one and the same constructor, which has slightly different configurations.

Today, this set is being actively implemented in Russia in educational robotics for preschoolers and younger students.

Such a constructor allows you to assemble and program using a computer many basic models according to instructions, as well as come up with your own. The set includes parts that are compatible with standard Lego bricks.

The Lego Education WeDo set includes:

  • 158 building elements;
  • USB Lego Switch;
  • motor;
  • tilt sensor;
  • distance sensor.

The switch controls the sensors and motors using the WeDo software. The switch connectors supply power to the motors and exchange data between the sensors and the computer.

Video presentation of the Lego WeDo set:

Lego Education WeDo is not only a construction set, but a complete methodological support, ready to be introduced into the educational process. This is a great start to your robotics training.

You can find robotics mugs where Lego WeDo is used in our.

LEGO Education WeDo 2.0

Upd. 4.12.2017: LEGO Education at the beginning of 2016 new version educational robotics kit for children WeDo 2.0 (art.45300).

Part basic set Lego WeDo 2.0 includes new versions of the switch, tilt and motion sensors, motor. Unfortunately, the new construction kit is not compatible with the previous version of Lego WeDo motors and sensors, because its microprocessor (Smarthub) has different connectors. The WeDo 2.0 SmartHub connects to a computer or tablet via Bluetooth 4.0.

Is there an alternative to Lego in educational robotics?

Today, the Lego platform is the undisputed leader in educational robotics. Lego Mindstorms kits are used in robotics mugs in many countries around the world. Lego Mindstorms in the leading positions in Russia.

What are the reasons for this leadership? There are several of them.

Firstly, it is undoubtedly the quality of the platform, its training, on the one hand, and design capabilities, on the other. This constructor can be used to build not only toy robots, but also prototypes of such serious structures as, for example, etc. Moreover, children can invent and implement all this. And you can also make a robot from Mindstorms, which!

Rover robot at WRO-2014 in Kazan

Are there any functional alternatives? In general, yes. This is, for example, Korean, German, domestic TRICK other. The platforms listed are similar in price to Lego. There are also more expensive constructors.

Second, it's a powerful Lego-based Olympiad robotics movement. World-class contests such as and, as well as many regional events and festivals require the use of Lego in their regulations.

Alternative Lego makers are also promoting competitions based on their platforms, as the youth robotics competition is entirely based on HUNA's bricks. Multiplatform competitions are also gaining popularity. In Russia, this and the just announced ICaR.

Third, the continuity of Lego Mindstorms. Before it can be described above WeDo, after - TETRIX and MATRIX.The latter two use the NXT and EV3 controllers but offer significant mechanical and structural expansion. Taking into account the fact that modern children get acquainted with Lego before the age of one year, it seems natural and easier to continue working with it further.

Fourthly, the time factor also plays a role in the popularity of Lego - it was simply the first in this area and conquered the market. There are established communities in different countries, there are many developments, there is considerable experience in the use in education.

The main Lego Mindstorms EV3 building block can work with leJOS firmware, which allows you to run Java applications. Oracle has released and maintains a separate version of the full Java SE specifically for this.

The normal JVM allowed me to use the Java Management Extensions (JMX) protocol built into it to implement remote control robot manipulator. A mnemonic diagram made on the AggreGate platform is used to combine control elements, sensor readings and images from IP cameras installed on the robot.


The robot itself consists of two main parts: a chassis and a manipulator arm. They are controlled by two completely independent EV3 computers, and all coordination is done through the management server. There is no direct connection between computers.

Both computers are connected to the room's IP network via NETGEAR WNA1100 Wi-Fi adapters. The robot is controlled by eight Mindstorms motors - 4 of them are "large" and 4 are "small". Also installed are infrared and ultrasonic sensors for automatic stopping at an obstacle when reversing, two touch sensors for stopping the manipulator rotation due to an obstacle, and a gyro sensor that facilitates the operator's orientation by visualizing the position of the shoulder.

The chassis has two motors, each of which transmits power to a pair of tracked drives. Another motor rotates the entire arm 360 degrees.

In the manipulator itself, two motors are responsible for raising and lowering the "shoulder" and "forearm". Three more motors are engaged in raising / lowering the hand, rotating it 360 degrees and squeezing / unclenching the "fingers".

The most difficult mechanical unit is the “brush”. Due to the need to move three heavy engines to the elbow area, the design turned out to be quite tricky.

In general, everything looks like this (a box of matches was hardly found for the scale):

Two cameras are installed to transmit the picture:

  • A regular Android smartphone with the IP Webcam application installed for a general overview (HTC One in the photo)
  • Autonomous Wi-Fi AI-Ball micro-camera, mounted directly on the manipulator's "wrist" and helping to grab objects of complex shapes

EV3 Programming

The software of the robot itself turned out to be as simple as possible. The programs of the two computers are very similar, they start the JMX server, register the MBeans corresponding to the motors and sensors, and sleep awaiting JMX operations.

The code of the main software classes of the manipulator arm

public class Arm (public static void main (String args) (try (EV3Helper.printOnLCD ("Starting ..."); EV3Helper.startJMXServer ("192.168.1.8", 9000); MBeanServer mbs \u003d ManagementFactory.getPlatformMBeanServer (); EVM3LargeRegulated motor \u003d new EV3LargeRegulatedMotor (BrickFinder.getDefault (). getPort ("A")); LargeMotorMXBean m \u003d new LargeMotorController (motor); ObjectName n \u003d new ObjectName ("robot: name \u003d MotorA"); mbs.registerMBean (m, n ); // Registering other motors here EV3TouchSensor touchSensor \u003d new EV3TouchSensor (SensorPort.S1); TouchSensorMXBean tos \u003d new TouchSensorController (touchSensor); n \u003d new ObjectName ("robot: name \u003d Sensor1"); mbs.registerMBean (tos, n) ; // Registering other sensors here EV3Helper.printOnLCD ("Running"); Sound.beepSequenceUp (); Thread.sleep (Integer.MAX_VALUE);) catch (Throwable e) (e.printStackTrace ();))) public class EV3Helper (static void startJMXServer (String address, int port) (MBeanServer server \u003d ManagementFactory.getPlatf ormMBeanServer (); try (java.rmi.registry.LocateRegistry.createRegistry (port); JMXServiceURL url \u003d new JMXServiceURL ("service: jmx: rmi: /// jndi / rmi: //" + address + ":" + String.valueOf (port ) + "/ server"); Map props \u003d new HashMap (); props.put ("com.sun.management.jmxremote.authenticate", "false"); props.put ("com.sun.management.jmxremote.ssl", "false"); JMXConnectorServer connectorServer \u003d JMXConnectorServerFactory.newJMXConnectorServer (url, props, server); connectorServer.start (); ) catch (Exception e) (e.printStackTrace ();)) static void printOnLCD (String s) (LCD.clear (); LCD.drawString (s, 0, 4);))

For each type of sensor and motor, an MBean interface and an implementing class have been created that directly delegate all calls to the leJOS API class.

Sample interface code

public interface LargeMotorMXBean (public abstract void forward (); public abstract boolean suspendRegulation (); public abstract int getTachoCount (); public abstract float getPosition (); public abstract void flt (); public abstract void flt (boolean immediateReturn); public abstract void stop (boolean immediateReturn); public abstract boolean isMoving (); public abstract void waitComplete (); public abstract void rotateTo (int limitAngle, boolean immediateReturn); public abstract void setAcceleration (int acceleration); public abstract int getAcceleration (); public abstract int getLimitAngle (); public abstract void resetTachoCount (); public abstract void rotate (int angle, boolean immediateReturn); public abstract void rotate (int angle); public abstract void rotateTo (int limitAngle); public abstract boolean isStalled (); public abstract void setStallThreshold (int error, int time); public abstract int getRotationSpeed \u200b\u200b(); public abstract float getMaxSpeed \u200b\u200b(); public abstract void backward (); public abstract void stop (); public abstract int getSpeed \u200b\u200b(); public abstract void setSpeed \u200b\u200b(int speed); )

Sample MBean implementation code "a

public class LargeMotorController implements LargeMotorMXBean (final EV3LargeRegulatedMotor motor; public LargeMotorController (EV3LargeRegulatedMotor motor) (this.motor \u003d motor;) @Override public void forward () (motor.forward ();) @Override public boolean suspend motorRegulation () (return suspendRegulation ();) @Override public int getTachoCount () (return motor.getTachoCount ();) @Override public float getPosition () (return motor.getPosition ();) @Override public void flt () (motor.flt () ;) @Override public void flt (boolean immediateReturn) (motor.flt (immediateReturn);) // Similar delegating methods skipped)

Oddly enough, the programming ended there. Not a single line of code was written on the server side and operator workstation.

Server connection

The robot is directly controlled by the AggreGate IoT platform server. Installed free version AggreGate Network Manager product includes a JMX protocol driver and allows connecting up to ten JMX hosts. We'll need to connect two - one for each EV3 brick.

First of all, you need to create a JMX device account by specifying the URL specified when starting the JMX server in the settings:

JMX device connection properties


After that, select the assets (i.e. MBeans in this case) that will be added to the device profile:

Selecting MBeans


And after a few seconds, we look and change the current values \u200b\u200bof all the polled MBean properties:

Device snapshot


You can also test various operations by manually calling MBeans' methods such as forward () and stop ().

List of operations


Next, we set up the polling periods for the sensors. A high polling rate (100 times per second) is used because the management server is located in local network together with the robot and it is the server that makes decisions about stopping rotation when it hits an obstacle, etc. The solution, of course, is not an industrial one, but in a well-functioning Wi-Fi network within the same apartment it proved to be quite adequate.

Polling periods


Operator interface

Now let's move on to creating the operator interface. To do this, first create a new widget and add the necessary components to it. In the final working version, it looks like this:

In fact, the entire interface consists of several panels with buttons, sliders and indicators, grouped into different grid layouts, and two large video players that broadcast images from cameras.

Inside the interface editor

The whole form:

View with the container panels shown:


Now, as the process control systems say, it remains to "revive the mnemonic diagram". For this, the so-called bindings binding properties and methods of graphical interface components with properties and methods of server objects. Since EV3 computers are already connected to the server, the server objects can also be the MBeans of our robot.

The entire operator interface contains about 120 bindings, most of which are of the same type:

Half of the bindings of the same type implement control using clicks on the buttons located on the mnemonic scheme. It is beautiful, convenient for testing, but completely unsuitable for real movement of the robot and moving loads. Bindings from this group are triggered by events mousePressed and mouseReleased different buttons.

The second half of the bindings allows you to control the robot from the keyboard by first pressing the Keyboard Control button. These bindings react to events keyPressed and keyReleased, and in the condition of each binding it is spelled out which button code you need to react to.

All control bindings call methods forward (), backward () and stop () different MBeans. Since events are delivered asynchronously, it is important that function calls forward ()/backward () and subsequent calls stop () not messed up. To do this, the bindings that call the methods of one MBean are added to the same Queue.

Two separate groups of bindings set the initial speeds and accelerations of the motors (this is now implemented on the server side using the model, so these bindings are disabled) and change the speeds / accelerations when moving the Speed \u200b\u200band Acceleration sliders.

The article contains a description of the experience of using the Lego Mindstorms EV3 constructor to create a robot prototype with its subsequent programmatic and manual control using the Robot Control Meta Language (RCML).

  • Assembling a prototype robot based on Lego Mindstorms EV3
  • Quick installation and configuration of RCML for Windows
  • Programmed robot control based on the EV3 controller
  • Manual control of robot peripherals using keyboard and gamepad
Running a little ahead, I will add that in order to control a Lego robot using a keyboard, you need to create a program containing only 3 lines of program code. More details on how to do this are written under the cut.

1. To begin with, a prototype robot was created from the Lego Mindstorms EV3 set, which will be used for programming and manual piloting.

Description of the robot prototype

The robot has a design similar to a car chassis. Two motors mounted on the frame have one common rotation axis, which is connected to the rear wheels through a gearbox. The gearbox converts the torque by increasing the angular speed of the rear axle. The steering is assembled on the basis of a bevel gearbox.



2. The next step is to prepare RCML to work with lego Mindstorms EV3.

You should download the archives with executable files and library files and.

The downloaded archives must be extracted to a directory with an arbitrary name, but you should to avoid Russian letters in the title.

The contents of the directory after unpacking the archives into it



Next, you need to create a configuration file config.ini, which must be located in the same directory. The lego_ev3, keyboard and gamepad modules must be connected in order to be able to control the EV3 Controller using the keyboard and gamepad.

Listing of the config.ini configuration file for RCML

Module \u003d lego_ev3 module \u003d keyboard module \u003d gamepad


The next step is to pair the EV3 controller and adapter.

Instructions for Pairing the EV3 Controller and Bluetooth Adapter

The instruction contains an example of pairing a Lego Ev3 controller and a PC running an operating room windows systems 7.

1. Go to the Ev3 controller settings section, then to the "Bluetooth" menu item.

2. Make sure the configuration parameters are set correctly. Checkboxes should be set on the opposite of the “Visibility”, “Bluetooth” items.

3. You need to go to "Control Panel", then "Devices and Printers", then "Bluetooth Devices".

4. It is necessary to click the "Add device" button. A window will open to select available Bluetooth devices.

5. Select the “EV3” device and click the “Next” button.

6. The EV3 Controller will display the Connect? Dialog. You need to select the checkbox option, and confirm your choice by pressing the central key.

7. Next, the "PASSKEY" dialog box will be displayed, the input line should contain the numbers "1234", then you should confirm the key phrase for pairing devices by pressing the central key on the position with a checkmark.

8. A form for entering the key for pairing devices will appear in the device pairing wizard. You need to enter the code "1234" and press the "Next" button.

10. On the PC, you need to return to the "Control Panel", then "Devices and Printers", then "Bluetooth Devices". The device with which it was paired is displayed in the list of available devices.

11. Double-click to access the “EV3” connection properties.

14. The COM port index specified in the properties should be used in the config.ini configuration file of the lego_ev3 module. The example shows the Bluetooth connection properties of a Lego EV3 controller using the standard COM14 serial port.


Further configuration of the module comes down to the fact that it is necessary to register in the configuration file of the lego_ev3 module the address of the COM port through which communication with the Lego robot is carried out.

Listing of the config.ini configuration file for the lego_ev3 module

Connection \u003d COM14 dynamic_connection \u003d 0


Now you need to configure the keyboard module. The module is located in the control_modules directory, then keyboard. Create a config.ini file next to keyboard_module.dll. Before creating a configuration file, you need to determine what actions should be performed on keystrokes.

The keyboard module allows you to use keys that have a specific numeric code. The table of virtual key codes can be viewed.

As an example, I will use the following keystrokes:

  • The up / down arrows are used to rotate the rear wheel motor forward / backward.
  • Left / right arrows turn the wheels left / right
The configuration file of the keyboard module describes which axes are available to the programmer to interact with the robot in manual control mode. Thus, in the example we have two control groups - these are the keyboard axes. To add a new axis, you should adhere to the following rules for describing axes.

Axis description rules for the keyboard module

1. When adding a new axis, it is necessary in the section add a property whose name is the axis name and assign it the value of the keyboard button in HEX format, while a similar record is entered for each button, i.e. the axis name can be used multiple times. In general, writing to the section will look like this:

Axis_name \u003d keyboard_button_value_in_HEX_format
2. It is necessary to set the maximum and minimum value that can be plotted along this axis. For this it is necessary with new line add a section in the config file config.ini, with the same name as the axis name, and set the properties upper_value and lower_value, which correspond to the maximum and minimum of the axis, respectively. In general terms, this section looks like this:

[axis_name] upper_value \u003d max_axis_value lower_value \u003d min_axis_value
3. Next, you should determine what value the axis will have if you press a button on the keyboard that was previously attached to it. The values \u200b\u200bare determined by creating a section, the name of which consists of the axis name and the value of the keyboard button in HEX format, separated by an underscore character. The properties are used to set the default (unpressed) and pressed state. unpressed_value and pressed_value respectively, to which the values \u200b\u200bare passed. The general view of the section in this case is as follows:

[axis-name_value of keyboard-button] pressed_value \u003d axis_value_when_key pressed unpressed_value \u003d axis_value_when_pressed_key
Spoiler text copied from RCML documentation for ease of viewing.


To implement control of the robot prototype, a configuration file for the keyboard module was created, which includes the go and rotate axes. The go axis is used to set the direction of movement of the robot. Pressing the up arrow key will set the axis to 100, pressing the down arrow key will set the axis to -50. The rotate axis is used to set the steering angle of the front wheels. Pressing the left arrow key will set the axis to -5, pressing the right arrow key will set the axis to 5.

Listing of the config.ini configuration file for the keyboard module

; Mandatory section; axis_name \u003d key_code (in HEX format); The go axis gets values \u200b\u200bfrom the up_arrow go \u003d 0x26; The go axis gets values \u200b\u200bfrom the down_arrow go \u003d 0x28; The rotate axis gets values \u200b\u200bfrom the left_arrow rotate \u003d 0x25; The rotate axis gets values \u200b\u200bfrom the right_arrow rotate \u003d 0x27; Description of the go axis, must always have both keys; Upper bound of the values \u200b\u200bof the go axis upper_value \u003d -100; Lower bound of the values \u200b\u200bof the go axis lower_value \u003d 100; Description of the rotate axis, must always have both keys; Upper bound of the values \u200b\u200bof the axis rotate upper_value \u003d - 100; The lower limit of the values \u200b\u200bof the rotate axis lower_value \u003d 100; Description of the behavior of the go axis for the key * up_arrow * (0x26); When pressing the key * up arrow * set the axis value to 50 pressed_value \u003d 100; When releasing the key * up arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the go axis behavior for the * down_arrow * (0x28) key; When pressing the * down_arrow * key, set the axis value to -50 pressed_value \u003d -50; When releasing the key * down_arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the rotate axis behavior for the * left_arrow * (0x25); When pressing the * left_arrow * axis value set to -5 pressed_value \u003d -5; When the key is released * left_arrow * set the axis value to 0 unpressed_value \u003d 0; Description of the behavior of the rotate axis for the key * right_arrow * (0x27); When pressing the key * right_arrow * set the axis value to 5 pressed_value \u003d 5; When releasing the key * right_arrow * set the axis value to 0 unpressed_value \u003d 0


Further, to implement control using a gamepad, you need to configure the gamepad module. Configuring the module includes creating a config.ini configuration file next to gamepad_module.dll located in the control_modules directory, then gamepad.

Universal module configuration file for interaction with a gamepad

; Mandatory section describing the used axes; Axis for ending the manual control mode Exit \u003d 9; 11 binary axes corresponding to the gamepad buttons B1 \u003d 1 B2 \u003d 2 B3 \u003d 3 B4 \u003d 4 L1 \u003d 7 L2 \u003d 5 R1 \u003d 8 R2 \u003d 6 start \u003d 10 T1 \u003d 11 T2 \u003d 12; 4 stick axes; Right stick up / down movement RTUD \u003d 13; Right stick left / right movement RTLR \u003d 16; Left stick up / down movement LTUD \u003d 15; Left stick left / right movement LTLR \u003d 14; 2 axes of the cross; Movement of the cross up / down arrowsUD \u003d 17; Movement of the cross to the left / right arrowsLR \u003d 18; Description of the B1 axis behavior; When the B1 button is pressed, set the axis value to 1 upper_value \u003d 1; When the B1 button is released, set the axis value to 0 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value upper_value \u003d 1 lower_value \u003d 0 upper_value \u003d 1 lower_value \u003d 0; Description of the behavior of the right stick axis up / down movement; Axis value when moving to the maximum possible upper position upper_value \u003d 0; Axis value when moving to the maximum possible lower position lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535 upper_value \u003d 0 lower_value \u003d 65535; Description of the motion cross axis behavior up / down; Axis value when the up arrow is pressed upper_value \u003d 1; Axis value when the down arrow is pressed lower_value \u003d -1 upper_value \u003d 1 lower_value \u003d -1


For more information on the customization features of the gamepad module, see the RCML reference manual.

3. The next step is to write a program in RCML.

In the root of the created directory, you need to create a program file. The name of the program file and its extension can be anything, but you should avoid Russian letters in the name. In the example, the file name is hello.rcml.

For the lego_ev3 module program code redundancy of the robot, has next view:

@tr \u003d robot_lego_ev3;

The lego_ev3 module connection page describes most of the functions supported by the controller. As a test case, a program was created to automatically enter the robot into a skid.

The program algorithm is as follows:

After reservation of the first free robot, two motors are connected for subsequent work with them as one. Then the robot starts to skid. The software description of the robot's actions allows you to accurately set the angles of rotation of the front wheels and the speed of rotation of the rear wheels. Using this technique allows you to achieve results that are difficult to repeat when manually piloting with a keyboard or gamepad.

Listing of a program for a Lego robot in RCML language

function main () (@tr \u003d robot_lego_ev3; // Reserve the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Set the motor timing @ tr-\u003e motorMoveTo ("D", 100, 0,0); system.sleep (500); @ tr-\u003e trackVehicleForward (-100); system.sleep (1000); @ tr-\u003e motorMoveTo ("D", 50, -50,0); system.sleep (4000); @ tr-\u003e motorMoveTo ("D", 50,50,0); system.sleep (4000); @ tr-\u003e trackVehicleOff (); system.sleep (1000);)


To compile the program, you must use the window command line. First, you should move to the created directory with the executable files rcml_compiler.exe and rcml_intepreter.exe. Next, you need to enter the following commands.

Command to compile the hello.rcml file:

Rcml_compiler.exe hello.rcml hello.rcml.pc
As a result of compilation, in the created directory will appear new file hello.rcml.pc.

Command line screenshot after successful compilation



Now make sure the EV3 Controller is turned on and paired with the Bluetooth adapter. The gamepad must be connected to the PC. After that, you need to execute the command to execute the program file:

Rcml_intepreter.exe hello.rcml

Appearance command line during program execution



A video demonstrating the robot movement program is located at the bottom of the article.

4. The next step is to control the robot in manual mode using the keyboard.

Using the keyboard, it is possible to control any robot motor. As part of the example, control of the following mechanisms is implemented:

  • Steering angle of the front wheels
  • The direction of rotation of the rear wheels

Listing of the program of interaction between the keyboard and the Lego robot based on the EV3 controller

function main () (@tr \u003d robot_lego_ev3; // Reserving the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Setting the motor timing system.hand_control (@tr, "keyboard", " straight "," go "," speedMotorD "," rotate ");)


The next step is to compile the program and execute it. The result of manually controlling a Lego robot using a keyboard is shown in the video at the bottom of the page.

5. In addition to the keyboard, a gamepad module is available that allows you to manipulate the robot using a gamepad. To implement control of the robot using a gamepad, it is necessary to describe at the program level which axes of the robot will take on the values \u200b\u200bof the axes of the gamepad.

Listing of the program of interaction between the gamepad and the Lego robot

function main () (@tr \u003d robot_lego_ev3; // Reserving the robot @ tr-\u003e setTrackVehicle ("B", "C", 0,0); // Setting the motor synchronization system.hand_control (@tr, "gamepad", " straight "," RTUD "," speedMotorD "," RTLR ");)


Then you should repeat the process of compiling the program and then execute it. The following shows the result of manually controlling a Lego robot using a gamepad, and all previously connected methods:

This article briefly demonstrates just a few of the capabilities of RCML. The most detailed description is in the reference manual.

Tags:

  • lego mindstorms
  • robotics
  • programming
Add tags
Did you like the article? To share with friends: