Software apps and online services
Watch the video and check out how learning to code can be fun and easy.
The video shows lessons 5 and 6 from BluPants coding class. Find more lessons here. Other than the drag and drop coding blocks shown, it also natively supports Python. For more information about BluPants visit www.blupants.com or watch our Intro to BluPants video.
Let's see how you can get your Lego Ev3 robot to work with BluPants.
Note: The SD card image has been updated on October 31st 2020. The new release has bug fixes and also adds proper support to the Lego Educational robot. If you are running an olde version, please consider updating it:Building your robot
- Gripp3r: full building instructions
- Educational: core set building instructions
- Educational: ultrasonic sensor building instructions
- Educational: claw (medium motor driving base) building instructions
You do not have to necessarily build the exact same robots we have. As long as you have the motors connected the same way we use on our robot, BluPants will work seamlessly on yours too. Additional tuning of the blupants.json may give you more accuracy though. See "Calibrating your robot" section for more details.
The BluPants default setup is the following:
- Claw motor connects to port A
- Left wheel motor connects to port B
- Right wheel motor connects to port C
- Range sensor connected to port 4
The range sensor should be connected to port 4.
Once you have your robot assembled, it is time to flash a micro SD card with the BluPants image.Booting your robot with the BluPants image
Note: The Gripp3r and Educational images are almost identical. The only difference is that Gripp3r uses the customized blupants_ev3_gripp3r.json for its configuration, while Educational uses the more generic blupants_ev3.json version. It means that either image would work fine on your robot, and you can always copy/edit/overwrite your local configuration on the "/root/blupants.json" to get more accuracy for your bot. See "Calibrating your robot" section for more details on how to customize your "/root/blupants.json" file.
You may refer to the official ev3dev page, or to this video for instructions on how to flash an SD card using Balena Etcher. Regardless the documentation you use, just make sure you flash the correct BluPants image file to your SD card.
Find the Memory Expansion port (SD Card reader) in the left side of your Ev3 brick.
After flashing the SD card, turn off your Ev3 brick, and insert the card as shown bellow:
Find the USB port for the WiFi and connect your USB WiFi dongle directly. Alternatively, connect the USB Hub, if you are also using a USB camera. On the pictures bellow we connect the WiFi dongle and the camera using the USB Hub.
Power on your robot and wait for it to boot.
Once it boots, if it is the first time you use the BluPants image, you will need to connect your robot to the WiFi network.Connecting your robot to WiFi
Using the navigation buttons go to "Wireless and Networks -> WiFi". Make sure the "Powered" option is enabled, then click "Start Scan".
Wait for a few seconds and you will see a list of WiFi networks found under the "Networks" list. In video below, it connects to a WiFi network identified (SSID) as "BluPants". You will need to find your own WiFi SSID and click the center button to select it.
Click "Connect", and in the case your network is protected with a password, you will need to provide it. Type your password, then click "OK" and "Accept".
You should see a message "Status: Associating" for a couple of seconds. If you provided the right password and everything goes well, you should see the message "Status: Online", and your WiFi IP address will show up on the top left corner of your Ev3 display.
Watch the video with all the steps described so far.
The robot IP address in the video is "10.0.0.237". Yours will very likely to be different. Once you see your IP address, you confirm your robot is connected and ready for you to start coding with BluPants.Coding time!
Once you have your robot connected to the WiFi, open a browser and visit http://blupants.org. Make sure the computer you are using to browse is also connected to the same WiFi network you connected your Ev3.
On the "Robot" drop-down menu (bottom right), make sure you see your Ev3 IP address and click "Play". If you do not see anything on the list, try reloading the page and/or closing and reopening the browser. The robot IP is only shown after the page loads completely:
And that's it! You are ready to enhance your coding skills with BluPants.
Keep in mind that BluPants is a multi-platform coding environment. It means, that the same learning experience you can enjoy with your Lego Ev3, can also be done with more affordable robots, such as Beaglebones and RaspberryPies.Robot configuration file
You can change your robot settings by editing its configuration file. All settings can be customized by editing the "/root/blupants.json" file on your robot's local Linux file system. You can access and edit the config file the same way you would do for any regular Linux machine. We are going to cover two options:
- SSH: if you are familiar with Linux/Mac OS and editing files with nano or vi
- Putty: if you are more familiar with Windows environments. Putty can be downloaded here.
The first thing you should do is to login to your robot with the default credentials and change your password. Check your robot IP address on the top left corner of the EV3 brick LCD display. In my case it was: "10.0.0.237".
The default credentials of your robot are:
Run the following command from your local computer to connect to your robot and open a shell there:
MacOS / Linux
$ ssh email@example.com
Windows with Putty
Remember to replace "10.0.0.237" with your specific robot IP address.
Provide the password "tempppwd".
% ssh firstname.lastname@example.org
Linux ev3dev 4.14.117-ev3dev-2.3.5-ev3 #1 PREEMPT Sat Mar 7 12:54:39 CST 2020 armv5tejl
_____ _|___ / __| | _____ __
/ _ \ \ / / |_ \ / _` |/ _ \ \ / /
| __/\ V / ___) | (_| | __/\ V /
\___| \_/ |____/ \__,_|\___| \_/
Debian stretch on LEGO MINDSTORMS EV3!
Last login: Sat Oct 31 16:44:25 2020 from 10.0.0.34
Once you login, change your password by running the command "passwd":
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Provide your new password, and make sure to memorize it. This is the one you are going to use from now on anytime you need to log into your EV3 Linux system.
Go to the /root folder and make sure you have your blupants.json files available there
root@ev3dev:~# cd /root
blupants_ev3_gripp3r.json blupants_ev3.json blupants.json
Now, you can use your favorite text editor such as nano or vi to edit the file.
root@ev3dev:~# vi blupants.json
root@ev3dev:~# nano blupants.json
Alternatively you can copy the file to be edited on your local machine, and work with it there. In order to do that, you do not even need to login to your Ev3 on a ssh session. From your local computer, simply run "scp" or "pscp" to copy the blupants.json config file from the robot to your computer:
MacOS / Linux
$ scp email@example.com:/root/blupants.json .
Windows with Putty
C:\Users\user>pscp -P 22 firstname.lastname@example.org:/root/blupants.json .
Visit the next section to learn how to calibrate your robot by changing the default configuration file. Then, once you are done editing, save it, and copy it back to your robot:
MacOS / Linux
$ scp blupants.json email@example.com:/root/blupants.json
Windows with Putty
C:\Users\user>pscp -P 22 blupants.json firstname.lastname@example.org:/root/blupants.json
Always remember to replace "10.0.0.237" by your robot's IP address.
Keep in mind, that the configuration files has to be compliant to the json format. If you break it, the robot will stop working until you provide another valid configuration file. Let's say if you completely destroyed your blupants.json file. If that happens, all you need to do is to get the original copy from GitHub and restore it to your robot replacing the broken file.
If you need to restore the file for Educational for instance, get the original content from this link and copy it back to your robot's /root/blupants.json file using "scp" or "pscp". If you need a copy of the original Gripp3r configuration, you can get it from this link.
Now that you know how to get access to your configuration file, let's see how you can change it to calibrate your robot and make it more accurate.Calibrating your robot
To calibrate your robot you need to edit your blupants.json configuration file. Visit the previous section to see how to get access to your blupants.json file for editing. This is the valid format for a standard blupants.json file:
"duty_ratio": [1.0, 1.0, 1.0, 1.0],
"robot_id": 2 should never be changed. For all Legos Ev3 robots, the value should always be 2.
"name" however, can be customized, and it will help you identify your robot, specially if you have multiple bots connected to the same network. Be creative and give your robot a cool name.
"use_opencv" is ignored since Lego hardware unfortunately does not support OpenCV.
"measurement_system": "m" is telling the robot to use the metric system when measuring the distance with the Ultrasonic sensor. If you want to use the royal system, change it to "r":
lf your are using the infrared sensor, this field is ignored. The measurement (range form 0 to 60) will show as centimeters though.
"duty": 0.5 tells the robot to use 50% of the power when spinning the motors used on the wheels. It can be set to any value from 0 (no power) to 1 (full power / 100%).
"block_length" tells how much your robot will travel when moving one square forward with the current duty. Let's say you are working on a small map, you may want to decrease the value of "block_length". For bigger maps, you may want to increase it.
"period" is unused.
"enable_tts": true will enable the Text-to-Speech module. If you want to disable it, set it to false. The robot executes commands faster when TTS is disabled. If you plan to use function say(), TTS needs to be enabled for your to hear your robot speaking.
"bluetooth_addr" is unused.
"ev3"->"claw"->"servo":"a" defines which port you connected your claw motor. Let's say ports A, B, and C were taken, already and you need to connect it to port D. Change the value to "servo":"d".
"ev3"->"claw"->"angle_open":"90" tells how many degrees your servo motor has to rotate so your robot can open its claw. Analogously,
"ev3"->"claw"->"angle_close":"-90" defines the closing angle. Notice that the Educational robot will use a much different angle as compared to the Gripper. If you assemble a completely different claw, depending on its physical property, you may need to customize those settings accordingly.
"ev3"->"motor"->"position" define the order of your motors. That is specially important if you are using the function set_motors() when coding your Ev3.
"ev3"->"motor"->"duty_ratio": [1.0, 1.0, 1.0, 1.0], can be used to compensate some issues with one wheel spinning faster the the other. An issue like that would prevent the robot from going straight. The first "1.0" in the array defines a coefficient for the motor defined with position "1" (front_left by default), the second "1.0" is the coefficient for the motor defined as position "2", so on so forth. Let's say for instance, that your robot is going a little bit to the left when programmed to move straight. If that is being caused because the right motor is running faster than the left motor, you may adjust the duty_ratio to compensate that, by lowering the value of the right motor. For instance:
"duty_ratio": [1.0, 0.95, 1.0, 1.0],
It will make the right motor to run 5% slower and potentially compensate the physical issues caused by one motor running faster than the other.
"ev3"->"motor"->"turn_left_period" are analogous. If you program your robot to turn 90 degrees to the right and it actually ends up turning only 60 degrees, you need to increase the value of "turn_right_period" to calibrate it properly. Similarly, let's say you code your robot to turn 90 degrees left and it turns 140 instead. You will need to decrease "turn_left_period" value to fix that.
"ev3"->"camera" are currently not being used. They are intended to define which port the tilt camera servo is connected to.
The BluPants image for the Lego Ev3 is based on the open source project ev3dev. We would like to thank the ev3dev community for the amazing work. If you want learn more about ev3dev, please visit: www.ev3dev.org.