Streaming de dados do C ++ para o Node.js.

Se você já trabalhou com addons C ++ para o Node.js, sabe que há muito trabalho para que eles funcionem bem com o resto do seu programa JavaScript. Depois de aprender como acompanhar as alterações da V8 usando a NAN e como lidar com as conversões de tipo de dados C ++ / JavaScript, você também precisa lidar com funções de adição assíncrona. O padrão assíncrono – sobre o qual eu postei antes – é complicado, para dizer o mínimo. Usar o padrão assíncrono permite que o código Node.js chame C ++ e receba dados por meio de um retorno de chamada, permitindo que o addon C ++ funcione em um thread separado. Isso permite que o código adicional seja executado na CPU por longos períodos sem amarrar o loop de eventos do Node.js – uma grande vitória. Depois de dominar tudo isso, você começará a pensar em como pode suportar abstrações de nível superior para mover dados de fluxo de dados entre Node.js e C ++. Esta postagem abrange a primeira parte do tópico – fluxo de dados do C ++ para o Node.js, e eu seguirei isso com outra postagem que cobre o fluxo de outra maneira em breve.

Nas duas postagens, mostrarei como criar interfaces baseadas em eventos e streaming para addons usando os módulos streaming-worker e streaming-worker-sdk. Nessas postagens, vou mostrar como usá-las em seus próprios complementos.

Exemplo – dados do sensor.

Acredite ou não, o desempenho não é o motivo mais comum para criarmos addons do C ++ para o Node.js. Embora certamente haja momentos em que o código C ++ é executado com muito mais eficiência do que o JavaScript, geralmente esse ganho de desempenho é devorado pela sobrecarga de empacotamento de dados entre a memória V8 e o C ++. Embora existam soluções alternativas (Buffers), o desempenho não é o principal motivo pelo qual os complementos do C ++ são úteis. Talvez a razão mais comum usada pelos addons seja sua capacidade de aproveitar o código C ++ existente. Isso pode ser especialmente crítico ao interagir com dispositivos – especificamente dispositivos que fornecem apenas APIs do C / C ++.

Meu histórico inclui muito trabalho em realidade virtual e descobri que os sensores de posição / orientação costumam ser fornecidos apenas com APIs C ou C ++. Se você quiser enviar dados de posição / orientação do seu Oculus Rift para um aplicativo Node-webkit / electron – então um addon pode ser sua resposta.

Vou manter as coisas simples nessas postagens – não é necessário conectar seu VR HMD … mas os conceitos serão transferidos para interagir com praticamente qualquer dispositivo de entrada com uma API C / C ++. Em vez de usar um dispositivo real, o código C ++ emitirá dados posicionais ruidosos (aleatórios). Vou esquecer os dados de orientação (é a mesma ideia) e, em vez de criar um aplicativo de RV em torno dos dados do sensor, só vou despejar os dados na tela (a partir do Node.js, é claro). O foco será na interface de streaming entre o addon e o Node.js.

No momento em que terminarmos, teremos um complemento que pode ser ouvido como um emissor de eventos ou como um fluxo de entrada – mais ou menos assim:

 

A hidden world revealed: Titan.

We’ve sent space probes to every planet in our solar system (and if you’re a die-hard Pluto fan, you only have to wait 4 more years). And yet there is still much to see, much to explore. Not every world gives up its secrets easily, and perhaps none has been so difficult to probe than Titan, Saturn’s largest moon. Bigger than Mercury, second only to Jupiter’s Ganymede, Titan has an atmosphere of nitrogen so thick it has twice the Earth’s air pressure at its surface.
That thick, hazy atmosphere is impenetrable by optical light… but infrared light can pierce that veil, and the Cassini space probe is well-equipped with detectors that can see in that part of that spectrum. And after 7 years, and 78 fly-by passes of the huge moon, there are enough images for scientists to make this amazing global map:

Pretty awesome. And making this animation was a huge effort. First, not all of the passes were at the same distance, so scientists had to resize the images to match the scale. Cassini passed at different times of day for the local regions, so the sunlight angle changed, making illumination and shadowing different. The atmosphere of Titan is dynamic, changing with time, so again compensations must be made. It’s painstaking work, but the results are truly incredible:

In this false-color map, what’s shown as blue is actually light at a wavelength of 1.27 microns — very roughly twice the wavelength the human eye can detect. Green is 2 microns, and red is 5 microns, well out into the infrared. When the final images are combined, what show up as brown regions near the equator are actually vast dune fields, grains of frozen hydrocarbons rolling across the plains in the relentless Titanian winds. White areas are elevated terrain. Near the north pole, only barely visible, are smudges on the map that have been shown to be lakes — literally, giant lakes of liquid methane!
So Titan has air, lakes, and weather. Sound familiar? It’s not exactly Earth-like, since the temperature there is roughly -180°C (-300°F), but the similarities are compelling. And Titan is loaded with organic compounds like methane, ethane, and more. A complex chemistry is certainly possible there, but complex enough to have formed life? No one knows. Just a few years ago I don’t think anyone would’ve taken the possibility seriously, but now… well, I wouldn’t rule it out.
Remember, these maps only show global features, and even though Cassini dropped the Huygens probe onto the surface, it saw a tiny fraction of what there is to see on this moon, which boasts over 80 million square kilometers of territory. That’s a lot of land. What else is there to find there?

Olympus Mons: the solar system biggest known mountain.

OLYMPUS MONS

The largest of the volcanoes in the Tharsis Montes region, as well as all known volcanoes in the solar system, is Olympus Mons. Olympus Mons is a shield volcano 624 km (374 mi) in diameter (approximately the same size as the state of Arizona), 25 km (16 mi) high, and is rimmed by a 6 km (4 mi) high scarp. A caldera 80 km (50 mi) wide is located at the summit of Olympus Mons. To compare, the largest volcano on Earth is Mauna Loa. Mauna Loa is a shield volcano 10 km (6.3 mi) high and 120 km (75 mi) across. The volume of Olympus Mons is about 100 times larger than that of Mauna Loa. In fact, the entire chain of Hawaiian islands (from Kauai to Hawaii) would fit inside Olympus Mons!
These images, taken by the High Resolution Stereo Camera (HRSC) on board ESA’s Mars Express spacecraft, show the eastern scarp of the Olympus Mons volcano on Mars.

The HRSC obtained these images during orbit 1089 with a ground resolution of approximately 11 metres per pixel. The image is centred at 17.5° North and 230.5° East. The scarp is up to six kilometres high in places.
The surface of the summit plateau’s eastern flank shows lava flows that have are several kilometres long and a few hundred metres wide.

Age determinations show that they are up to 200 million years old, in some places even older, indicating episodic geological activity.
The lowland plains, seen here in the eastern part of the image (bottom), typically have a smooth surface.
Several channel-like features are visible which form a broad network composed of intersecting and ‘anastomosing’* channels that are several kilometres long and up to 40 metres deep. (*Anastomising means branching extensively and crossing over one another, like veins on the back of your hand.)
Several incisions suggest a tectonic control, others show streamlined islands and terraced walls suggesting outflow activity.
Age determinations show that the network-bearing area was geologically active as recent as 30 million years ago.
Between the edge of the lowland plains and the bottom of the volcano slope, there are ‘wrinkle ridges’ which are interpreted as the result of compressional deformation. In some places, wrinkle ridges border the arch-like terraces at the foot of the volcano slope.
The colour scenes have been derived from the three HRSC-colour channels and the nadir channel.
The perspective views have been calculated from the digital terrain model derived from the stereo channels.
The 3D anaglyph image was calculated from the nadir and one stereo channel. Image resolution has been decreased for use on the internet.
Links to look :
OlympusMons.com – Your Guide to Olympus Mons – the largest volcano in our solar system.

Mars Exploration: Multimedia

List of highest mountains on Mars by height


Name Elevation (m)
Olympus Mons 21,171
Ascraeus Mons 18,209
Arsia Mons 17,779
Pavonis Mons 14,037
Elysium Mons 13,862
Maxwell Mons, Venus
(tallest mountain on Venus) 11,000
Tharsis Tholus 8,000-9,000
Biblis Tholus
(formerly Patera) 7,198
Alba Mons 6,815
Ulysses Tholus 5,863
Uranius Mons 4,853
Anseris Mons 3,959
Hadriacus Mons
(formerly Hadriaca Patera) 3,959
Euripus Mons 3,945
Tyrrhenus Mons
(formerly Tyrrhena Patera) 3,920
Promethei Mons 3,789
Chronius Mons 3,240
Apollinaris Mons
(formerly Patera) 3,155
Gonnus Mons 2,937
Syrtis Major Planum 2,300
Amphitrites Patera 2,066
Nili Patera 2,036
Pityusa Patera 1,877
Malea Patera 1,313
Peneus Patera 1,276
Labeatis Mons 1,143
Issedon Paterae 826
Pindus Mons 704
Meroe Patera 542
Dead Sea, Earth
(depth below sea level) -420
Orcus Patera -764
Oceanidum Mons -1,277
Horarum Mons -2,325
Peraea Mons -2,470
Bentley Subglacial Trench,
Earth (depth below sea level) -2,555
Octantis Mons -2,731
Galaxius Mons -3,972
Challenger Deep, Earth
(depth below sea level) -10,924