{"id":1098,"date":"2017-06-12T14:14:31","date_gmt":"2017-06-12T13:14:31","guid":{"rendered":"http:\/\/ofalcao.pt\/blog\/?p=1098"},"modified":"2017-06-12T14:51:24","modified_gmt":"2017-06-12T13:51:24","slug":"google-cloud-sdk-on-ev3","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2017\/google-cloud-sdk-on-ev3","title":{"rendered":"Google Cloud SDK on EV3"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 1 of 1 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/google-cloud-sdk\" class=\"series-298\" title=\"Google Cloud SDK\">Google Cloud SDK<\/a><\/div><p>A fellow from PLUG defied me to show a LEGO robot that translates conversation, much like the C3PO protocol droid from Star Wars.<br \/>\nI only had a couple of hours so I decided to copy the Raspsberry Pi approach of using &#8220;the Cloud&#8221;. Google offers a <a href=\"https:\/\/cloud.google.com\/free\/\">one year free trial<\/a> so I registered and tried a few examples on my Ubuntu laptop, amazing what one can do with just a few curl commands!<\/p>\n<p>So, how to use Google Cloud SDK directly from LEGO MINDSTORMS EV3?<\/p>\n<p>Google has a repository for Debian but it doesn&#8217;t work with ev3dev &#8211; there are no packages for the ARM architecture. But I found someone saying that he managed to install the x86 tar.gz package on his Raspberry Pi so.. why not give it a try? And yes, it really works.<\/p>\n<p>So this is the process to install Google Cloud SDK on EV3 running ev3dev. It was tested with a fresh installation of the latest release available today, &#8220;2017-06-09&#8221;<\/p>\n<pre>robot@ev3dev:~$\r\nLinux ev3dev 4.4.68-20-ev3dev-ev3 #1 PREEMPT Mon May 15 12:45:40 CDT 2017 armv5tejl GNU\/Linux<\/pre>\n<p>No dependencies needed &#8211; just download the most recent of the &#8220;Versioned archives&#8221; <a href=\"https:\/\/cloud.google.com\/sdk\/downloads\">available for download<\/a>:<\/p>\n<pre>wget https:\/\/dl.google.com\/dl\/cloudsdk\/channels\/rapid\/downloads\/google-cloud-sdk-158.0.0-linux-x86.tar.gz<\/pre>\n<p>Then just extract it and run the install script:<\/p>\n<pre>tar -xvf google-cloud-sdk-158.0.0-linux-x86.tar.gz\r\n.\/google-cloud-sdk\/install.sh\r\n\r\n<\/pre>\n<p>The install takes 5 minutes:<\/p>\n<pre>Welcome to the Google Cloud SDK!\r\n\r\nTo help improve the quality of this product, we collect anonymized usage data\r\nand anonymized stacktraces when crashes are encountered; additional information\r\nis available at &lt;https:\/\/cloud.google.com\/sdk\/usage-statistics&gt;. You may choose\r\nto opt out of this collection now (by choosing 'N' at the below prompt), or at\r\nany time in the future by running the following command:\r\n\r\ngcloud config set disable_usage_reporting true\r\n\r\nDo you want to help improve the Google Cloud SDK (Y\/n)? N\r\n\r\nYour current Cloud SDK version is: 158.0.0\r\nThe latest available version is: 158.0.0\r\n\r\n+------------------------------------------------------------------------------------------+\r\n| Components |\r\n+---------------+-----------------------------------+--------------------------+-----------+\r\n| Status | Name | ID | Size |\r\n+---------------+-----------------------------------+--------------------------+-----------+\r\n| Not Installed | Cloud Datalab Command Line Tool | datalab | &lt; 1 MiB |\r\n| Not Installed | Cloud Datastore Emulator | cloud-datastore-emulator | 15.4 MiB |\r\n| Not Installed | Cloud Datastore Emulator (Legacy) | gcd-emulator | 38.1 MiB |\r\n| Not Installed | Cloud Pub\/Sub Emulator | pubsub-emulator | 21.0 MiB |\r\n| Not Installed | gcloud Alpha Commands | alpha | &lt; 1 MiB |\r\n| Not Installed | gcloud Beta Commands | beta | &lt; 1 MiB |\r\n| Not Installed | gcloud app Java Extensions | app-engine-java | 132.2 MiB |\r\n| Not Installed | gcloud app Python Extensions | app-engine-python | 6.4 MiB |\r\n| Installed | BigQuery Command Line Tool | bq | &lt; 1 MiB |\r\n| Installed | Cloud SDK Core Libraries | core | 6.1 MiB |\r\n| Installed | Cloud Storage Command Line Tool | gsutil | 2.9 MiB |\r\n| Installed | Default set of gcloud commands | gcloud | |\r\n+---------------+-----------------------------------+--------------------------+-----------+\r\nTo install or remove components at your current SDK version [158.0.0], run:\r\n $ gcloud components install COMPONENT_ID\r\n $ gcloud components remove COMPONENT_ID\r\n\r\nTo update your SDK installation to the latest version [158.0.0], run:\r\n $ gcloud components update\r\n\r\nModify profile to update your $PATH and enable shell command \r\ncompletion?\r\n\r\nDo you want to continue (Y\/n)? Y\r\n\r\nThe Google Cloud SDK installer will now prompt you to update an rc \r\nfile to bring the Google Cloud CLIs into your environment.\r\n\r\nEnter a path to an rc file to update, or leave blank to use \r\n[\/home\/robot\/.bashrc]:\r\n\r\nBacking up [\/home\/robot\/.bashrc] to [\/home\/robot\/.bashrc.backup].\r\n[\/home\/robot\/.bashrc] has been updated.\r\n\r\n==&gt; Start a new shell for the changes to take effect.\r\n\r\nFor more information on how to get started, please visit:\r\n https:\/\/cloud.google.com\/sdk\/docs\/quickstarts<\/pre>\n<p>Now exit from the SSH session and login again. The SDK commands should be available so let&#8217;s configure our environment:<\/p>\n<pre>robot@ev3dev:~$ gcloud init<\/pre>\n<p>This will take about 6 minutes:<\/p>\n<pre>Welcome! This command will take you through the configuration of gcloud.\r\n\r\nYour current configuration has been set to: [default]\r\n\r\nYou can skip diagnostics next time by using the following flag:\r\n gcloud init --skip-diagnostics\r\n\r\nNetwork diagnostic detects and fixes local network connection issues.\r\nChecking network connection...done. \r\nReachability Check passed.\r\nNetwork diagnostic (1\/1 checks) passed.\r\n\r\nYou must log in to continue. Would you like to log in (Y\/n)? Y\r\n\r\nGo to the following link in your browser:\r\n\r\nhttps:\/\/accounts.google.com\/o\/oauth2\/auth?redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&amp;prompt=select_account&amp;response_type=code&amp;client_id=32555940559.apps.googleusercontent.com&amp;scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&amp;access_type=offline<\/pre>\n<p>Just copy the link in last paragraph and open it on your browser. You will need to login with a valid Google account. Mine was already associated with a project (&#8216;ev3-pd&#8217;) because I already started testing the APIs on the laptop so I picked that project but you can also create a new one.<\/p>\n<p>You will get a verification code like this:<\/p>\n<pre>6\/vzSXbihAPCTeewAazTZo0YqL49qYDFUcuIR0HBDWnvz<\/pre>\n<p>Just copy&amp;past it to the last prompt to continue<\/p>\n<pre>Enter verification code: 6\/vzSXbihAPCTeewAazTZo0YqL49qYDFUcuIR0HBDWnvz\r\n\r\nYou are logged in as: [yourgoogleid@gmail.com].\r\n\r\nPick cloud project to use: \r\n [1] ev3-pd\r\n [2] Create a new project\r\nPlease enter numeric choice or text value (must exactly match list \r\nitem): 1\r\n\r\nYour current project has been set to: [ev3-pd].\r\n\r\nDo you want to configure Google Compute Engine \r\n(https:\/\/cloud.google.com\/compute) settings (Y\/n)? Y\r\n\r\nWhich Google Compute Engine zone would you like to use as project \r\ndefault?\r\nIf you do not specify a zone via a command line flag while working \r\nwith Compute Engine resources, the default is assumed.\r\n [1] asia-east1-a\r\n [2] asia-east1-b\r\n [3] asia-east1-c\r\n [4] asia-northeast1-b\r\n [5] asia-northeast1-c\r\n [6] asia-northeast1-a\r\n [7] asia-southeast1-b\r\n [8] asia-southeast1-a\r\n [9] europe-west1-d\r\n [10] europe-west1-c\r\n [11] europe-west1-b\r\n [12] europe-west2-a\r\n [13] europe-west2-b\r\n [14] europe-west2-c\r\n [15] us-central1-c\r\n [16] us-central1-f\r\n [17] us-central1-a\r\n [18] us-central1-b\r\n [19] us-east1-c\r\n [20] us-east1-b\r\n [21] us-east1-d\r\n [22] us-east4-a\r\n [23] us-east4-b\r\n [24] us-east4-c\r\n [25] us-west1-a\r\n [26] us-west1-b\r\n [27] us-west1-c\r\n [28] Do not set default zone\r\nPlease enter numeric choice or text value (must exactly match list \r\nitem): 9\r\n\r\nYour project default Compute Engine zone has been set to [europe-west1-d].\r\nYou can change it by running [gcloud config set compute\/zone NAME].\r\n\r\nYour project default Compute Engine region has been set to [europe-west1].\r\nYou can change it by running [gcloud config set compute\/region NAME].\r\n\r\nCreated a default .boto configuration file at [\/home\/robot\/.boto]. See this file and\r\n[https:\/\/cloud.google.com\/storage\/docs\/gsutil\/commands\/config] for more\r\ninformation about configuring Google Cloud Storage.\r\nYour Google Cloud SDK is configured and ready to use!\r\n\r\n* Commands that require authentication will use yourgoogleid@gmail.com by default\r\n* Commands will reference project `ev3-pd` by default\r\n* Compute Engine commands will use region `europe-west1` by default\r\n* Compute Engine commands will use zone `europe-west1-d` by default\r\n\r\nRun `gcloud help config` to learn how to change individual settings\r\n\r\nThis gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and\/or projects.\r\nRun `gcloud topic configurations` to learn more.\r\n\r\nSome things to try next:\r\n\r\n* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.\r\n* Run `gcloud topic -h` to learn about advanced features of the SDK like arg files and output formatting<\/pre>\n<p>Since I already activated a service account for my project I already had a JSON file with a private authorization key to use (if you don&#8217;t know how to do it <a href=\"https:\/\/cloud.google.com\/sdk\/docs\/authorizing\">look here<\/a>). I copied it from my laptop as &#8216;EV3-PD.json&#8217; and defined a path variable for Goggle Cloud SDK to find it when needed:<\/p>\n<pre>robot@ev3dev:~$ export GOOGLE_APPLICATION_CREDENTIALS=\/home\/robot\/EV3-PD.json<\/pre>\n<p>This key allows us to generate an access token that grants access to Google Cloud APIs for the next 3600 seconds:<\/p>\n<pre>robot@ev3dev:~$ gcloud auth application-default print-access-token\r\n\r\nya29.ElpnBDIm1MCsz4isiMF6NL3Hc5yzGpkoGr0iJG1sB68DX00ZvkecQaBL-fkviWYq6HVtkezRjg9Vv_lSxJ6Q7XXFRfH-2Gon_Q4H2784wYZkvZox2UfP2ncJJ0Q<\/pre>\n<p>And we are now able to use <del>Skynet<\/del> The Cloud for our most CPU intensive tasks. Next post I will show how to transcript voice to text through Google Cloud Speech API.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 1  of 1 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/google-cloud-sdk\" class=\"series-298\" title=\"Google Cloud SDK\">Google Cloud SDK<\/a><\/div><p>A fellow from PLUG defied me to show a LEGO robot that translates conversation, much like the C3PO protocol droid from Star Wars. I only had a couple of hours so I decided to copy the Raspsberry Pi approach of using &#8220;the Cloud&#8221;. Google offers a one year free trial so I registered and tried &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2017\/google-cloud-sdk-on-ev3\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Google Cloud SDK on EV3&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[157,13,299],"tags":[301,300],"series":[298],"class_list":["post-1098","post","type-post","status-publish","format-standard","hentry","category-ev3dev-en","category-ev3dev","category-mindstorms","tag-mindstormsmagic","tag-google-cloud-sdk","series-google-cloud-sdk"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-hI","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1098"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1098\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1098"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}