Showing posts with label Rover. Show all posts
Showing posts with label Rover. Show all posts

Hoverboard comms library

I'm back making silly moving things using hoverboard hub motors and re-flashed hoverboard controllers.

For months on end I've been vaguely putting off working on the big 6-wheel platform I started because I needed to write a library for the comms protocol so I wasn't committing the sin of copy & pasting great swathes of code to run the three separate controllers.

Now I've finally sat down and got round to it so the excuses for not progressing the big rover project are evaporating. I only started thinking about this two years ago.

eBike battery mount

Way back at EMFCamp I bought an eBike battery to use in a Rover. It came bare without a connector or mount. It took me a long time to get around to searching for a connector and ordered something from AliExpress.

When it arrived it was a disappointment. The connector was just about OK but the mount was rubbish and unusable.

Yesterday I finally got around to designing a 3D printed block to go on the supplied rail and hold the connector firmly in place, unlike the awful flimsy plastic pieces supplied.

I also had to drill the rail to make the locking mechanism work, but that came out OK.

Now I need to get on with the rest of the Rover.

Useful Sensors Person Sensor testing

One of the things I'd quite like to do with my Rover project is have it detect when a person is in front of it and aim a camera at them. The long term goal is that it's a kind of telepresence device, but this is also another way to avoid collision with people and I want as many checks on that as possible.

When these very cheap sensors from Useful Sensors appeared I grabbed a couple.

Their USP is supposed to be that they offload all the machine learning face detection onto a dedicated module you can just get readings from and will even learn specific faces. In practice I found they seemed to be very prone to false positives so I left them sitting unused for a month or two after an initial burst of enthusiasm.

At LARPCon I had a chat with a droid builder who'd brought one of their in-progress projects along which is part-finished B2EMO replica. 

This droid has a prominent 'eye' camera, although in practice it's just a drone camera much like I've been experimenting with.

This made me think of the Person Sensor again and have another go with it. For testing I attached it to the cheap pan/tilt setup I have the drone camera in and started trying to filter out the false positives from the Person Sensor.

It became clear pretty quickly that the false positives are very 'bursty', ie. you'll get 2-3 false detections in a row then they disappear. With detection happening at around 5Hz, ignoring any detections with less than four consecutive positives seems to pretty much kill them all without adding much latency.

I then set about making it track the 'best' face and move the pan/tilt setup. After a bit of faffing with preventing constant hunting due to lag I eventually got decent enough tracking so long as the lighting is favourable.

Yes you could do this with a powerful SBC like a Jetson Nano and do it better, but this is doing it with a standalone $10 module and offloading the work. I made a little video of it tracking in my cellar. Beware the static on the audio channel, this video is coming from a USB 5.8GHz receiver and the camera has no microphone.

I think this works passably OK now so I'll be investigating this further and seeing about making a more stable pan/tilt mechanism. I may also wrap the Person Sensor functions up into an Arduino Library for the benefit of others. It's not complicated to use but abstracting stuff into a re-usable library is better.



Hoverboard motor powered rover: Part 6

Things seem to have slowed down with work on my rover as I keep disappearing on 'side quests' and one of those was to make a better controller for this and any other projects that need a remote controller.

So I cooked up a 3D printed design with some 3-axis sticks and as many buttons as I could manage on an ESP32. It's partly inspired by the 3D printed controllers James Bruton and Keegan Neave have made but ESP32 based.

With a screen I happened to have fitted and the encrypted 2-device ESP-Now library I'm working on being bidirectional (another side quest) it should be able to give lots of info on the rover while it's in use like battery voltage, location and so on.

This might be of use to others (although the design's quite specific to that screen) so I've made it available on GitHub and christened it Sticky.

LD2410 radar sensors

As I worry about safety around my rover I've been looking for a way to detect people that doesn't rely on anything complicated like AI image analysis and can be done with a simple cheap sensor.

By chance, Andreas Spiess did a brief review of the new Hi-Link LD2410 24Ghz radar sensors, which are designed for presence detection.

They look promising and aren't expensive, so I bought a few along with the dedicated UART breakout board made for them.

My little bit of testing suggests they're really quite good at detecting people within a few metres, whether they are moving or not and people are rarely completely still. At close range it can tell if you're breathing.

While you can just connect one of the pins to a GPIO to signal presence they use a serial protocol for configuration and more detailed readings. However as they are comparatively new devices there wasn't a library for this.

Between reading the work somebody has started on integrating them into ESPHome and the slightly confusing manufacturers datasheet I've cooked up an Arduino Library and submitted it to the Library Manager. I hope people find it useful.

Now I need to make some breakouts for them, they use 1.27mm headers, and attach them to my rover.


Hoverboard motor powered rover: Part 5

I've slowly been chipping away at adding sensors to the rover and it's at a point where I really need to dig deep into RobotOS (ROS) and start on tying it all together.

The Wyse 5060 thin client has been screwed to an old VESA TV bracket, which works OK but tends to come loose under vibration. Given I primarily want to make the rover drive around outdoors this urgently needs fixing.

The Kinect has been cut down, using information from this blog post so it can be screwed directly to the top deck and this works really well.

I threw a bit of effort at software and the sonar range finders are now an I2C peripheral of the Wemos D1 Mini that talks to the remote control and sends commands to the motor controllers. I also found an old MPU6050 accelerometer and a nice tilt compensated compass to give reliable orientation information put these on the I2C bus.

The 5060's original SSD was too small to be practical, being only 8GB. I happened to have a larger one in an unused machine and bought a cheap adaptor to make it physically fit, so the onboard computer's now running a full copy of Ubuntu and it's possible to remote desktop into it and test the Kinect 'live'. A couple of USB WiFi dongles, while not ideal connect it to my home network indoors and provide a 'hotspot' for working on it elsewhere.

With the D1 Mini connected over USB to the the 5060 it should be possible to use rosserial to pass all I2C connected sensor information and detail from the motor controllers sensors back to ROS, while accepting 'twist' commands to move. I do vaguely wonder if I should move to an ESP32 though, as the D1 mini is rather busy with synchronous tasks that could do with being done on a second core but more importantly having hardware UARTs to talk to the motor controllers would be far better than the software serial library I'm using.

I've also plugged a USB GPS dongle I had in my box of project bits into a spare port.

Which means I've close to a full 'sensor suite' for a basic rover. The Kinect won't work outdoors and the GPS won't work indoors, so I still need to come up with something to cover these complementary gaps and do a load of work on sensor fusion, but learning about this topic is the whole point of this project.

I see LIDAR and custom made wheel tick sensors built into the hoverboard motors in my future. The former will give some outdoor obstacle location for mapping and the latter help with dead reckoning indoors. Dead reckoning is not going to work on loose surfaces, but will do OK on nice indoor flat floors and be backed up by the Kinect.

As this very much got me to a solid milestone on the rover, I've christened it with a name, 'Crufty' as it's made from 'maker cruft' and intend to write up/open source large chunks of it on Github.

It was also an opportunity for a presentation at my Raspberry Pi meetup despite the total lack of Raspberry Pis in the build.



Hoverboard motor powered rover: Part 4

With the arrival of more Kinects I need to get back to mounting a computer on the rover in a better way than just cable-tying a Raspberry Pi to a cable-tie base. It was rattling round like a mad thing outdoors which was just generally unsatisfactory.

Having read up a little on ROS I came to the conclusion that I needed a more powerful computer than a Pi 3B+. The Kinects chuck a lot of data at USB, the Pi3 hangs everything off USB and poor performance of USB peripherals is a standard Pi thing. If I want to try the Xbox One Kinect it requires USB3 which the Pi3 simply doesn't have. However with the ongoing chip shortage you simply can't buy things like Pi 4s or Jetson Nanos easily.

To get something with a bit of grunt and more memory without breaking the bank I took a leaf out of Colin Hickey's book and bought a used thin client from eBay. This one is a Dell Wyse 5060 which gets you an AMD GX-424CC quad core 2.4Ghz processor, 4GB RAM, USB3 and a tiny 8GB SSD for £37 delivered. A quick rummage in my box of PC parts and I found another SODIMM so it's now sporting 8GB of RAM. There's a well know pre-set password of 'Fireport' on the BIOS and once you've cleared this you can wipe the SSD and install any desktop OS you fancy.

Ubuntu 20.04LTS, the main supported OS for the final release ROS 1 'Noetic' fits on the 8GB SSD fine although I can imagine running out of space at some point. The SSD fitted is a weird stubby SATA thing plugged directly into the board but apart from the physical form factor it seems it's otherwise standard SATA. So if needed I can make an internal cradle and connect a standard drive with SATA cables.

It's a really nice little machine. I booted a LiveUSB of the Ubuntu desktop and it's really quite nippy for the basic specification.

Being a thin client the case has proper mounting points for both a VESA mount and a desktop stand. It just fits on the deck of the rover and I can see myself using the VESA mount for this. It's fanless and DC powered with a ubiquitous 19V laptop style supply and I should be able to use a buck convertor to get that from the rover's 36V battery pack easily. Physically it's about 5-6 times the size of a Pi in a case but given the scale of rover I'm building this isn't a big deal.

The only concern is this will use a lot more power than a SBC like a Pi or Jetson but it is far more efficient than a full desktop, it's effectively laptop style components. It's missing the optional WiFi adapter but I'm not bothered by that. I've got some USB ones and with six USB ports on two separate buses that's not going to kill performance for other things.

I'm really impressed with the build quality, silence and compactness of this little thing, it's almost tempting to replace the hulking ancient desktop I use in my cellar workshop with another Wyse 5060 the same. I'm not even sure it'd be any slower.

Hoverboard motor powered rover: Part 3

 

I finally took my rover down to East Essex Hackspace and drove it around a bit.

This showed it to be fairly easy to drive with the ESP-Now Nunchuck remote control and the range is more than I need for basic testing.

At its lowest speed setting the rover doesn't always make a lot of purchase on the uneven ground as it's prone to wheel spinning, but as it's 4WD it always makes some progress. This will be massively helped with some form of suspension.

Four wheels screwed to the corners of a piece of plywood is not an optimum chassis design once the surface is anything less than super smooth, but I knew this when I did it.

On the higher speed settings it digs in, gains momentum and flies about, rattling as it goes. The Kinect shook off of its 3D printed mount and I could hear the cable-tied Raspberry Pi rattling like mad so these things need securing in a significantly better way. I'm building up to stripping down the Kinect and making a custom enclosure of my own.

For the test I was using the 'best' of the three battery packs salvaged from the hoverboards and it lasted just fine.

There's not much else to say about this test but here's a little video I recorded.





Hoverboard motor powered rover: Part 2

One of the features I really want to play with in the rover is some kind of location awareness combined with obstacle avoidance.

There are a lot of ways to do this of varying effectiveness based on the situation.

In one of my many boxes of maker junk I had an XBox 360 Kinect, which like the hoverboard was a thing lots of people threw time at hacking several years ago.

The 360 Kinect is old hat now and more modern sensors do more but I've got the Kinect. More importantly if I want to do things like cut the cable down, remove the case to slim it down etc. etc. they can be had for less than the cost of postage on eBay. So I've bought second one and it's on its way.

The Kinect is a combination of a decent conventional RGB camera, infrared camera and an infrared projector that throws a mass of points of infrared light at the scene. Onboard processors then turn that into an RGBD (red/green/blue/depth) image by mapping the distortion of the infrared dots.

The problem with old open source software is much like old closed source hardware: it stops working.

Not in the fact it's fundamentally broken but the shifting sands of time and internet entropy means once it's no longer heavily maintained and interested people move on links break, software versions change and stuff gets deprecated.

You can still install it from binaries. The SBC I actually wanted to try the Kinect with installed them just fine but then it failed to work with no obvious error.

Moving on to a laptop running a different Linux variant the binaries installed and worked but without sound. The Kinect firmware is missing from the binaries. The firmware is a Microsoft blob of proprietary stuff so that's understandable but the script to download that firmware is missing too. I don't have an immediate need for the onboard microphones but it irks me.

So I shifted to building from source and the instructions are wrong.

Not hideously wrong but links to libraries and git repositories were wrong or out of date and some default installed utilities needed are no longer there. So I muddled through and got it built. If I have a second go at building it, which is inevitable, I'll try to write it up and correct the OpenKinect Wiki.

My being able to correct these problems is one of the strengths of open source software but I fully understand why a lot of people find it frustrating. When I first got the Kinect out of the box it's been lurking in for several years to prove it still worked I installed the Microsoft drivers and developers kit on Windows 10. The Kinect immediately gave results ten years afters release. It 'just worked' in the way everybody moans Windows doesn't.

In parallel with this I've been wondering how to mount the Kinect so as per usual it's 3D printing to the rescue.

I didn't like the look of any of the mounts found on Thingiverse (one of them I tried just didn't fit) so I designed my own. Making very specific module/object mounts for prototyping things seems to be a thing I spend a lot of time doing. The end result is quite nice so I've uploaded it for other people to use.

I've now made a 'deck' on top of the rover that protects and hides the messy motor, driver, battery and power supply wiring. The battery puts out 31-40v but I need 5v and 12v (maybe 3.3v too) buses to drive the control stuff and this wiring begins to take up a chunk of space. There's also on/off switches, battery isolator, charger connections and so on. Deck is a fancy word it's just another bit of plywood  from a skip with stuff screwed to it haphazardly.

First on the list screwed to the deck was the Kinect on its 3D printed mount.

The thing with the Kinect and frankly any other kind of RGBD sensor is they are quite 'heavyweight' sensors in terms of processing power. You get depth information but it's not an easily digestible map; it has to be processed extensively to act on.

This is on top of all the limitations the sensor has physically. It just can't be relied on to reliably prevent collisions etc., even before you allow for any mistakes in my coding and setup.

If you look at almost any autonomous vehicle they will have a whole suite of sensors to keep things safe and to that end I've made an array of three old-school ultrasonic range finders on the bottom of the rover in another 3D printed enclosure. They fit quite nicely between the two motor mounts.

These ultrasonic sensors are decades old tech but you still find them in beginner robotics projects because they're cheap and highly effective at short range. They too have limitations, but should be an OK backstop for making it harder to drive the rover straight into a wall or perhaps more importantly into somebody.

Running these ultrasonic sensors is an old-school Arduino Nano, which frankly is perfect for this task. I may buy another three ultrasonic units and stick an identical array at the rear. The rover essentially has no front other than what I've chosen by sticking the Kinect at one end. It can move and turn the same in either direction. Given how cheap Kinects are I may investigate if it's possible to connect two to one computer but I suspect the answer might be no.

Reading around the topic I've found basic microcontrollers like older Arduinos can be used to feed information into Robot OS (ROS) over USB serial quite easily. So connecting up a bunch of basic sensors pre-processing their outputs and generating something easy for ROS to digest is where I'll concentrate before getting into any complicated mapping.

Hoverboard motor powered rover: Part 1

For absolutely ages I've fancied building a remote controlled rover that's got some physical heft and can handle rough ground. I've never really been into RC cars but a 'robot' is different.

This urge goes all the way back to the 90s when I was a fan of the TV show Robot Wars and at one point I got as far buying some big AGM batteries and wheelchair motors but like with a lot of projects my enthusiasm fizzled out. Part of this was because back when I was first looking at it this was an expensive hobby. Good quality speed controllers, good RC gear and access to the materials and machine tools needed to build something (unless you worked for an engineering company or University Engineering dept.) implied a level of investment in time and money I couldn't really do. I eventually became friends with some people who had competed in Robot Wars but I never built a 'robot' myself.

Now we live in quite a different world.

Electric vehicles of all sizes are now commonplace; from RC quadcopters to commuter scooters, electrically assisted bicycles, motorcycles and cars. Developments in battery technology, brushless motors and semiconductors haven't only been technical improvements but also the cost/performance improvements that come from massive scale manufacturing.

Also, all manner of hobby electronics and computing has become hugely more affordable and accessible. I'm an active member of a Hackspace with access to all the tools I could reasonably need to make something viable and I've a bunch more free time than I used to have, at least for now.

My recent trip to EMFCamp 2022 got me enthused again and while there I bought a 36v eBike 'Silvertail' battery pack as it's a well packaged large chunk of power with a built in battery management system. I've also dived in and bought some broken 'hoverboards' to play with.

The craze for hoverboards a few years back created a glut of cheap second hand ones, often 'dead' due to poor battery management making them refuse to charge. The same poor battery management also lead to a number of dangerous house fires, a reputation that still persists despite battery safety getting better.

Naturally, Hackspace people got hold of these and tried to do things with them.

The motors are very high performance for the bargain bucket second hand price and come with everything you need to drive them, maybe even battery packs if you can replace any dead cells without setting fire to anything. Good speed controllers are still expensive but the ones in hoverboards are kind of adequate.

Lucy Rausch worked out how to replace the original firmware for the ubiquitous controllers in early hoverboards and a whole load of people built comedy vehicles with them. A bunch of Germans are very into converting the popular children's ride-on "Bobby Car" toys into absurdly nippy little vehicles.

I've bought two of these 'dead' hoverbaords and even had a go at reviving the battery packs.

What could possibly go wrong?

There isn't a huge plan here. I just want to enjoy exploring how this works and as I'm coming at it after everybody else has already had a go there's plenty of information out there.

My minimum viable rover is just four hoverboard wheels, controllers and recovered battery pack screwed to a piece of plywood. This is not its final form, which may be six wheeled with rocker/bogie suspension in a vague Mars Rover homage.

The whole project has a bit of a 'what people were playing with 5-10 years ago' thing going on. It's not unexpected as where possible I'm using stuff I already have kicking around in the cellar.

Lacking any RC gear I made my own 2.4Ghz remote using a Wii Nunchuck controller which were ubiquitous in Arduino projects a while back and a couple of ESP8266 microcontrollers sending ESP-Now packets.

I ended up reasonably happy with the resulting code and might publish it even though it overlaps a bit with other published projects.

I'm also minded to play with a bit of collision avoidance and/or location mapping. Not to make the rover autonomous but to make it 'hard to crash into stuff'. This can advance separately from the chassis and basic remote control use. What was everybody enthusing about ten years ago that I had in a crate of junk?

The Microsoft Xbox 360 Kinect.

It's old hat, doesn't work outdoors in direct sunlight and getting old enough that support in modern versions of Robot OS might have disappeared enough that I give up on the idea, but I do have one and it does work as I've tested it with a fresh compile of the open source libraries.

I know in my heart I'll have to buy a proper LIDAR sensor (which like almost everything else have become massively more affordable) but in the meantime I can tinker with this.

So how far have I got?

Not massively far but I do at least have one pair of wheels moving.

Since the original explosion of hoverboard hacking the controller hardware has changed and you can't use Lucy's firmware, but various people have adapted it to the controllers they've found in their hoverboards or even started again from scratch.

One of my scrap hoverboards had controllers supported by one of these firmware variants, the other didn't.

A bit of peering at markings on the microcontroller suggests I could probably reverse engineer the board rework the pinouts and make my own firmware variant but that's going to be time consuming. So I've ordered another pair of identical boards to the supported ones. This was about the same price as another dead hoverboard but you won't know which controllers are inside until you open them.

It does live though...





Buying stuff is the easy part.

For some time I've wanted to build a 'rover' chassis, some kind of remote control electric vehicle that will handle rough-ish ground. This is as much as a learning exercise as it is to deliver a specific prop or vehicle.

I gathered a small mobility scooter chassis and motor some time back but lacked a sensible battery to drive it.

With the explosion of popularity in eBikes, there's a lot of controllers and battery packs making their way onto the secondhand market and one of the people at EMFCamp 2022 was selling a stack of them for project use.

This is a 'SilverFish' battery pack, a quite common but not entirely standardised design that packages the batteries and BMS into a nice solid removeable pack. 

At a nominal 36V it will overpower the 24V motor I have but not excessively so if it's under light load. I've a charger on the way for it and will need to investigate a suitable speed controller.

I'm not thinking of building anything at all autonomous, that's a serious exercise and in something large frankly dangerous, so it'll be traditional radio control gear in use. I am however thinking of making it have FPV video and perhaps some automated collision avoidance using LIDAR so it can be driven without having to follow it.

If the chassis I have doesn't doesn't work out, I'll probably switch to one based around four hoverboard motors doing tank steering as that's a common hacky rover design. Making it usable away from paths will mean modifying the hoverboard hub motors so the wheels are a larger diameter, but again that's a well covered thing.