What are the differences and advantages of Hub Motor and ordinary motors?
The basic idea is the same. In a normal motor, you have a hollow, outer, ring-shaped permanent magnet (sometimes called a stator) that remains stationary, and an inner metal core (called a rotor) that rotates inside it. The rotating rotor has a shaft passing through the middle to drive the machine. But what if you grip the shaft too tightly to spin and start the motor? The rotor and stator then have no choice but to swap roles: the normally stationary rotor remains stationary while the stator rotates around it. Try it with an electric toothbrush. If your toothbrush (broadly speaking, it's attached to the static part of the motor), instead of holding the plastic, try holding only the bristles, then turn it on. It's tricky to do this because the brush moves so fast, but if you do it right, you'll find the handle swinging back and forth slowly. This is basically what happens in in-wheel motors. You attach the usually rotating bottom bracket to the static frame of a bike or the chassis of a car. When you turn on the power, the outside of the motor spins and becomes the wheel (or wheels) that drive the vehicle forward.
What are the advantages of in-wheel motors?
It depends on whether you are talking about electric bikes or electric cars. Adding a hub motor and battery to your bike is a combination of pros and cons: you add weight to your bike, but in return, you get a pleasant and easy ride when you don't want to pedal. In the case of electric vehicles, the benefits are even more pronounced. A typical car (including engine, transmission, and chassis) can weigh 10 times as much metal as its occupants, which is one reason cars are so inefficient. Replacing the heavy duty engine and transmission with an in-wheel motor and battery, you'll have a car that's lighter and uses energy more efficiently. Removing the engine bay also frees up a lot of space for passengers and their luggage - you can put the battery behind the back seat!
Vehicles powered by in-wheel motors are much simpler (mechanically less complex) than normal vehicles. Suppose you want to reverse. Instead of using carefully arranged gears, all you have to do is reverse the current. The motor spins backwards, and then spins backward! What about the four-wheel drive? This is a fairly expensive option for many vehicles - you'll need more gears and a complicated driveshaft - but it's an easy fix with in-wheel motors. If you have an in-wheel motor on each of the four wheels of your car, you automatically get a four-wheel drive. In theory, it's easy enough to get the four motors to turn at slightly different speeds (to help cornering and steering) or torque (to get you moving in muddy or uneven terrain).