Wednesday, February 22, 2017

Making a "Mega" Shopping Trolley


Shopping Trolleys

This is a short post explaining how to make a "Mega" Shopping Trolley, and is written from an Australian perspective. Now I'm not talking about those metal/plastic carts (known as "Trundles" in New Zealand) that you push around the supermarket and invariably has a wonky castor. Rather, I mean the sort of thing that you try and stuff as much as you can in, and pull behind you on the way home full of groceries. The sort of thing that looks like these:


Now for a small amount of shopping these are almost OK, but they have two main issues. The first is that they never seem to be big enough for what you need to buy. The second is that they tend to wear out quickly with repeated use. Typically either the fabric rips or tears, or more likely the wheels (which are the cheapest part of the trolley) will break.That last can be really awkward when it happens on the way home. The solution to this is to make your own trolley, and it's simple (and relatively cheap) to do.

Make your own Trolley


I first constructed my own trolley shortly after I could no longer afford to run and keep my own car. Being on a fixed income, I still needed a way to get the groceries back home on the bus, which I now used. The earliest record of my Mega Trolley was in my comic Floods and Storms, which recounts what happened in 2007 when a monster storm hit the Newcastle area. Here's what it looked like:



As you can see, it's easy to make. You need a work trolley (usually one that folds away, a large (50 litres or more) squarish bin with the top removed, and a couple of "bungee cords" (elasticized cords with hooks or looks on the end). You fold out the work trolley, place the bin on folded-out base plate, and then attach the two bungee cords around the bin so that each each is secured around a shaft of the trolley. For example, my current mega trolley looks like this:



The bungee cords go inside and around the shaft. These have a loop on the end that you can lock, and were better to use than ones with hooks because the shafts of the trolley were square in shape and hooks wouldn't hold properly. This rig initially (in 2007) cost me $29 for the work trolley from ALDI, $20 for the bin from Big-W, and $7.50 for the special bungee cords from Bunnings. That's $56.50 all up, but the wheels won't break easily on this and the fabric won't rip (unless you're doing something SERIOUSLY WRONG)!!

Usage

In general a trolley with no groceries in will be easy to carry on a bus or train. It won't take up much more room than a regular commercial trolley, and the only extra weight will be your own shoulder/hand bag plus 2-4 shopping bags. One technique I've used is placing the unfilled trolley into the middle of a shopping cart. As you go from store to store you place the purchased items behind the trolley, and put the items you're about to buy in front. Here's an example of that.


I started using this technique based on my own needs. Two full front compartments is about the limit of what the trolley will carry, and I have a practise of shopping for groceries at Coles / Woolworths first, and then at ALDI second (mainly because they have sorting tables, which allow me to repack the trolley). Of course if you have other things to buy, like a magazine for example, you might want to buy those before doing your grocery run, rather than pull a full trolley behind you.

Once you've finished your grocery shopping, find somewhere to repack your items into the trolley. Removed the trolley from the cart and place on the floor. Place heavy hard/items at bottom and lighter/bulkier items at the top. From my own experience I've found it best to use the trolley with a variety of shopping bags. Heavy and solid items can be placed in the bin, but additional bags and be placed on top, and the handles of the bags placed around the trolley so that they won't fall off. Here's an example of that, being inspected by Bobby the dog.


In the photo above I have a "cold bag" on top of the bin, and a couple of overflow bags on the back. The purple bag on the top probably has bread (or something else that I don't want crushed) in it. The main thing is to make sure that the trolley's centre of gravity is lower than the top of the bin, otherwise pulling the trolley will be a bit random.

Pull the trolley with either palm up or down. It's better to pull it slightly to one side rather than directly behind. To get on the bus pull the trolley up to the door, step up, turn around and lift with two hands (bending knees if needed). When you exit the bus you can just pull the trolley out and allow the base plate to take the load. If you have to go up steps allow the wheels to take the load. Once you get home, unpack and store any objects in cool bags first.

Maintenance and Replacements

A mega trolley is like an axe or a broom, when any of the three parts (trolley / bin / cords) wear out, replace it and carry on. In practise I've found that the trolleys will wear out before the bin and bungees. Here's a comparison of three types of work trolley I've used for my mega trolley:


The trolley on the left was purchased as a special from ALDI in 2007. It lasted for 2 years until I started having problems with the wheels. The issue was that the mechanism that folds up the trolley base plate also folded the wheels backwards into the flat of the trolley. After a while empty trolleys, being lighter, would tend to fold up as I was walking pulling the trolley along! The middle trolley is one of several bought from Bunnings over the years. This type of trolley sometimes also folded up unexpectedly, but the main problem with it is that they wheels have soft rubber rims, and these wear out over time, especially if you don't have a sidewalk and have to pull them down a blue metal street! The trolley on the right was also bought at ALDI (in fact I assembled it on the sorting table) and so far has no problems. The other issue with these trolleys is their height. I'm 185cm tall, and the taller one at right is far easier to pull behind me than the other two, which for me involved a bit of a crouch.


The width of the trolley affects which bags you can attach to them. I've found that cold bags will fit on all of them, but regular "eco" shopping bags struggle with the one on the right. My solution is to use slightly larger bags from Big-W and longer bags from Bunnings.



The other thing about these trolleys is the wheels. As you can see above, the first two have wheels that are explicitly attached to the trolley. That's only an issue when they wear out, like the ones in the middle, because you can't replace them. You then need to buy a new trolley. The wheels at right are attached with washers and a "splint". If these wear out I should be able to buy replacements or equivalents from a local hardware store like Bunnings.

And that's it - pretty basic but way more effective than those silly frabric and plastic trolleys that break on you.

Monday, February 20, 2017

Leveller for OpenSimulator (part 2)

Exporting from Leveller to Opensim

This tutorial looks at working with Leveller (a powerful 3D terrain editor for windows from Daylon Graphics) and OpenSimulator (Opensim). Part 1 explained how to import terrains from Opensim into Leveller. This part explains how to export heightfields in Leveller back into Opensim.

OpenSimulator Regions used

This part uses the four regions of test00, test01, test10, and test11 to demonstrate exporting terrains from Leveller back into the grid.



The listing for these regions likes a bit like...



...however the positions are only important  when importing the heightfields files using load-tile command.

Exporting single regions

To demonstrate exporting single regions we'll be using the following example from Leveller...



This 256x256 document was created by creating eight shapes, giving each a height (as shown on the map at right and then selecting all shapes followed by executing a Shapes > Heightfield from Selected Points command. Finally the water level was set using Edit > Water Level > Elevation to 20.

Exporting to In-World

You can export the above Leveller document as a RAW file for loading in-world. To do this, select File > Export and pick the Second Life option. After selecting a file to save to (it needs to be an existing RAW file, but you can easily copy the file and rename that copy) you might see something like this:




If the document has any heights less than zero you will get an error and the export will fail. It's best to play around with Original Elevations and Use per-pixel scaling. Once you've exported the file, you can go in-world and load it via your viewer.

You have to be the owner of the region in order to upload the raw file. Go to the Region / Estate dialog box and select the Terrain tab. You'll see something like this:



Select the Upload RAW terrain button, select the file and the terrain will be loaded. It should look something like this:


  
The submerged area above is roughly at 20m and matches the default water level. However on the original Leveller document that coastline contour is 20.6, and clears the waters. There's some trade off and inaccuracy using the .raw format. Compare this with exporting in .ter format (below). 
 

Server commands for saving terrains

The following two methods use server commands to save region's terrains. Server commands are made within the Opensim console. These examples are taken using ConEmu, a "Windows console emulator with tabs, which presents multiple consoles and simple GUI applications as one customizable GUI window with various features". ConEmu, rather than the Windows command line was used, as ConEmu behaves more like a Linux terminal, with the user being able scroll back through previous lines and reports, and use the up arrow to see (and then edit) previous commands. Users are also able to copy and paste from and to the console easier that with the standard  DOS prompt, and key shortcuts and colour schemes can be set for convenience.  All this makes using the Opensim console a lot easier for a Windows user. Other OSs may have their own equivalents. ConEmu was used as I predominantly use Windows and Windows apps (and hence Leveller).

For single regions

Leveller can export a heightfield to Opensim  simply by exporting using Terragen format (.ter). To do so, select File > Export and select the Terragen option. After selecting a file to save to, the dialog should look something like this:



To load the terrain for a single region you must first change to that region. You do this by using the "change region" command. For example, to go to the test00 region we'd type...


change region test00 [ENTER]

...and the console prompt should now show...


Region (test00) #

If it doesn't, you may have mistyped the name of the region. Making typos like that can create unexpected errors! Assuming you have now selected the region, You would use the "terrain load" command to save that to a particular file. For example...


terrain load N:\OpenSim\HeightFields\Leveller\Tutorial\in-world\test00.ter

...would load the terrain from the test00.ter file in that directory (you need to put quotes around a file path name if it has spaces in). The format of the file save is determined by the extension used as follows:
Extension File Format
.r32/f3232bit RAW,
see RAW, 8 bit, 16 bit, and 32 bit explained
.terTerragen heightfield,
see Terragen™ Terrain file specification
.rawlinden labs/Second Life RAW,
see Tips for Creating Heightfields and Details on Terrain RAW Files
.jpg/jpegJoint Photographic Experts Group  image format.
.bmpdevice independent BitMaP
.pngPortable Network Graphic
.gif Graphics Interchange Format
.tif/tiffTagged Image File Format
.gsdgeographic survey data file
As you can see above, the example file was loaded in the Terragen format. The reasons for choosing that format are that it is a heightfield format rather that a graphics format, and that Leveller uses a modified Terragen format for its documents. If this is successful the console should look something like this:

  After loading the file in the region it'll look something like this in Opensim:



Here's a comparison between .raw and .ter exports, using the in-world map:



A good work practice is to use the Leveller document as a master file, and to make changes in that, rather than later re-import that region a second time to make modifications. Here's the above region re-imported back into Leveller using a raw file generated in-world...



...not pretty is it? Most of the bumpiness and abstraction is caused by using an image format to save heightfield data. If you own or rent a region but can't access the console for that grid, see if you can get the administrator to use terrain save (see part 1) and terrain load to for you (using .ter format), rather than using a .raw file.

For tilesets

In Opensim you can create regions that are square with dimensions in multiples of 256, for example 256x256, 512x512, 768x768, and so on. However at present you cannot have two regions of different sizes adjacent, without having issues  with one or more of those regions. So, in general you won't see a 256x256 region next to a 512x512 region, but you may see a string of 256x256 or larger regions together. A "tileset" is a collection of adjacent or connected regions of the same size. The following is a 512x512 example we'll be using in Leveller (which will be a 2x2 tileset of 256x256 regions):



You can just see the 256m grid lines on the map. This is also an example of  the MicroDEM colour scheme. Leveller allows you to change display colours for heights. It's also an example of me playing around with different tools!

Export a Leveller document as a PNG

Leveller can export the above as a PNG file. To do so, use the File > Export command and select the PNG option. After choosing a filename, and opening option, you should see something like this:



After OKing that, the following gets created in that directory:



The .wld and .xml  files are created by Leveller in the process of making the PNG. And the PNG looks something like this:


Load-tile command

The single PNG file created above for a tileset, can be loaded into Opensim using the terrain load-tile command in the console. This only works saving to a PNG file. The syntax is:
terrain load-tile <filename> <tile width <tile height> <xstart> <ystart>

...and where: <filename> is the file name of the of the saved file (e.g. 2x2tileset(default).png), and <tile width <tile height> is the width and height of the tileset, and <xstart> <ystart> are the grid's x and y location of the south west corner of the tileset (e.g. 1102 1000 for the sample island is the test00 region). However, you must also select each region in the tileset in sequence, and then repeat the command for that image, in order to load the section of that PNG that corresponds to the region selected.

For example, to load the PNG image above into test00, test01, test10 and test11, you would need to do the following commands:



Unlike the save-tile command (see part 1), you can load images that are not just in the /bin directory! The result of the above commands is...



Now this looks like the heightfield alright, but it seems to be a bit exaggerated, and what's happened with the water level? Comparing the Leveller map with the Opensim map, we can see this more clearly:


The water level hasn't changed in Opensim so it must be something to do with the format of the PNG (16bpp and the map elevations range). You can either go back to Leveller and fiddle around with the export settings (and check the document for silly errors like setting the water level at the wrong height, though in the above example it was set to 20.0008m in Leveller), or you can fiddle around with the height field either in-world, or via the console. If you want to go via the console method, select the region and try playing around with the following commands:
terrain elevate <num>
Raises the current heightmap by the specified amount.
terrain lower <num>
Lowers the current heightmap by the specified amount.
terrain multiply <num>
Multiplies the heightmap by the value specified.
terrain rescale <min> <max>
Rescales the current terrain to fit between the given min and max heights
terrain revert
Loads the revert map terrain into the regions heightmap.
In this instance I was able to fix the height issue buy using terrain lower 11 in each region. The result looks like...



But, the solution won't always be to do that command - it varies depending on the terrain. There is a third alternative, and that's to use the Export tileset feature of Leveller. 

Exporting tilesets from Leveller

Leveller now has an Export Tileset option which will automatically export a Leveller document as a set of Terragen formatted files suitable to be imported using terrain load within Opensim. To create this, use File > Export Tileset. The following dialog will appear:



There are several sets of options on this dialog. Output filename allows you to select both the directory to save the tile files in, and a "base name" to use how those files are named. The directory you use for a tileset export should either be empty, otherwise confusion might result.The base name (e.g. if you enter test.ter, the base name is test) is added to codes generated by Leveller to indicate where in the tileset the file goes. For example test_x0_y2.ter should be loaded into the region in the bottom row (numbering starts with 0) and 3 columns from the left. See below for an efficient way of doing this.

Tiling has two ways to decide split up the document into tiles - by px per tile, and by the number of tiles across and down the tileset. If you always use the same size regions (and they'll always be square in Opensim) then you might just just use that option (e.g. 256), but choosing the second might be easier if you're working with larger sized regions. The Elevation offset is added to the the heightfields of the exported files, and works the opposite way to the same option on Import Tileset. It defaults to 20 which matches the default water level in Opensim, but can be changed.

The water height may be an issue with the current example. Above I mentioned it was set to 20.0008m (some minor rounding errors). If we're using the Export Tileset method, that expects the water level to be at 0m in Leveller. Now we could either go back into Leveller and drop the heightfield by 20m, and then then set the water level to 0m. To drop the whole heightfield we'd either select all (or none) and then do Filter > Elevate and use the following settings:



Setting the water level is as simple as Edit > Water lever > Elevation and entering 0.0 m (works better than just plain 0). Now that might a good thing to do if you're working on several documents and most of them have the Water Level set to 0. However, if we just wanted to export that tileset now and doing that later, we could just enter 0 m for the Elevation offset instead! Assuming that we do, here's what the dialog might now look like:



After you OK that, the files in the Export sub-directory will look like this:



The next step is loading the files into Opensim using the terrain load command as detailed above. You simply change regions and then terrain load for each. The following is how this would look in the console for the example tileset...



...and here's the result in-world:



No adjusting needed!



Part 3 shows how to make terrain using shapes.
 

Sunday, February 19, 2017

Leveller for OpenSimulator (part 1)

Importing from Opensim to Leveller

Leveller is a powerful 3D terrain editor for windows from Daylon Graphics. With Leveller the user can "paint" terrain, use vectors to create contours (which can then create heightfields) and use a variety of filters and tools to create distinctive and realistic terrain features (see the website for a more complete list of features). Users can also import and export heightfields in a variety of formats, and the latest update includes methods to easily import from and export to terrains with OpenSimulator (Opensim for short). This tutorial gives a run though on how to do that and why.

Why use an external terrain editor?

While it is possible to create and edit terrain within Opensim, this is a mixture of in-world techniques inherited from Second Life, and brute force console commands. It is possible to get exactly what you want, but using an external terrain editor to create or edit terrain has the following advantages:
  • Editing a set of adjacent regions becomes a lot easier, as the editor can be used to edit the terrain for all the regions;
  • Real world terrain can often by imported into the editor and then exported into a grid;
  • It provides the user with greater precision in editing the terrain, and terrain can easily be copied and/or divided into different documents;
  • Dedicated terrain editors have tools which better emulate real terrain, and/or are easier to use;
  • Terrain editors may have several levels of "undo", and backing up terrain sets; and
  • Once you have a separate heightfield document, you can usually export it to a different editor if you want, and also use it in other applications (such as Unity).
Using a dedicated terrain editor encourages a certain type of work flow.  The editor's version of the heightfield becomes the main or "master" version. Edits (and backups) then get made in the editor and exported to Opensim. Minor changes might be made in Opensim, but once the heightfield is in an editor's document format, that is the version that gets edited for major changes. The limiting factor is how you can get terrain into and out of Opensim. Any terrain editor you're using needs to be able to read and write in a format that Opensim can understand. In the following examples we'll be using a sample grid, as shown below:
A four region island.
As you can see the terrain's already been edited and the larger island is composed of regions eeny, meeny, miny, and moe. These will be used to demonstrate saving terrain to be imported to Leveller. The four other regions of test00, test01, test10, and test11 will be used to demonstrate exporting terrains from Leveller back into the grid. The listing for these regions likes a bit like...



The positions only become relevant when importing and exporting tilesets of multiple regions. We'll tackle importing to Leveller in this part, as the tutorial assumes you already have one or more regions in  one or more grids (even if that is only a stand-alone grid). 

Importing via a viewer

You can save a region's terrain as an RAW file from in-world via the viewer if your avatar owns the region. You need to find the Region/Estate menu option within the viewer. The location of this can be different depending on which viewer you're using (the example below is using Singularity) and sometimes the ALT-R shortcut is assigned to it. Find the option and select it. When the Region/Estate dialog appears, move to  the Terrain tab, as per below:



Selecting Download RAW Terrain will save the current definition as a RAW so the image is used to store heightfield data file. A RAW file is an image file. It can be edited in Photoshop and other graphics editors but it can also be read by Leveller. After you've saved the file you'll have something like this:
 

In this example we are only saving the terrain from the eeny region. To import this file into Leveller, go to that application and select from the File menu the Import option and from the list of formats select Second Life. You then use the browser to select the .raw file to read and will see something like this:



The choices are Elevations, Water elevations, and Original elevations. The Water channel comes from raw channel 3, whereas the others come from raw channels 1+2, and 12+13, respectively. A local coordinate system is set with the origin in the south west corner, to match the ground coordinates that Second Life uses. After loading the raw file you should then see something like this in Leveller:



This import can now be edited in Leveller. There may be some inaccuracy in using .raw files.  

Server commands for saving terrains

The following two methods use server commands to save region's terrains. Server commands are made within the Opensim console. These examples are taken using ConEmu, a "Windows console emulator with tabs, which presents multiple consoles and simple GUI applications as one customizable GUI window with various features". ConEmu, rather than the Windows command line was used, as ConEmu behaves more like a Linux terminal, with the user being able scroll back through previous lines and reports, and use the up arrow to see (and then edit) previous commands. Users are also able to copy and paste from and to the console easier that with the standard  DOS prompt, and key shortcuts and colour schemes can be set for convenience.  All this makes using the Opensim console a lot easier for a Windows user. Other OSs may have their own equivalents. ConEmu was used as I predominantly use Windows and Windows apps (and hence Leveller).

For single regions

To save the terrain for a single region you must first change to that region. You do this by using the "change region" command. For example, to go to the eeny region we'd type...


change region eeny [ENTER]

...and the console prompt should now show...


Region (eeny) #

If it doesn't, you may have mistyped the name of the region. Making typos like that can create unexpected errors! Assuming you have now selected the region, You would use the "terrain save" command to save that to a particular file. For example...


terrain save N:\OpenSim\HeightFields\Leveller\Tutorial\single\eeny.ter

...would save the terrain to the eeny.ter file in that directory (you need to put quotes around a file path name if it has spaces in). The format of the file save is determined by the extension used as follows:
Extension File Format
.r32/f3232bit RAW,
see RAW, 8 bit, 16 bit, and 32 bit explained
.terTerragen heightfield,
see Terragen™ Terrain file specification
.rawlinden labs/Second Life RAW,
see Tips for Creating Heightfields and Details on Terrain RAW Files
.jpg/jpegJoint Photographic Experts Group  image format.
.bmpdevice independent BitMaP
.pngPortable Network Graphic
.gif Graphics Interchange Format
.tif/tiffTagged Image File Format
.gsdgeographic survey data file
As you can see above, the example file was saved in the Terragen format. The reasons for choosing that format are that it is a heightfield format rather that a graphics format. Leveller also uses the .ter extension for its documents but these are not in Terragen format. Leveller can however easily import and export in Terragen format. To import this file into Leveller, from the File menu select Import and change the format to Terragen Terrain. After selecting a file you will something like this:



After loading the file it'll look something like this:



Notice how using Terragen instead of Raw gives a smoother result.

For tilesets

In Opensim you can create regions that are square with dimensions in multiples of 256, for example 256x256, 512x512, 768x768, and so on. However at present you cannot have two regions of different sizes adjacent, without having issues  with one or more of those regions. So, in general you won't see a 256x256 region next to a 512x512 region, but you may see a string of 256x256 or larger regions together. A "tileset" is a collection of adjacent or connected regions of the same size, with each region being one tile. The following three examples are taken from 3rd Rock Grid:



The above is a 2x2 tileset, surrounded by non-region water areas.



The above is a 3x1 tileset, surrounded by non-region water areas.


The above is a 2x3 tileset, surrounded by non-region water areas, but one that also includes gaps where there are no regions. The large island in the example used for this tutorial is a 2x2 tileset. 

Save-tile command

It is possible to save a single file for a tileset using the terrain save-tile command in the console. This only works saving to a PNG file. The syntax is:
terrain save-tile <filename> <tile width <tile height> <xstart> <ystart>

...and where: <filename> is the file name of the of the saved file (e.g. EnnyIsland-all.png), and <tile width <tile height> is the width and height of the tileset, and <xstart> <ystart> are the grid's x and y location of the south west corner of the tileset (e.g. 1100 1000 for the sample island with is the eeny region). The command is a little buggy in that it may fail if you add a path to the file name of the saved file (under Windows it gets saved in the \bin sub-directory) and a single command doesn't save all the regions terrain, but rather the terrain of the region you have currently selected.
For example if your current region is moe and you do the following command...
terrain save-tile EnnyIsland-all.png 2 2 1100 1000

...you would get the following result:



As you can see only the top left region (moe) has been saved to the file, the other regions are transparent. If you had eeny selected instead, you would get...



To save all the region's terrain, you need to change regions one at a time and repeat  the same command:





...will produce this result:



You can import this file to Leveller by doing an import as per above, but using the PNG option instead of .ter. The result will look something like this:



Note how the terrain looks very terraced. This is a result of using a graphics format instead of a heightfield format.

Saving tilesets for Leveller

Leveller now has an Import Tileset option which will automatically import saved terrain files from a tileset and place them correctly - provided you name the terrain files correctly first. To do this, you follow through the procedure outlined under For single regions for each region in the tileset. Each file must be in Terragen format (.ter) and its name must use the syntax base_xN1_yN2, where base is any text you want as long as it is the same for each tile, N1 is the horizontal tile index starting at zero and growing eastward, and N2 is the vertical tile index starting at zero and growing northward.
For example, in saving the sample island, the following commands were used...


Notice how the regions were changed between terrain saves, and how the file names were adjusted slightly to reflect the position of that region in the tileset. This results in the following files in Import directory:



 We now swap to Leveller and select File > Import Tileset. After selected that directory we would see something like this:



The elevation offset (set to -20 by default) will adjust the heightfield after import. Opensim's default water level is 20, but Leveller's (and other programs like L3DT) default water level is zero. This allows the user to automatically adjust when importing from Opensim, and there is an export equivalent that adds height back on. We won't change this value. After import you should see:

This is much smoother the heightfield is when compared with the PNG import. We might want to adjust  those grid lines on the map. Going to Navigation > Gridlines we'll see something like this:

Delete all spacings except for 1, and add 256 before OKing. Now the map will look like this, showing the different region's borders:




You can have gaps in the tileset, like the 2x3 tileset from 3rd Rock Grid. In this case Leveller just replaces empty positions with blocks of 0m heightfields. 



In part 2 we'll show how to export 

heightfields back to Opensim