[HN Gopher] Making my first robot as a software engineer
       ___________________________________________________________________
        
       Making my first robot as a software engineer
        
       Author : robertleoj
       Score  : 354 points
       Date   : 2024-12-10 22:31 UTC (4 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | cluckindan wrote:
       | Very nice project, haven't seen many xy plotters built like that.
       | 
       | Instead of inventing your own, you could have used Gcode as the
       | protocol language.
        
         | robertleoj wrote:
         | Thank you! I made it like that purely for fun, this project was
         | not intended to be useful, or have the best mechanical design
         | :P
         | 
         | Using Gcode is a good idea, though it does seem a bit overkill
         | for this simple application
        
         | remram wrote:
         | Wouldn't you need the Arduino to do the inverse-kinematic
         | calculations if you want to interpret gcode?
        
           | dekhn wrote:
           | See fluidnc http://wiki.fluidnc.com/en/config/kinematics as
           | an example where you can get kinematics going without too
           | much effort. It also has links to more pen plotter
           | implementations to learn from.
        
       | usixk wrote:
       | Congrats! cool project and great write up as well
        
         | robertleoj wrote:
         | Thank you!
        
       | msdundarss wrote:
       | I was looking for something similar to get started! Thanks for
       | sharing
        
         | robertleoj wrote:
         | Happy to hear :D
        
       | cgreerrun wrote:
       | The SO100 arm[1] and LeRobot[2] community are great too if you're
       | getting into robotics from the software side of things.
       | 
       | Demonstration of the arm:
       | https://x.com/ChrisMGreer/status/1867278261631561996
       | 
       | [1]https://github.com/TheRobotStudio/SO-ARM100
       | 
       | [2]https://github.com/huggingface/lerobot
        
         | robertleoj wrote:
         | Really cool 4dof robot - thanks for the reccomendation
        
       | NalNezumi wrote:
       | Cool project! Since the arm seems to be a 2 DoF arm in a 2D
       | application, you don't really need numerical optimization but can
       | get the analytical solution to the inverse kinematics problem.
       | Otherwise using previous joint states as initial guess for the
       | optimization is good so that you don't get weird "swings" in the
       | arm (rarely happen in 2D)
        
         | nomel wrote:
         | To put it simply: there's only one solution for each 2d
         | position, if you force the mid joint to always be on one side
         | (and that preferred side can be allowed to switch, to minimize
         | accelerations of the lower arm).
        
         | robertleoj wrote:
         | That's true - using numerical optimization was just the
         | simplest/fastest way to get it working :P
        
       | JKCalhoun wrote:
       | Super cool. And it reminds me why to do these projects: you learn
       | so much in pursuing the project end-goal: motor selection, 3D
       | printing, model slicing, ESP32 programming, etc.
       | 
       | I expect to see a second robot soon with significant changes
       | based on the lessons learned.
       | 
       | (I too just picked up a Bambu A1 printer after deciding to dive a
       | little more into 3D printing. I can confirm it is amazing
       | compared to the Ender-3 I had only dabbled with a bit before.)
        
         | richk449 wrote:
         | As an ender-3 owner, I'm curious what makes the Bambu better?
        
           | Teknoman117 wrote:
           | It just works and it's so, so much faster. Went from an Ender
           | 3 v2 to a Bambu P1S. No more re-leveling the bed, no more
           | first layer adhesion problems, and your prints run 4-6 times
           | quicker.
        
           | moooo99 wrote:
           | First of all, all Bambu models are substantially faster while
           | also achieving the same or better print quality.
           | 
           | Bambu printers are much more polished in terms of hardware
           | and software, making 3D printing more accessible. Their
           | software is more of a closed source thing, but also a lot
           | more polished.
           | 
           | I think a big part of this can be attributed to the 3D
           | printing scene maturing a bit, but a lot is also specific to
           | Bambu Labs
        
             | phero_cnstrcts wrote:
             | But they require Internet connection to function optimally.
        
               | zrail wrote:
               | Eh, not really. You can set them up in LAN mode and pair
               | them with the slicer. You lose access to the mobile app,
               | of course, and you also lose automatic firmware updates.
               | 
               | I had mine set up in local mode for awhile but the mobile
               | app is useful for people in my life that don't care about
               | learning how to work a slicer, so we use cloud mode.
        
               | JKCalhoun wrote:
               | I think you just need the internet to perform a firmware
               | update? My sense is you can take them off the internet --
               | either go LAN or sneaker-net your data via MicroSD card.
        
           | numpad0 wrote:
           | Just a super well made all-proprietary FDM. X1 is CoreXY, A1
           | is i3/bed slinger. Fundamentally same as anything. Does all
           | kinds of filaments and even 100% infills like cakewalk. If
           | you manage to make it do spaghetti you get a lot of eyeballs.
           | But still the same yak just super meticulously shaven. I mean
           | I wouldn't need it at all at all.
        
         | robertleoj wrote:
         | Thanks! Exactly - I feel much more comfortable talking about
         | the hardware at work now after having made this and feel more
         | confident about making something more advanced.
         | 
         | This is my first printer so I don't have anything to compare it
         | to, but to me it seems to "just work"
        
       | darepublic wrote:
       | I've been wanting to get into robotics and this is inspiring to
       | me. Thank you!
        
         | robertleoj wrote:
         | Great to hear that it's useful!
        
       | dheera wrote:
       | As a software and robotics engineer I really wish we could get
       | rid of these stupid "DuPont" connectors already. I want them
       | gone. They're huge, fall out easily, and hard to keep track of.
       | 
       | JST-EH is my preferred connector for most through hole type
       | stuff. That shit really stays in place after it's plugged in.
        
         | riskable wrote:
         | JST-EH is great but let's try to avoid JST-SM. It's worse than
         | DuPont! There's no surface mount connector for JS-SM yet for
         | some f'ing reason every LED strip ever uses JST-SM connectors.
         | This makes it impossible to design something like an RGB LED
         | strip controller board without having to solder some wires to
         | the board (with the connector on the other end).
         | 
         | Drives me bonkers.
        
           | Rediscover wrote:
           | Much great info about JST connectors, heck the whole website
           | is great:
           | 
           | https://www.mattmillman.com/info/crimpconnectors/common-
           | jst-...
        
         | Eduard wrote:
         | https://jst.de/product-family/show/164/eh
         | 
         | JST-EH has a 2.5 mm pitch, plus housing, plus orientation. I
         | cannot see where that shall be any smaller than the
         | omnipresent, universal Dupont connectors. Maybe you mean
         | something different with "DuPont".
        
           | numpad0 wrote:
           | Fake DuPont/QI/2550 has zero latching whatsoever. Contact
           | lengths vary and housings come with massive plays. Great if
           | you want a free safe breakaway feature, sucks otherwise.
           | Nearly anything else has a latching feature that require a
           | lot more force or deliberation to undo, like ZIF with a latch
           | or a lock flap.
           | 
           | By the way, strictly for home breadboard uses only, when I
           | need a bit more resistance than bare DuPont I wrap it in
           | double sided tape and let the header poke through it. Kind of
           | works.
        
         | imtringued wrote:
         | Molex Micro Lock is the new (old) hot shit.
        
         | auxym wrote:
         | I nominate Molex SL. 2.54 mm for easy fit on breadboards and
         | such (EH is 2.5 mm), can fit multiple connectors side by side
         | (just like "dupont" connectors), they have latches (molex KK,
         | for example, has no latch) and many variants: wire to wire,
         | wire to board, panel mount, shrouded and unshrouded. And they
         | are pretty cheap and available (from digikey and co).
        
       | riskable wrote:
       | Up next: Learn how to make your own circuit boards instead of
       | relying on individual microcontroller and motor controller boards
       | :)
        
         | 05 wrote:
         | Reinventing the wheel is fun, but 3d printer boards already
         | exist, and are literally mcu+stepper drivers, could be bought
         | for pennies from people who upgraded their 3d printers to
         | aftermarket ones.
        
       | BWStearns wrote:
       | Awesome writeup! As someone who is roughly in this same stage of
       | hardware learning, this had me laughing.
       | 
       | > I went into "screw with it until it works" mode. I took it
       | apart, re-applied the magnet, swapped wires around, did all kinds
       | of stuff. After a while of this, the error finally went away! No
       | idea why though.
        
         | semitones wrote:
         | This gave me a chuckle too - such a familiar experience
        
         | robertleoj wrote:
         | Thank you, great to hear!
        
       | ElectRabbit wrote:
       | You mastered the holy trinity of engineering: hw, sw and
       | mechanics.
        
         | robertleoj wrote:
         | "Mastered" is a strong word, but thanks!
        
       | maceakacer wrote:
       | nice, i chcked the github and its a very nice robot, also i
       | guessed you used a program that tracks objects or dots you put on
       | a camera recording (sry if im wrong i know nothing about
       | robotics) and the robots follows some pattern in it.
        
         | robertleoj wrote:
         | Yeah - I'm using mediapipe for hand tracking, which is straight
         | out of the box. Then I can just make the robot draw the exact
         | sequence of dots my index finger drew :)
        
       | dtgriscom wrote:
       | I've been a software engineer for 40+ years now. I still remember
       | the one time I wrote firmware for a cable-driven robot hand. It's
       | such a rush to type a command on a keyboard, and something on the
       | bench next to you goes "wrrrrp!".
        
         | xcf_seetan wrote:
         | This. I remember in the 90's working on a software to control a
         | plastic molding machine that made plastic cups, and hit enter
         | and feel the power of a pneumatic system pushing up the
         | platform where i was standing.
        
         | FpUser wrote:
         | Same here. I wrote my first robot in the 80s. Well it was
         | actually scientific device for my main job. Among various
         | sensors it had moving parts controlled by solenoids and stepper
         | motors. Same sense of excitement when the thing worked.
        
         | robertleoj wrote:
         | Right? I'm thoroughly enjoying that rush :D
        
       | rezz wrote:
       | This might be the best thing I've read on HN all year. Thank you
       | for the inspiration.
        
         | robertleoj wrote:
         | That's very inspiring for me to hear, thank you! Glad it's
         | useful.
        
       | a_t48 wrote:
       | This is neat. I've touched ESP32 programming a bit, but need to
       | go deeper.
        
       | neumann wrote:
       | Reminds me of the https://www.brachiograph.art/ . I tried to
       | replicate this, but found the position drifted and jittery....
       | Probably due to poor glueing technique...
        
         | robertleoj wrote:
         | Hahaha wow that is scrappy as hell - it does look difficult to
         | get right :P
        
       | penjelly wrote:
       | this is my dream. How'd you break into the industry?
        
         | robertleoj wrote:
         | Previously, I worked at a startup where we were making a vision
         | system for golf simulators to analyze the player's swing. It's
         | this company: https://www.elvagolf.com/
         | 
         | I learned a lot of computer vision skills from that job, and it
         | turns out this kind of computer vision is directly applicable
         | to robotics as well.
         | 
         | So, I applied for a role as a vision engineer at my current
         | job, and got the role :) This is where I work now:
         | https://www.monumental.co/
         | 
         | Apart from my vision skills though, I was also just generally a
         | good fit - I had a lot of startup/small company experience, I'm
         | a pretty good software engineer apart from the computer vision,
         | and the culture fit was there as well. I feel very lucky that
         | the stars all aligned for me to be here.
        
       | whatever1 wrote:
       | I find it so rewarding to work on such hardware projects.
       | 
       | Unfortunately the market has decided that unless it serves ads in
       | billions of eyeballs it does not matter.
        
         | robertleoj wrote:
         | Well in what context does it matter?
         | 
         | If it's useful for you to learn, then it matters, right?
         | 
         | There are also endless applications for hardware, but I guess
         | to make a viable product you probably need a sizeable team of
         | people.
        
         | badpun wrote:
         | It matters, you're just not going to be pulling $300k-$500k
         | making it. Across all industries, best paying jobs are rarely
         | the most fun ones.
        
       | xcf_seetan wrote:
       | For a more refined machine, there is the XScara[0], a DIY SCARA
       | 3D Printer that can be used for more than 3d print. I made one
       | and change the 3d print head with a laser system, and also had a
       | pen that can be used as a plotter.
       | 
       | [0] https://github.com/madl3x/x-scara
        
         | robertleoj wrote:
         | Oh wow that is refined indeed - I'll check it out, thanks!
        
       | ipv6ipv4 wrote:
       | Analytical solution of the inverse kinematics:
       | 
       | o1 = atan(y/x) - acos((x^2 + y^2 + L1^2 - L2^2) / (2 * L1 *
       | sqrt(x^2 + y^2)))
       | 
       | o2 = acos((x^2+y^2-L1^2-L2^2)/(2 _L1_ L2))
        
         | robertleoj wrote:
         | Nice - did you just chuck it into wolfram alpha or sympy? How'd
         | you get it?
        
           | ipv6ipv4 wrote:
           | It was a long long time ago. I don't remember how I found it.
           | 
           | I do remember being frustrated by the endless papers on SCARA
           | and the importance of the inverse kinematics but no mention
           | of what they actually were. So here they are. (I just checked
           | now, and there seem to be at least a few papers online with
           | the derivation. Times have changed)
           | 
           | I also have this:                 def do(self, (x, y), (dx,
           | dy)):             """ Calculate o derivative (do1, do2) given
           | position (x, y) and desired movement derivative (dx, dy)
           | """             xy2 = x**2 + y**2             ll2 =
           | self.L1**2 + self.L2**2             lld2 = self.L1**2 -
           | self.L2**2             # do1             N = x*dy - y*dx
           | M = xy2             P1 = x**4 + 2 * x**2 * (y**2 - ll2) +
           | y**4             P2 = -2 * ll2 * y**2 + lld2**2             P
           | = P1 + P2             Q = xy2             PQ =
           | math.sqrt(-P/Q)              R = (xy2 - lld2) * (x*dx + y*dy)
           | S1 = math.sqrt(xy2)             S2 = P             S = S1*S2
           | # do2                     T = 2 * (x * dx + y * dy)
           | U1 = (2*self.L1*self.L2)**2 - (x**2 + y**2 - ll2)**2
           | U = math.sqrt(U1)             return -(PQ*R)/S + N/M, -T/U
           | 
           | For this I used a symbolic solver but I don't remember what
           | it was. I also don't remember if it was a meaningful
           | improvement over a simple interpolation between angles.
           | 
           | BTW if memory serves, parsing basic SVG is pretty easy.
           | Though, these days it may be more useful to implement a gcode
           | parser as there are so many freely available gcode generation
           | tools.
        
             | imp0cat wrote:
             | I am currently doing something similar for an off-the-shelf
             | drawing robot with two arms, each with a shoulder and an
             | elbow joint - load svg, convert layers to numpy arrays,
             | then get the angle configuration for each point and save
             | them to a format the robot can read and draw. However, I am
             | finding that the time required to compute the points is
             | quite long.
             | 
             | The fastest way I have right now is a large look-up table
             | (ie. precompute angles for each point of a canvas with a
             | sufficient precision, then use the table to do fast
             | searches for the nearest point).
        
       | TechDebtDevin wrote:
       | So random to stumble upon this on HN a day after I happened upon
       | this on Github while looking for maker/robotics inspiration.
        
       | kentt wrote:
       | I can't help but feeling very envious (in a nice way) of your
       | situation with coworkers. It seems like when you had an issue,
       | you had someone 10 steps ahead of you willing to help out, give
       | advice, lend a part etc.
       | 
       | This project seemed to go as well as my side projects, but when I
       | run into a hiccup, I wait a month for a part on AliExpress, or
       | wander around at Home Depot looking for something that I don't
       | know what it is yet.
       | 
       | Kudos to you for surrounding yourself with great people. Thanks
       | for the write up.
        
         | PhilRobots wrote:
         | The author is my colleague. He's so enthusiastic and fun to
         | help (also very driven to solve issues).
         | 
         | We are lucky to have him around too.
        
       | anymouse123456 wrote:
       | I'm another software head that made the move to electronics and
       | then robotics.
       | 
       | If you feel pulled at all, just dig in right now.
       | 
       | Even if you never make the leap professionally, and it's just a
       | few hobby projects, it'll 10x your regular SWE work while also
       | broadening and deepening your understanding of the increasingly
       | digitally controlled world around you.
        
       ___________________________________________________________________
       (page generated 2024-12-14 23:01 UTC)