Thursday, 28 March 2019

On giant mecha - how practical are they?


You know exactly what I am talking about. You've probably run into them at some point, be it through films or some form of animation. This article will be about their practicality, with current technology.

So, first things first, can it stand?


Let's look at some figures.
The tire pressure of an aircraft is the pressure it exerts on the ground (the surface area of the tire in contact with the ground changes depending on the weight of the aircraft, keeping the pressure constant). For most commercial aircraft, it's about 200 psi - or 1 379 000 pascals (Newtons per square meter, approximately 137 900 kg per square meter of tire surface). This is designed for the hard surface of runways and taxiways in an airport - such an aircraft can't land on soft ground and not sink into the ground at least and little.
The ground pressure (as it is called), for more everyday things - like humans - is a lot lower. A human exerts about 55 000 pascals when standing, though this can more than twice that when walking / running (source: wikipedia). A passenger can exerts about 205 000 pascals. A mountain bicycle exerts about 245 000 pascals, while a road racing bike exerts about 620 000 pascals. A stiletto heel can exert as much as 3 250 000 pascals - more than an aircraft (which is why they damage floors and many other surfaces).

Let's see what this translates to. If the ground pressure is to be the same as that of a normal vehicle, a 100 tonne mecha would have to have a surface area of (100 x 1000 x 10)/(205 000) = 4.878 m2 in contact with the ground. To stand on 1 foot (and walk), this would require a foot that is about 2 m wide and 2.43 m long. For one that's half that weight, the required area of the foot would be half of that (about 1.5 m x 1.62 m).This is assuming that pressure is distributed fairly evenly by the foot, which is highly unlikely unless it has a rubber sole (which would immediately make kicks about one third as cool). Chances are, if the mecha are made like humans, more weight would be concentrated on the back of the foot.

Still, according to these calculations, a mecha would probably be able to stand on most surfaces.

Part II - can it not collapse under its own weight?

A major issue we face here is the square-cube law: doubling an object's dimensions, which multiplies its surface area by a factor of four, also increases its mass by a factor of eight. This is a problem, because properties like tensile and compressive strength depend on an object's cross-sectional area. So, when you increase it's strength by a factor of 4, you increase its mass by a factor of 8, which means you need more strength to support the increased weight.

Let's compare some comparable structures.

Falcon 1 rocket: Height: 21.2 m, Diameter: 1.7 m, Mass: 27.67 tonnes (source)
Boeing 747-8: Length: 76.25 m, Wingspan: 68.4 m, Mass (Operating empty weight): 220.128 tonnes (source)
Rockwell B-1 Lancer: Length: 44.5 m, Wingspan: 24 m - 42 m (swing wing), Mass: 87.1 tonnes (source)
Falcon 9 rocket: Height: 70 m, Diameter: 3.7 m, Mass: 549.054 tonnes (source)

I chose the Rockwell B-1 Lancer as an example because it includes a rather large moving part - the wing sweep can be changed in flight.

As you can see, chances are, an average mecha will not crumble under its own weight - if it was standing still. So, you can build a statue of it without a problem. However, that is not what we want, we want it to be able to move, to run, to shoot lasers, and to kick other mecha in the face.

So, it needs to move...


Therein lies the problem. To accelerate a part as heavy as a mecha's legs, you are going to need some very powerful motors. For a 20 m, 50 tonne robot, we can assume that its legs are about 10 m tall - approximately half its height. If one third of its weight is in its legs, and the centre of gravity of the leg is one third of the way down the leg from the hip (both are probably conservative estimates), to swing the robot's leg, you will need a torque of (10/3)*((50 000*10)/3) = 555.56 kNm. A 100 kNm motor looks like this (look at the images this page).

In addition to that, to accommodate all that movement, the legs will have to be strong. As in, it should be able to handle being swung at something at high speed, with something heavy attached to the end of it (the foot, the lower leg, and the knee joint, and all associated actuators/sensors) without bending in the middle.

But I got ahead of myself. In order to kick something in the face, the mecha has to reach said target, and if it is, indeed, terrestrial, it has to walk or run there. Walking can be rather complex. One foot has to be taken off the ground, while the weight balances on the other momentarily, and when that foot reaches the ground, the weight must be transferred to it in order to move the other leg. Running can be more taxing still - the mecha has to generate enough force for both feet to leave the ground temporarily. Besides, running exerts a lot of force on the ground (Newton's third law).

All this means a lot of bending moment on the legs, as it balances the body over the heel like an inverted pendulum. To counter this, you need very strong materials for the legs. If you want it to stand on the ground without turning a paved road into quicksand, and if you want reasonable sized motors / actuators, you will need a light-weight material. There are few materials that meet both these requirements.

Provided we found the right material, we still have to move the individual joints. We will need fairly large motors if we are going to use motors. These motors would probably need a lot of current, which introduces a host of other problems (motor control becomes more difficult, and the wires get thicker and heavier, among other things) Another viable option is hydraulics, which will also be very large and very heavy. You will also need a full hydraulics system if you select this option, which also translates to more weight,complexity, and issues with materials. In either case, the actuator we use must be fast,responsive, and very controllable. Finding or manufacturing such actuators will not be easy.

Power?


In order to do all of this, we need a source of power. Given the space constraints and the energy requirement, nuclear might be the only really viable option, but the reactor size will probably have to decrease a little. Power isn't my area of expertise, so I can't say for sure, but I don't think the technology is there quite yet.

Controllability

And now, my favourite part the discussion - how do you make the robot work?

First, you will need to know the robot's starting configuration - how the limbs are positioned, the robot's posture, whether it's stationary or moving, etc. For this, you will need sensors, and a lot of them. You will need to know the position of each motor. You will need to know the tension on the leg beams. You will need accelerometers and gyroscopes, probably in each limb, to measure current linear and rotational acceleration. All this is available, so there is no problem there.

The next problem is judging where the robot is going to step. You can use a radar to map the contours on the ground, and you could also use images from one or more cameras to help you. A laser scanner could also help, but it could be overkill in this case. Again, we have the technology - it's expensive, and difficult to implement, but we definitely have the technology. If there is any problem here, it's creating a transparent window through the foot to get the images necessary.

This information has to be processed. That shouldn't be too hard, but a possible issue is time delays. Chances are, all control will be by a central processor, which will command lower level processors in the limbs, etc, at a high level (at least, that is the design that makes the most sense to me). In order to get it to walk, the arms, legs, torso, and head movements must be coordinated. Delays in transmitting main control commands could potentially throw the whole system out of sync if the problem is bad enough. If the feedback from the limbs, etc. are delayed, or if the data from those sensors are gibberish, that could cause a problem as well. Also, there is the problem of sensors producing readings at different rates, which can be dealt with, but it can cause problems. The long distances can make data transmission errors more likely, but that can be dealt with.

The next problem is the actuators themselves. If my experience teaches me anything, it is that this part is going to be ridiculously difficult. As I mentioned before, finding motors or other actuators that are powerful enough and quick enough would be difficult. I can't be certain about hydraulics, but with motors, controlling it is going to be difficult because finding a motor control circuit that is small enough, and won't heat too much (or burn out) with intermittent operation would be nearly impossible. The other problem is managing space when installing them (though hopefully that wouldn't be too much of a problem with hydraulics.

To summarize,

Sensing and data processing can be done - it won't be easy, but it can be done.
If you can build it, it will be able to walk without sinking a couple of metres into the ground with each step.
Finding material that can be used to build it will be a problem.
Finding a power source is likely impossible right now.
Finding suitable actuators would be very difficult.

The verdict: It's not possible right now, but maybe it will become a reality in the near future. It might not have any practical use, but it'll be an interesting experiment for nerds like us.

You can follow me on Facebook here for news and updates.

Until next time!

Wednesday, 6 March 2019

Random syllable generator for conlanging

One of the most tiring things about conlanging is generating new words. You could always come up with random words, which works quite well when the number of words you need to generate is in the tens or maybe in the early triple digits. However, there comes a point where you need to formalise the process. Here, I will explain in detail how it can be done, and give  a sample c++ program that can be used for the purpose.

I have described some of the basics in my post Conlanging adventures 001. I will reiterate some of the points here, to make it easier to follow.

So, to generate vocabulary for a conlang, you need:
  1. A sound system: What are the sounds that exist in your language? What consonants exist? What vowels exist? I would recommend using an IPA chart to decide on the sounds that you want to use. You can decide on the exact number of sounds you want to use - after all, some languages have more sounds in them than the others. You may also want to decide on whether you want tones in your language.
  2. How the sounds are combined: In any language, there are specific ways in which sounds can be combines. In English, for example, you can end a syllable in 'ng', but you can't start a syllable with it. This means you have to decide on the possible starting consonant clusters, vowels, and ending consonant clusters. You can choose to eliminate one of the consonant clusters completely (i.e., if it's a language like Japanese, the only possible ending consonants are 'n' or nothing, with nothing being much more common). If you're particularly daring, or if you're Russian, you can go ahead and make the vowel cluster optional as well. You have to decide the maximum length for each cluster as well.
If you have decided on these, we can go on to generate syllables.

Let's start with a simple language as a sample. First, let's decide on a set of simple sounds.
Consonants: k, g, p, t, d, n, m, r, h, s
Vowels: a, e, i, o, u

Next, we need to decide on possible consonant clusters.
Starting consonants: k, kr, g, gr, p, t, tr, d, n, m, r, h, s, sr
Vowels: a, e, i, o, u, ai (basic vowels + one diphthong)
Ending consonants: k, kt, g, p, pt, t, d, n, ng, m, r, s

I will consider the starting and ending consonant clusters optional, so the generator would have the option to drop them.

Without further ado, let's get to the program.

EDIT: there is a problem that I discovered after testing the program - cin will read all the characters you input, and use it as the input the next time cin is called (for example, if you type "yes" instead of "y", it will read that input as "y", the next input as "e", and the next as "s"). The fix is to clear cin and skip over all the other characters in the buffer. The commands used for the purpose are cin.clear() and cin.ignore(10000, '\n');. I have highlighted those edits in red in the code.


#include <cstdlib>
#include <iostream>
#include <string>
#include <random>
#include <time.h>


using namespace std;

#define LENGTH_STCONST 15
#define LENGTH_VOWELS 5
#define LENGTH_TECONST 13


string stConst[LENGTH_STCONST] = {"k","kr","g","gr","p","t","tr","d","m","n","r","h","s","sr"};

string vowels[LENGTH_VOWELS] = {"a","e","i","o","u"};

string teConst[LENGTH_TECONST] = {"k","kt","g","p","pt","t","d","n","ng","m","r","s"};


/*
 *
 */
int main(int argc, char** argv) {
   
    //Loop exit variables
    int end = 0; //main loop
    int st_end = 0; int v_end = 0; int te_end = 0;//cluster loops
   
    //For user input
    char inChar = '\0';
    //For addressing arrays
    int index_0,index_1,index_2;
   
    //random number generator
    default_random_engine generator;
    //distributions - three uniform int distributions used.
    uniform_int_distribution<int> distribution_0(0,(LENGTH_STCONST-1));
    uniform_int_distribution<int> distribution_1(0,(LENGTH_VOWELS-1));
    uniform_int_distribution<int> distribution_2(0,(LENGTH_TECONST-1));
   
    /*discard random number of random numbers*/
    time_t now = time(0);
    cout<<now<<endl;
    int skip_time = now%10000;
    cout<<"skip time: "<<skip_time<<endl;
    for (int i = 0; i<skip_time; i++){
        index_0 = distribution_0(generator);
        index_1 = distribution_1(generator);
        index_2 = distribution_2(generator);
    }
   
    //main loop
    while (end==0){
        //set cluster loop variables to zero
        st_end = 0; v_end = 0; te_end = 0;
       
        //User input
        cout<<"Generate new syllable? Y/N"<<endl;
        cin>>inChar;

        cin.clear();
        cin.ignore(10000, '\n');
       
        //Exit program if exit command is given
        if ((inChar=='n')||(inChar=='N')){
            cout<<"Exiting loop"<<endl;
            end = 1;    //set end variable
            continue;   //exit loop
        }
       
        //generate index using random number generator
        index_0 = distribution_0(generator);
        index_1 = distribution_1(generator);
        index_2 = distribution_2(generator);
        cout<<index_0<<" "<<index_1<<" "<<index_2<<endl;
       
        //print generated syllable
        cout<<stConst[index_0]<<" "<<vowels[index_1]<<" "<<teConst[index_2]<<endl;
       
        //cluster loops, to modify either starting, vowel, or end clusters only
        while(st_end == 0){
            cout<<"Generate new starting consonant cluster? Y/N"<<endl;
            cin>>inChar;

            cin.clear();
            cin.ignore(10000, '\n')
            if ((inChar=='n')||(inChar=='N')){
                st_end=1;
                continue;
            }
            else{
                index_0 = distribution_0(generator);
                cout<<stConst[index_0]<<" "<<vowels[index_1]<<" "<<teConst[index_2]<<endl;
            }
        }
       
        while(v_end == 0){
            cout<<"Generate new vowel cluster? Y/N"<<endl;
            cin>>inChar;

            cin.clear();
            cin.ignore(10000, '\n')
            if ((inChar=='n')||(inChar=='N')){
                v_end = 1;
                continue;
            }
            else{
                index_1 = distribution_1(generator);
                cout<<stConst[index_0]<<" "<<vowels[index_1]<<" "<<teConst[index_2]<<endl;
            }
        }
       
        while (te_end == 0){
            cout<<"Generate new ending consonant cluster? Y/N"<<endl;
            cin>>inChar;

            cin.clear();
            cin.ignore(10000, '\n')
            if ((inChar=='n')||(inChar=='N')){
                te_end = 1;
                continue;
            }
            else{
                index_2 = distribution_2(generator);
                cout<<stConst[index_0]<<" "<<vowels[index_1]<<" "<<teConst[index_2]<<endl;
            }
        }
    }

    return 0;
}



Explanation:
Includes: iostream - used for cin and cout.
string - we need strings, because we have multiple letters in a cluster. Alternatively, you can use 2D arrays (which you will have to use if you use C instead of C++), but I find strings more versatile.
random - used to generate random numbers.
time.h - used to randomize random numbers using current time, because I find that it keeps generating the same syllables otherwise.

Defines: used to define the size of each of the string arrays that follow. If you need to make a cluster optional, I would recommend making the size of the array larger than the number of consonants you have.

Array declerations:  
string stConst[LENGTH_STCONST] = {"k","kr","g","gr","p","t","tr","d","m","n","r","h","s","sr"};
Here, an array of strings is used to store all possible starting consonant combinations. As you might have noticed, the length of the array is defined as 15, though there are 14 entries. The extra entry remains null, which is used to account for the fact that the starting consonant cluster is optional.
The vowel clusters and terminal consonant clusters are defined the same way. The terminal consonant cluster also has an extra, null entry.

Main program:
First, the exit variables for the loops are declared. Then, the input character for user input, and variables for array indexes are created. Afterwards, the random number generator is declared. You could use rand() instead, but this method is a little more reliable.
 Next, a random number of the generated numbers are discarded. This is because the program tends to generate the same random numbers, and thus the same syllables otherwise. To do this, time_t now = time(0) is used to get the current time in seconds from 00:00, 1st January, 1970. Since I have no intention of looping that many times, I take the modulus of 10,000, and discard that many random numbers from each distribution.

Main while loop:
Here, first, the cluster loop end markers are reset to zero. Then the user is prompted to input whether they want a syllable generated. Then, the random number generators defined are used to generated three random integers in the range  (0, length of array) for each of the three components. This is then displayed.

Then comes the optional part. The three cluster modification loops allow the user to regenerate one of the three components while keeping the other two components of the syllable the same. I find it useful for the conlang I use regularly (because there are so many sounds, some technically possible combinations sound weird) but you can delete the three cluster loops if you want to.

Program output: 
The program output is as follows. For clarity, I will highlight user inputs in red and generated syllables in green.

1551861330
skip time: 1330
Generate new syllable? Y/N
y
13 3 4
sr o pt
Generate new starting consonant cluster? Y/N
y
n o pt
Generate new starting consonant cluster? Y/N
y
gr o pt
Generate new starting consonant cluster? Y/N
y
 o pt
Generate new starting consonant cluster? Y/N
y
h o pt
Generate new starting consonant cluster? Y/N
n
Generate new vowel cluster? Y/N
n
Generate new ending consonant cluster? Y/N
y
h o p
Generate new ending consonant cluster? Y/N
y
h o m
Generate new ending consonant cluster? Y/N
y
h o kt
Generate new ending consonant cluster? Y/N
y
h o t
Generate new ending consonant cluster? Y/N
y
h o n
Generate new ending consonant cluster? Y/N
y
h o pt
Generate new ending consonant cluster? Y/N
n
Generate new syllable? Y/N
y
4 0 1
p a kt
Generate new starting consonant cluster? Y/N
n
Generate new vowel cluster? Y/N
n
Generate new ending consonant cluster? Y/N
n
Generate new syllable? Y/N
y
0 2 4
k i pt
Generate new starting consonant cluster? Y/N
n
Generate new vowel cluster? Y/N
n
Generate new ending consonant cluster? Y/N
y
k i g
Generate new ending consonant cluster? Y/N
y
k i kt
Generate new ending consonant cluster? Y/N
y
k i t
Generate new ending consonant cluster? Y/N
n
Generate new syllable? Y/N
n
Exiting loop

RUN SUCCESSFUL (total time: 55s)


I hope you found this useful. If there is anything you would like clarified, please mention it the comments below and I will reply as soon as possible.

You can follow me on Facebook here for news and updates.

Until next time!




How to write a character who is smarter than you

We all have that one character (or few) who is significantly smarter than the writer. So, as a writer, how do you write such a character con...