Has anyone published a “First GoPiGo3 (Python) program in VS Code” tutorial?
I would hope that would not be a remote dev example, to just first get to know how to use VS Code native as a GoPiGo3 specific content sensitive editor.
[Carried over from a private thread that was going wayyy off topic. ]
Just to be clear here - are we talking about installing the entire blasted thing on the robot? Or just the remote execution shell and extensions?
If you’re thinking of trying to install the entire environment, including the IDE, on the robot, I would most humbly, and strongly, recommend against it.
One of the main reasons I moved from the Pi-3 to the Pi-4 was to try to provide enough “umph!” to do everything locally with the entire kit-and-kaboodle installed on the robot. I went with a Pi-4, 4gb, (which was the beastliest board at the time, except for the first-gen Jetson Nano I have, which didn’t fit).
“It was a disaster” is a masterpiece of understatement. It slowed the robot to a crawl and it overheated despite my best efforts to keep things cool, and that was on the Pi-4. The Pi-3 just rolled over and died.
I eventually went the “remote execution” route after trying several other ideas because it was convenient and didn’t “weigh down” the robot.
Note that all of this was done with Raspbian for Robots, off of a SD card, and was before the GoPiGo O/S and SSD/Multiboot days, but I would still have the most serious doubts about the Pi’s ability to run the whole enchilada.
As far as “students” using it is concerned - how advanced are these students?
Are we talking about students who have a few hundred hours of stick-time and already know the difference between “IF”, “FOR”, and “AND”?
Or are we talking about kids still in ground-school who are still learning the difference between the prop and the cockpit, and need a reminder on the control panel that reminds them which way “UP” is?
For the first group - OK, I can see that. Especially if their education track is primarily programming and development oriented. However, I still don’t think the whole environment will work on the 'bot - unless it’s one of Tom Coyle’s “Road Hog” monsters.
For the second group - Oh Lord no! Bypass the Cessna 172 with dual controls and slam them into a 747 for their first logged flight. You’d scare them outta their socks so fast there’d be a hole in the air!
For the record, I like VS-Code - especially the way it takes care of all the mechanics of Git and GitHub. Though I may be something of a neo with Python, I’m not new to programming and - though the learning curve was is steep - VS Code works perfectly as a way to manage a larger project, and even then I screw things up abysmally!
I’m not exactly sure what you folks have in mind, but it sounds scary to me.
All I want is the “great editor” for Python. The install of VSCode went real smooth. The install of a simple nano keymap extension zipped to completion giving me hope.
I opened a new file and it suggested I select a language. I chose Python and it recommended a Python extention.
The install of the recommended Python extension sent Dave into a coma!
I’m going to explore and see if there are some non-Intellisense Python extensions that will offer only Python syntax hinting and easygopigo3 module import sensitive help.
Has anyone published a “First GoPigo3 (Python) program in anything” tutorial? Especially the “GoPiGo3” part?
As @cyclicalobsessive has mentioned before, we see a recurring theme here:
Students - even college students - are floundering around in a sea of robot functions and API calls and they come here hoping for a life-ring.
And we do it too. They end up getting that essential class, (on these forums), in “Beginning Python and Fundamentals of Robotics 101”, and go on to do well on their projects and theses. And I’m NOT complaining - I was the recipient of like honors when I started and I feel it is an honor and a privilege to help in what small way I can too.
But documentation is sorely lacking. Sure, the student can glean skill and experience from the wealth of information here - but that’s an uphill struggle for a student who is already weighed down by an oppressively complex project on top of the 18 or 20 credit-hours of classes he’s carrying.
Maybe a Dexter/MR sponsored Wiki would work? Something that would index well, and that - as we learned something - we could use to “pay it forward” to the next generation by writing descriptive articles - as opposed to the relatively limited topics here on the forum?
Are you installing ALL of the IDE on Dave, or just the server/remote execution wedge, running the actual IDE on another system?
I’ve never experienced, (using the remote execution model), seeing Charlie go into a coma, but I have seen all kinds of funny things happening when the entire environment was installed.
The editor suggested I pick a language for my new file and then suggested I install a 52MB Python extension.
The VSCode app became unresponsive, the ssh from my mac to Dave became unresponsive, Dave’s health check app turned on the “oh no” yellow LED flashers but they were stuck on, so I jerked the juice and gave Dave a short nap.
After trying a few simple Python extensions, I decided to retry the official Python extension again but from the extension marketplace panel and not panic so quickly.
It succeeded and the editor now provides GoPiGo3 context sensitive help, and my hello program ran in a VSCode terminal pane.
I am using the Mac Remote Desktop to the RPi desktop through the Legacy Pi OS VNC with 1920x1080 resolution on a 23" ultra wide monitor.
I need to look at the processor and memory usage for editing bigger files and running GoPiGo3 programs from inside VSCode as well as running from a non-VSCode shell
I also haven’t found a key mapping I like yet. My Mac doesn’t have home/end keys, and the only thing I have found to work fo that is fn + right-arrow which is not going to be a short cut.
But I’m on a roll at least exploring native VSCode on RPi3B+
I actually don’t have VS Code fully on my robot. I’ve got it on my Linux laptop that I use to run ROS with my GoPiGo3. I use the remote editing functionality, which does install some software on the remote system. Overall that approach has worked really well for me.
You install the heavyweight parts, (the entire VS Code IDE and executables), on your Mac and a lightweight “shim”, (helper program/scripts), on the robot itself that the main program reaches out to via a SSH connection, and uses it to control the environment on the 'bot itself. Some extensions run on the 'bot, others run in the IDE, but all in all it works well.
Assuming you create a pair of shared secrets for your robot and your main system, if you move (or reformat), all you have to put back are the project directories, the .vscode directory in the root of your home directory, and the .ssh directory in the same place.
Once you’ve done that and attempt to re-connect, it might download one or two things, do some fix-ups, or whatever, but once it’s done you’re right back where you were before, extensions, everything.
==============================
To do this you install the entire program on your Mac, then install the “SSH” and “Remote Development” extensions, and then tell it you want to develop on Dave, (or Carl, you can do both).
It then reaches out to the bot, logs in, installs the necessary helper software and, (after you connect to or clone the repository to the robot), you’re good to go.
I tried it the way you’re doing it and it sometimes worked, sometimes didn’t , it was slow, laggy, it stuttered, and eventually drove me to distraction.
I tried several other techniques, including developing on the laptop and using FileZilla to transfer files back-and-forth - which was a Fuster Cluck with horns and teeth!
Eventually I stumbled upon, (and got working!), the remote dev capabilities - and that was a godsend. It has actually made development on the robot, and interfacing with GitHub for source control, virtually painless.
In fact, (in all honesty), I can say I made 99% of the progress on my project after I enabled remote dev. I was able to work on all the parts - the Python server code, the JavaScript client side code, the CSS and HTML parts - all of it in a seamless and integrated manner.
This allowed me to overcome a major development hurdle:  Debugging JavaScript browser code within VS Code while running and monitoring the underlying server-side code on the 'bot. Without this, I’d still be hacking at things with a machete and trying to figure out where the smoke was coming from.
If you’re wondering why it took so long to discover remote dev, there are two reasons:
I’m a blithering idiot, stumbling around this stuff like a blind man.
Remote dev for the ARM-7 platform, (Raspberry Pi), is a relatively recent thing - being less than a year-or-so old compared to other platforms.
There’s a tiny bit of fussiness until you get a shared secret set up to enable no-password logins, after that it’s as nice as direct dev on the 'bot itself.
Ooh - I haven’t done that yet. I just provide my password every time.
I changed my preferences so I have different themes for my local and remote (i.e. robot) editors. That way I can be clear on what I’m working on (since both have a catkin_ws/src directory)
This is truly de minimus, (no more fussy than providing a password for sudo), and the solution, (setting up a shared secret), is no more “fussy” than installing an extension.
OK, did it - installed VSCode on my Mac with the SSH Remote extension, and configured it bing, bang, boom.
=== Remote Dev VSCode ===
1) Install VSCode for Mac
* Download zip file, Dbl click to expand
* Drag VSCode.app to Applications folder
* Install SSH For Remote Extension
* Set up SSH to GoPiGo3 pi@x.x.x.x
* Install Python on SSH remote
2) Using VSCode Remote
* open a folder on the SSH remote (~/GoPiLgc/Examples/first_vscode)
* Edit a file ( robot2.py)
* Open a terminal window, split the terminal
* run in left term, status in right term
After running it for 7 hours, the load average was even better at around 0.25, BUT it appears the memory leak is still present - available memory (while running the program to read the battery voltage, the IR distance sensor and the Ultrasonic distance sensor) which started out at 433MB dropped to 375MB. That is a loss of about 8MB per hour.
Of course, now I have to repeat the test running the program without VSCode connected to identify if the memory leak is in “Python/GoPiGo3/Legacy PiOS” or in the “VSCode Python Extension”.
It appears the VSCode remote editor, two VSCode remote terminals, and running the robot2.py program in one of the remote terminals uses 120MB more than running the program from a non-VSCode ssh shell. Available memory before the program started was 558MB and after the program started went down to 550MB. AND after 5 hours the available memory went up!! to 594 MB due to a increase in the buff/cache?
So the leak is in the Raspberry Pi VScode Python extension. 8MB an hour leak is not prohibitive with 400 MB available, but not an insignificant amount of memory.