<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lutong Zhang on Medium]]></title>
        <description><![CDATA[Stories by Lutong Zhang on Medium]]></description>
        <link>https://medium.com/@zlt1213?source=rss-7cad01e666fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*69esKWyTs6AZFn9u.</url>
            <title>Stories by Lutong Zhang on Medium</title>
            <link>https://medium.com/@zlt1213?source=rss-7cad01e666fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:37:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zlt1213/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[About SLAM, prior, and make the ugly more beautiful.]]></title>
            <link>https://medium.com/@zlt1213/about-slam-prior-and-make-the-ugly-more-beautiful-93a3147a4028?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/93a3147a4028</guid>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Thu, 22 May 2025 13:23:01 GMT</pubDate>
            <atom:updated>2025-05-22T13:23:01.311Z</atom:updated>
            <content:encoded><![CDATA[<p>Below is a “zoom-way-out” tour of the <strong>10 micro-concepts</strong> that hide inside that one-line posterior formula. I’ll start with the absolute basics and build up, so when you read words like <em>prior</em> or <em>likelihood</em> they feel friendly instead of spooky.</p><p><em>(And yes — you almost certainly meant </em><strong><em>prior</em></strong><em>, not “prayer.” In Bayesian lingo a prior is just “what I believed before I saw any data.” No incense required!)</em></p><h3>1. Random variables — our chess pieces</h3><p>Think of <strong>XtX_t</strong> (state) and <strong>ZtZ_t</strong> (measurement) as labeled jars that can hold many possible values. We don’t know what’s inside each jar yet, but we can attach probabilities to the possibilities. Those jars are called <em>random variables</em> in probability theory.</p><h3>2. Prior distribution</h3><p>The <strong>prior</strong> P(X1)P(X_1) answers: <em>“Before I look at any sensor data, how likely is each possible state?”</em> It encodes gut feeling, previous experiments, or a design spec. It’s just a regular probability distribution — nothing mystical. (<a href="https://en.wikipedia.org/wiki/Prior_probability?utm_source=chatgpt.com">Wikipedia</a>)</p><h3>3. Conditional probability</h3><p>When you write P(X2 ⁣∣ ⁣X1)P(X_2\!\mid\!X_1) you’re saying: <em>“If I already know X1X_1, here’s how that tilts the odds for X2X_2.”</em> Conditional probabilities are the glue in almost every statistical model.</p><h3>4. Markov chain (a one-step memory rule)</h3><p>A <strong>Markov chain</strong> is the promise that <em>the future only cares about the present.</em><br> Formally: P(Xt+1 ⁣∣ ⁣Xt,Xt−1,… )=P(Xt+1 ⁣∣ ⁣Xt)P(X_{t+1}\!\mid\!X_t,X_{t-1},\dots)=P(X_{t+1}\!\mid\!X_t). That’s why the transition factors stop at one neighbour. (<a href="https://en.wikipedia.org/wiki/Markov_chain?utm_source=chatgpt.com">Wikipedia</a>)</p><h3>5. Transition model</h3><p>Put the previous two ideas together and P(Xt ⁣∣ ⁣Xt−1)P(X_{t}\!\mid\!X_{t-1}) becomes the <strong>transition model</strong>: a little probabilistic box that predicts tomorrow’s state from today’s.</p><h3>6. Likelihood (measurement model)</h3><p>The <strong>likelihood</strong> L(Xt;zt)=P(Zt=zt∣Xt)L(X_t;z_t)=P(Z_t=z_t\mid X_t) scores: <em>“If the robot were really at state XtX_t, how plausible is the sensor reading ztz_t I just saw?”</em> Same math, but viewed as a function of XtX_t now that ztz_t is fixed. (<a href="https://en.wikipedia.org/wiki/Likelihood_function?utm_source=chatgpt.com">Wikipedia</a>)</p><h3>7. Bayes’ theorem (update rule)</h3><p>Bayes’ rule turns a prior + likelihood into a <strong>posterior</strong>:</p><p>Posterior∝Prior×Likelihood.\text{Posterior} \propto \text{Prior} \times \text{Likelihood}.</p><p>For multiple time-steps, you just multiply <em>all</em> the priors/transitions and <em>all</em> the likelihoods, then normalise once at the end. (<a href="https://en.wikipedia.org/wiki/Bayes%27_theorem?utm_source=chatgpt.com">Wikipedia</a>)</p><h3>8. Posterior distribution</h3><p>After the update you get P(X1,X2,X3∣z1,z2,z3)P(X_1,X_2,X_3 \mid z_1,z_2,z_3) — the <strong>posterior</strong>. It’s everything you currently believe about every state, rolled into one probability surface. Tomorrow it becomes <em>today’s prior</em> and the game repeats. (<a href="https://en.wikipedia.org/wiki/Posterior_probability?utm_source=chatgpt.com">Wikipedia</a>)</p><h3>9. Factorisation (breaking the big formula into Lego bricks)</h3><p>Because of the Markov and measurement assumptions, the huge joint distribution <em>factorises</em> into six tiny pieces:</p><ul><li>three <strong>dynamic factors</strong></li><li>three <strong>measurement factors</strong></li></ul><p>Multiplying those six is vastly cheaper than enumerating every triple (X1,X2,X3)(X_1,X_2,X_3).</p><h3>10. Factor graph (a wiring diagram for the math)</h3><p>A <strong>factor graph</strong> draws each variable as a circle and each factor as a square, with edges only where a term uses that variable. The picture makes the sparsity obvious and lets solvers like GTSAM exploit it for speed. (<a href="https://ocw.mit.edu/courses/6-438-algorithms-for-inference-fall-2014/3e3e9934d12e3537b4e9b46b53cd5bf1_MIT6_438F14_Lec4.pdf?utm_source=chatgpt.com">MIT OpenCourseWare</a>)</p><h3>Quick mnemonic</h3><blockquote><strong><em>Posterior ≈ Prior × Transition × Likelihood (for every time-step)</em></strong><em><br> Normalise once at the end.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93a3147a4028" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Baby version of embedded intelligence for robotics: analysis of the PI-0 model -part-1]]></title>
            <link>https://medium.com/@zlt1213/baby-version-of-embedded-intelligence-for-robotics-analysis-of-the-pi-0-model-part-1-5a091e398d97?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a091e398d97</guid>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Thu, 01 May 2025 01:34:44 GMT</pubDate>
            <atom:updated>2025-05-01T01:34:44.920Z</atom:updated>
            <content:encoded><![CDATA[<p>In this series of posts, I’ll break the model down to several parts, analysis each parts and them put them together, so you will have a deep understanding of the model.</p><p><a href="https://github.com/Physical-Intelligence/openpi.git">The github codebase is here</a>. I have to say that, this is really a brilliant project, and beginning of a new path. OK, let look at the overall picture of the model.</p><p>OpenPI incorporates a Vision Transformer as part of its <strong>Vision-Language Model (VLM) backbone</strong>, which is based on the <strong>PaliGemma</strong> model. PaliGemma combines a pre-trained ViT (the <strong>SigLIP</strong> vision encoder) with a language model (Gemma) (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/paligemma#:~:text=PaliGemma">PaliGemma</a>) (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/paligemma#:~:text=SigLIP%20with%20the%20Gemma%202B,that%20converts%20an%20image%20into">PaliGemma</a>). In OpenPI’s code, this ViT is integrated as follows:</p><ul><li><strong>Pre-trained ViT via SigLIP</strong>: The SigLIP encoder is a contrastively pre-trained ViT that converts input images into sequence embeddings (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/paligemma#:~:text=SigLIP%20with%20the%20Gemma%202B,that%20converts%20an%20image%20into">PaliGemma</a>). In OpenPI, these image embeddings are fed into the Gemma transformer backbone (PaliGemma) along with text tokens. This gives the model visual understanding. The PaliGemma weights (including the ViT’s parameters) are <strong>initialized from a released checkpoint</strong> rather than trained from scratch.</li><li><strong>Implementation and Classes</strong>: Rather than defining a ViT from scratch, OpenPI leverages the existing PaliGemma model. The repository defines a weight loader (PaliGemmaWeightLoader in openpi/training/weight_loaders.py) to load the official PaliGemma checkpoint, which contains the ViT weights (<a href="https://github.com/Physical-Intelligence/openpi/blob/main/src/openpi/training/weight_loaders.py#:~:text=%22gs%3A%2F%2Fvertex">openpi/src/openpi/training/weight_loaders.py at main · Physical-Intelligence/openpi · GitHub</a>). This loader merges the pre-trained parameters into the model’s parameter dictionary, while leaving placeholders for new robotics-specific weights (the action expert) intact (<a href="https://github.com/Physical-Intelligence/openpi/blob/main/src/openpi/training/weight_loaders.py#:~:text=This%20allows%20us%20to%20support,used%20by%20the%20Pi0%20model">openpi/src/openpi/training/weight_loaders.py at main · Physical-Intelligence/openpi · GitHub</a>). The model configuration is set up in openpi/training/config.py via Pi0Config, where paligemma_variant selects the specific PaliGemma model variant (e.g. “gemma_2b_lora”) (<a href="https://github.com/Physical-Intelligence/openpi/blob/main/src/openpi/training/config.py#:~:text=model%3Dpi0.Pi0Config%28paligemma_variant%3D">openpi/src/openpi/training/config.py at main · Physical-Intelligence/openpi · GitHub</a>).</li><li><strong>ViT Integration in the Model Pipeline</strong>: During model construction, the code <strong>initializes a SigLIP vision module and combines it with the language module</strong>. The SigLIP ViT is configured to output feature vectors of the same dimension as the language model’s embeddings (so they can be concatenated). For example, the initialization (via a bridging utility) creates an image model with a specified variant (e.g. a 400M-param SigLIP) and matching width. This image encoder is paired with the Gemma language model and stored as the img component of the PaliGemma module. In effect, the ViT processes input camera images into patch tokens which are then <strong>fed into the transformer</strong> alongside text tokens.</li><li><strong>Role in Inference</strong>: At inference time, the ViT handles the raw visual observations. The input images (from the robot’s cameras) are first passed through the SigLIP ViT to produce image token embeddings. These tokens are then passed into the PaliGemma transformer (the VLM) along with any language context (e.g. task description). This allows the model’s next stages to attend to visual features. The integration is seamless — in code, the embed_prefix method of the Pi0 model will run the image through self.PaliGemma[&quot;img&quot;] (the ViT) and supply the resulting tokens to the transformer model (self.PaliGemma[&quot;llm&quot;]). Thus, the Vision Transformer is a <strong>front-end</strong> to the VLM, providing high-level visual features that the model uses to reason about what it sees.</li></ul><h3>Fusion of Vision-Language Model (VLM) and Action Expert</h3><p>The OpenPI <strong>π0 model</strong> is a <strong>Vision-Language-Action</strong> model consisting of two fused components: a large VLM backbone (PaliGemma, described above) and a smaller <strong>action expert</strong> network specialized for robot controls. Rather than running as two separate networks, these are merged into a single architecture so that they can share information. Key aspects of this fusion include:</p><ul><li><strong>Dual-Config Transformer Architecture</strong>: The Pi0 model uses the Gemma transformer architecture for both the VLM and the action expert. In the code, Pi0Config defines two model variants – e.g. a &quot;gemma_2b&quot; for the main VLM and a &quot;gemma_300m&quot; for the action expert (300M parameters) (<a href="https://github.com/Physical-Intelligence/openpi/blob/main/src/openpi/training/config.py#:~:text=model%3Dpi0.Pi0Config%28paligemma_variant%3D">openpi/src/openpi/training/config.py at main · Physical-Intelligence/openpi · GitHub</a>). When constructing the model, it obtains two configurations and passes <strong>both</strong> into the model initializer. For example, the code bridges into an internal _gemma.Module by providing a list of configs: [paligemma_config, action_expert_config] . This effectively creates a single transformer module with <strong>two sets of weights</strong> – one corresponding to the pre-trained VLM and one for the new action expert. (The action expert’s weights are initialized from scratch or a smaller Gemma checkpoint, then possibly fine-tuned.) In other words, the transformer layers are extended to include extra parameters for the “action expert” alongside the original ones.</li><li><strong>Mixture-of-Experts (MoE) Integration</strong>: Internally, the model routes different token types through different weights. The <strong>robotics-specific tokens</strong> — namely the robot state and future action tokens — are <em>“routed to the action expert”</em>, while the image and language tokens use the original VLM weights. This routing happens at each transformer layer. In practice, the implementation treats the combined transformer as a Mixture-of-Experts: the _gemma.Module sees both configs and is set up so that any token coming from the second config (expert) uses the expert’s feed-forward and maybe its layer-norm weights, whereas other tokens use the first config’s weights. They share the self-attention mechanism, enabling interactions between the two domains, but have distinct feed-forward paths. The OpenPI code uses a custom masking and parameter naming scheme to facilitate this – for example, parameter names containing llm_1 correspond to the second (action expert) weights . During training, only the action expert parameters may be unfrozen (or use LoRA tuning) while the VLM is partially frozen , depending on the configuration.</li><li><strong>Input/Output Fusion</strong>: To integrate the robot’s state and actions into the transformer, the Pi0 model adds extra projection layers. The <strong>current robot state</strong> (e.g. joint positions) is projected by state_proj into the model’s embedding dimension, creating a “state token.” Similarly, each future <strong>action</strong> in the prediction horizon (a vector of commands) is embedded by an action_in_proj layer into the model space. These serve as additional input tokens to the transformer, appended after the image/text tokens. On the output side, the transformer’s representation for those action tokens is fed through an action_out_proj linear layer to produce actual action values (continuous control commands) . Thus, the action expert doesn’t produce logits for classification, but outputs real-valued vectors for motor commands. All these projection layers are defined in the Pi0 model class (as seen in the code snippet initializing self.state_proj, self.action_in_proj, etc.) .</li><li><strong>Attention and Architectural Flow</strong>: The combined sequence of tokens (image patches, language tokens, state token, and a sequence of action tokens) is processed in one forward pass. A custom <strong>attention mask</strong> is used to implement the intended information flow. The design is that <em>earlier tokens (images, text, state)</em> can be freely attended to by later tokens, but the <strong>VLM tokens do not depend on the future action tokens</strong> (to avoid distribution shift from pre-training). Meanwhile, the action tokens are allowed to attend to each other <strong>bidirectionally</strong> (the action expert uses a full attention within the action block). In effect, the image/text context forms a prefix that the action tokens condition on. The repository’s implementation of mask_ar (mask autoregressive) in the attention mask logic constructs a “block causal” mask to enforce this behavior (i.e. no information flows <em>from</em> action tokens back into the VLM tokens, but action tokens see everything). This ensures the VLM part remains as it was pre-trained, while the action expert attends to the rich visual-language features when predicting the next actions.</li><li><strong>Inference Pipeline</strong>: At runtime, the <strong>combined model</strong> is invoked through a unified interface. The input is typically a dictionary containing the robot’s observations (images, state, etc.). The Pi0 model’s infer method (conforming to the BasePolicy interface) will package these into the required token format, run the transformer forward pass, and produce a set of predicted future actions. The output is a dict with an &quot;actions&quot; field, which contains a sequence of predicted actions (for example, a 10-step action plan) (<a href="https://huggingface.co/datasets/introvoyz041/Openpi/commit/2692235c93ae7a68101b320f8d1cdecee3fe78ab#:~:text=%2B%20pred_action_chunk%20%3D%20policy_client.infer%28request_data%29%5B">Migrated from GitHub · introvoyz041/Openpi at 2692235</a>). For instance, one call might output an array of shape (Horizon, ActionDim) representing the next H horizon actions (<a href="https://huggingface.co/datasets/introvoyz041/Openpi/commit/2692235c93ae7a68101b320f8d1cdecee3fe78ab#:~:text=%2B%20assert%20pred_action_chunk,8">Migrated from GitHub · introvoyz041/Openpi at 2692235</a>). OpenPI’s client utilities then handle this output: the ActionChunkBroker (in openpi_client) wraps the policy and delivers the action sequence step-by-step. It calls the policy’s infer once to get the full action chunk, then each time step pops one action to send to the robot, returning the next on subsequent calls (<a href="https://huggingface.co/datasets/introvoyz041/Openpi/commit/2692235c93ae7a68101b320f8d1cdecee3fe78ab#:~:text=27">Migrated from GitHub · introvoyz041/Openpi at 2692235</a>) (<a href="https://huggingface.co/datasets/introvoyz041/Openpi/commit/2692235c93ae7a68101b320f8d1cdecee3fe78ab#:~:text=%2B%20pred_action_chunk%20%3D%20policy_client.infer%28request_data%29%5B">Migrated from GitHub · introvoyz041/Openpi at 2692235</a>). This two-level approach (high-level VLM decision followed by low-level execution) is exactly how the VLM and action expert work together. The <strong>VLM (image &amp; language encoder)</strong> provides an informed context, and the <strong>action expert</strong> module outputs a feasible motor command sequence based on that context. In summary, the code combines the VLM and action expert into one model class, ensuring that image/language features and action outputs are <strong>jointly processed</strong> with appropriate modularity. The result is a single forward pass producing robot actions, with the heavy visual-semantic lifting done by the ViT-backed VLM and the fine control generated by the integrated action expert.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a091e398d97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get started with Mujoco — Part 1]]></title>
            <link>https://medium.com/@zlt1213/get-started-with-mujoco-part-1-e90147165751?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e90147165751</guid>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Sat, 19 Feb 2022 14:50:31 GMT</pubDate>
            <atom:updated>2022-02-19T14:50:31.578Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started with Mujoco — Part 1</h3><h3>Why doing this?</h3><p>Mujoco is a simulator for robotics. Actually, despite the kind of strange pronunciation, Mujoco stand for Multi-Joint dynamics with Contact.</p><p>Personally, I have been working with Gazebo, another commonly used robotics simulator, for years. The thing that stopped me from even trying Mujoco was the initial investment. Yes it was not free.</p><p>The good news is that Deepmind open-sourced Mucojo early this year. All the codes are freely available on <a href="https://github.com/deepmind/mujoco">Github</a> under Apache License. After knowing this good news, I clone the repo at first time. Now let’s fired it up and have some hands on experience.</p><h3>Installation</h3><p>The latest versionof mujoco can be download from the <a href="https://github.com/deepmind/mujoco/releases">github release page</a>. At this moment, the latest release is 2.1.1. For my Linux machine, I downloaded mujoco-2.1.1-linux-x86_64.tar.gz , as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*u4Wyx1DKb4FJUGcbIoXCWQ.png" /><figcaption>Download Mujoco from Github</figcaption></figure><p>I created a dir as ~/mujoco_working, and then unzipped the downloaded file under this dir. Since the project is pre-built, the installation process if pretty straightforward.</p><p>Now it’s time to verify the installation. The simplest way to do that is to run a pre-built model. In the terminal, cd to the mujoco/bin dir, and then type:</p><p>./simulate ../model/flag/flag.xml</p><p>Then the simulator will started as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXsCS23lm2JrCp-ZDQGU4w.png" /><figcaption>verify the installation of mujoco</figcaption></figure><p>For the next step, I will document my explore of the mujoco world such as writing a robot definition file, writing some controllers for an acrobot and so on…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e90147165751" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drone Controller PX4 on Pixhawk with Nuttx: Part 3 Driver of a Sensor]]></title>
            <link>https://medium.com/@zlt1213/drone-controller-px4-on-pixhawk-with-nuttx-part-3-driver-of-a-sensor-c1cfcd1d7a47?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1cfcd1d7a47</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[nuttx]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[px4]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Wed, 07 Aug 2019 10:24:29 GMT</pubDate>
            <atom:updated>2019-08-08T13:52:51.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Drone Controller PX4 on Pixhawk with Nuttx: Part 4 Driver of a Sensor</h3><p>This is the 3rd part of the <strong>PX4 code-study series. </strong>In this part, the main goal is to find a way to add a new sensor to the PX4 system. The other parts of the this series can be found at: (to be decided)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*x4ktuNn-0mxOBjyC.jpeg" /></figure><h3>Sensor Drivers based on Nuttx</h3><p>The drivers for the sensors are all under the Firmware-&gt;src-&gt;drivers directory. For example, the driver of the very popular MPU6000 is underdrivers-&gt;imu-&gt;mpu6000 directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJ2pIYp7a2E5H9S6bck8Hw.png" /><figcaption>CMakeLists.txt under mpu6000</figcaption></figure><p>As listed in the cmake file, the driver of the mpu6000 is compiled as a px4-module, which is a thread running in the system. The main function of this module is mpu6000_main() which is located in the file of <em>mpu6000_main.cpp</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYypGxr9ZhljTgWdsKxcmQ.png" /><figcaption>Entry point of the mpu6000 class</figcaption></figure><p>In the mpu6000_main() function, the start() method of mpu6000 class is called. Here the mpu6000 is a class that provides several useful methods, as all the other sensors. The methods and data of this class are listed in the picture blow. The construction of this class is based on some other classes, such as the PX4Accelerometer and PX4Gyroscope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*CtIwNf2sZmfScK5U2CkR_Q.png" /><figcaption>Internal methods and data types of the mpu6000</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8236utdwhDifYBUWUL78w.png" /><figcaption>Dependencies of this Class</figcaption></figure><p>The mpu6000_main() function firstly processes the input argument. If the argument equals to start, the start() function will be called.</p><pre>start() -&gt;<br>start_bus()-&gt;</pre><p>In start_bus(), a new class is allocated, and then the start() method of that class is called, which schedules the running interval of this thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*wfj7FSH2AqVsvQaniOVJCg.png" /></figure><p>The calling stack is listed as below:</p><pre>start()-&gt;<br>start_bus()-&gt;<br>new MPU6000()-&gt;<br>MPU6000::init()<br>MPU6000::start()</pre><p>The MPU6000::init() probes the device, and the MPU6000::start() schedules the thread. In the MPU6000::init() function, the character device driver (CDev) is also initiated.</p><p>In MPU6000::probe() , a register read function is called to identify the type and id of the MPU6000 device. This register-read function is provided by the _interface class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*vSHxKBOFuAK4iYb462whqA.png" /><figcaption>device probe</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*cPjuklsVYRIHt14OwTdNkQ.png" /><figcaption>Read Register</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_71Yi0YW97WjS3ZnjK0bJg.png" /><figcaption>Character Device Created</figcaption></figure><p>Another interesting point is that, during the creation of the MPU6000 class, a character device (CDev) with a path is created. This character device is managed by the nuttx system, and can be used later to poll data from.</p><p>Till now, the mpu6000 device is initiated, started and a character device is linked to this class.</p><p>For any question:</p><p>zlt1213@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1cfcd1d7a47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drone Controller FX4 on Pixhawk with Nuttx: Part 1 Environment Setup]]></title>
            <link>https://medium.com/@zlt1213/drone-controller-fx4-on-pixhawk-with-nuttx-part-1-environment-setup-a4c33e62e9e4?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4c33e62e9e4</guid>
            <category><![CDATA[px4]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[nuttx]]></category>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[pixhawk]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Wed, 10 Oct 2018 02:05:26 GMT</pubDate>
            <atom:updated>2018-10-10T03:03:42.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYOWgnGPtzFswy1lduBksQ.jpeg" /></figure><p>========================================</p><p>Summary:</p><ol><li>Brief intro of PX4 autopilot flight control system</li><li>Install Tool Chain</li><li>Clone the Source Code from Github</li><li>Build the code</li><li>Build the code for simulation(Additional)</li></ol><p>========================================</p><h3>1. Brief Intro</h3><p><a href="https://docs.px4.io/en/">PX4 is the <em>Professional Autopilot</em></a>. Developed by world-class developers from industry and academia, and supported by an active world wide community, it powers all kinds of vehicles from racing and cargo drones through to ground vehicles and submersibles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*0RrMlvfn8hh72rPiT5CX7Q.png" /><figcaption>Fig. 1 Pixhawk</figcaption></figure><p>PX4 can run on different platforms, among which the Pixhawk maybe the most famous one. The core of the Pixhawk is an ARM cortex M4 processor, which handles the pose estimation and flight control of a drone. On the ARM Cortex M4, there’s a Real Time Operating System named Nuttx is running. The PX4 system is built on the application layer of Nuttx.</p><p>The main topic of this serious of posts is to explore the functionality and implementation of PX4 on Nuttx. Let’s get started</p><h3>2. Install Tool Chain</h3><p>Although the development tool chain can be install on both the Windows machines and the Mac machines, the Linux machine is the most easy to use platform of development. If you are using Win or Mac, it’s easy to install a virtual machine to run Linux.</p><p>In order to install the development tool chain on Linux, please follow the steps below.</p><ol><li>Download the shell script <em>ubuntu_sim_nuttx.sh</em> from</li></ol><pre><a href="https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_nuttx.sh">https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_nuttx.sh</a></pre><p>2. Run the shell script to install the tool chain</p><pre>source ubuntu_sim_nuttx.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*ADGW9IbGeJaiU3sfeTmKGA.png" /><figcaption>Fig. 2 Install Tool Chain by Shell Script</figcaption></figure><p>Notice that you may want to install pip firstly by</p><pre>sudo apt-get install python-pip</pre><p>3. Reboot the Linux system</p><h3><strong>3. Clone the PX4 Source Code from GitHub</strong></h3><p>The source code of PX4 system can be clone from GitHub by the following steps.</p><ol><li>Clone the main firmware</li></ol><pre>mkdir -p ~/px4<br>cd ~/px4<br>git clone https://github.com/PX4/Firmware.git</pre><p>2. Clone the source file for sub folers</p><pre>cd Firmware<br>git submodule update --init --recursive</pre><h3><strong>4. Build The Code</strong></h3><p>Go to the /Firmware directory firstly and</p><pre>make px4fmu-v2_default</pre><p>This command builds the code and after its finishing the firmware will be ready to upload to the board.(which will be explained in detail in later posts)</p><h3>5. Build The Code for Simulation (Additional)</h3><p>Instead of running the PX4 system on the Pixhawk hardware and flying the drone in the real world, it is possible to run a simulator on the Linux machine. The following steps explain how to install the simulators and how to build for simulation on Linux.</p><ol><li>Download the shell script <em>ubuntu_sim.sh</em> from</li></ol><pre><a href="https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim.sh">https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim.sh</a></pre><p>2. Run the shell script to install the simulator</p><pre>source ubuntu_sim_nuttx.sh</pre><p>3. Build for Simulation</p><p>Under the directory of /Firmware, run</p><pre>make posix jmavsim</pre><p>After the build finishes, the PX4 console will show up as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*Qmwt3EdXtdYdwO7T6IVFvQ.png" /><figcaption>Fig. 3 Console of PX4 for simulation</figcaption></figure><p>and the simulator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*JOmpdc4Us4OiR81i0l9gJg.png" /><figcaption>Fig. 4 PX4 Simulator</figcaption></figure><p>You can command the drone in the simulator to take of by</p><pre>pxh&gt; commander takeoff</pre><p>Any question, email me at</p><p><strong><em>zlt1213@gmail.com</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4c33e62e9e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nuttx Real Time Operating System (RTOS) on STM32F4 — Part1: Environment Setup]]></title>
            <link>https://medium.com/@zlt1213/nuttx-real-time-operating-system-rtos-on-stm32f4-part1-environment-setup-df36af8bbd03?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/df36af8bbd03</guid>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[tor]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[stm32f4]]></category>
            <category><![CDATA[nuttx]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Sat, 29 Sep 2018 07:14:50 GMT</pubDate>
            <atom:updated>2018-09-29T07:26:42.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FT-EIWR5j6JVqld5bWxQyA.jpeg" /></figure><h3><strong>1. Some Brief Intro</strong></h3><p>When talking about Real-Time operating systems, there’s a vary big chance that the very first one that pops up in mind is the famous FreeRTOS. That one is a small operating system used in lots of different cases. Another famous RTOS is the high end VxWorks from WindRiver. It is claimed that this operating system is running on the <a href="https://www.windriver.com/customers/customer-success/aerospace-defense/nasa-jpl/"><em>Mar Rover</em></a><em>. As it name suggested, the FreeRTOS is basically free, and on the other hand the VxWorks is so expensive that it feels pain to mention its price(at least for my case).</em></p><p>I guess one of the reason the popularity of Nuttx keeps increasing is because of the Hobby Drone community. Actually, the famous Pixhawk flight controller is developed on the Nuttx RTOS. Nuttx is well developed, easy to use and free. So, why not using it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ZnFtoNUXkAkS2SZ8.jpg" /><figcaption>Fig. 1. Pixhawk Flight Controller</figcaption></figure><p>When looking at different Real Time Operating System, the very basic idea behind them is fundamentally similar. RTOSs are used to handle multiple tasks running “at the same time” on the system. Notice that “at the same time” is a kind of approximation of what is going on under the hood.</p><p>As the title figure, this serious well introduce how to get started with Nuttx on the STM32F4 platforms. Personally I am using a very small (in physical size ) STM32F407 dev-board which I can easily carry to anywhere with me. It’s a nice piece of toy which I enjoyed very much. So much for simple intro. Let’s look at how to start with Nuttx on STM32F4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*awyDde1a5T6ulWkxAGl-OA.png" /><figcaption>Fig. 2 Ubuntu Linux VM Running on Windows</figcaption></figure><h3><strong>2. Prepare the Linux VM</strong></h3><p>If you are using a Linux system, you may want to jump this part. For the other running Windows, you need to setup a Linux Virtual Machine on your Computer. This process is quite easy. Firstly, you may want to download the VMware Playstation(Please Google it)and install this piece of nice software locally on your computer. The lasted image file of Ubuntu Linux System can be downloaded from there website with several clicks(also please use Google to find the website). Once you have the image file, it’s quite easy to install the Ubuntu Linux under the VMware. After finishing this, you should have a Linux running one your Windows, literally.</p><h3>3. Get the Nuttx</h3><p>The very first thing you need to do is to download and install all the dependencies. As its name suggests, these programs are needed for latter use. Run this commend in the terminal and it will get everything done for you.</p><p><strong>sudo apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev</strong></p><ol><li>After that, making a folder that named as ‘nuttxspace’ where you can store the Nuttx by</li></ol><p><strong>mkdir ~/nuttxspace</strong></p><p>then go into that directory</p><p><strong>cd ~/nuttxspace</strong></p><p>2. Then clone the OpenOCD repo by</p><p><strong>git clone </strong><a href="https://www.youtube.com/redirect?q=http%3A%2F%2Frepo.or.cz%2Fr%2Fopenocd.git&amp;v=heSkSd-_70g&amp;event=video_description&amp;redir_token=bbB1a9f7XuvRgYguDKlqdLSZR898MTUzODI4NTQzNEAxNTM4MTk5MDM0"><strong>http://repo.or.cz/r/openocd.git</strong></a></p><p>and go into the openocd directory and create the config file as</p><p><strong>cd ~/nuttxspace/openocd</strong></p><p>Config OpenOCD for STLink:</p><pre><strong>sudo ./bootstrap</strong></pre><pre><strong>./configure — enable-internal-jimtcl — enable-maintainer-mode — disable-werror — disable-shared — enable-stlink — enable-jlink — enable-rlink — enable-vslink — enable-ti-icdi — enable-remote-bitbang</strong></pre><p>3. Finally, you need to install it by</p><pre><strong>make</strong></pre><pre><strong>sudo make install</strong></pre><p>After successfully implementing the last step, you should have your computer ready for Nuttx development. The next post will discuss how to compile Nuttx and flash it to the board.</p><p>From: Luz211</p><p>For any Question: zlt1213@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df36af8bbd03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Jump Start of Reinforcement Learning by DQN: 1. A Brief Introduction]]></title>
            <link>https://medium.com/@zlt1213/a-jump-start-of-reinforcement-learning-by-dqn-1-a-brief-introduction-14167c747689?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/14167c747689</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-q-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[dqn]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Sat, 16 Jun 2018 14:59:46 GMT</pubDate>
            <atom:updated>2018-06-17T01:02:11.584Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction</h3><p>Suppose there’s an agent (or a being, whatever the name is). It can act based on its surrounding environment, as well as its own condition. One of the very basic idea of automation is to config the agent in such a way that its action well be beneficial. Take the Fig.1 as an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27M_agM1yVbSxhW_KN7bQw.png" /><figcaption>Fig. 1 Gold-Miner Agent</figcaption></figure><p>In Fig. 1, the agent is a gold miner who’s looking for gold in a mine. The white circles represents locations in the mine. The agent can jump from one location to another. At some of the locations, the agent will find gold as rewords. Meanwhile, at other locations the agent will find nothing but barely stones. For these cases, the reward to the miner is zero on negative.</p><p>Here in this example, a location can be regarded as a state of the agent. The agent can chose to which location should he go for the next step. This can be regarded as action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TVO8BwT4wDpST5dLJTY3Mw.png" /><figcaption>Fig. 2 State and Actions</figcaption></figure><p>Take Fig. 2 as an example. At a certain time t, the miner is at location B. We can say that the state of the agent is B. There are four actions that the agent could take. Action 1 is to go from B to A. Action 2 is to go from B to C. Action 3 is to go from B to F. Action 4 is to go from B to D. There exist rewards for Action 2 and Action 3, but nothing for Action 3 and Action 1.</p><h3>2. Maximize the Sum of Rewards</h3><p>Generally speaking, if the agent is at state <strong><em>s</em></strong>, it should take an action <strong><em>a. </em></strong>This action will bring the agent to a new state <strong><em>s’</em></strong>, and this action would also return a reword <strong><em>r </em></strong>(could be positive, negative or zero). The mechanism that the actions are chosen at different states is called a <strong><em>policy</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*q-UWTiBeDqBI-k0Wb6lrGw.png" /></figure><p>If we go several steps further, we can define a Q function as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*KvPotiwPZr4c6h-MlDIxPg.png" /></figure><p>This function takes the current state and action as input. After taking action a, assume that the agent follows a certain policy, so there will be a trail of pairs of states and actions. Each of these state-action pairs is associated with a reward. The Q function returns the total reward of the trail of state-action pairs. For different policies, the states-action pairs should be different. Among these trails, there surely exist at least one trail that maximum the Q function. These policies are called the optimal policies for the problem. Usually Q* have been used as the symbol to represents the Q function of the optimal policies.</p><p>The Q* can be written as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*mJpzieA5D0rkdS2oXUjR0A.png" /></figure><p>The rewards after state <strong><em>s</em> </strong>is in the ‘future’. Thus it is true that the we should consider a little of the future that is too far away from current. The γ term here is named as discount factor which discount the influences of the further future rewards. Generally, γ is between 0 and 1. This optimal Q* function can also be written as a recursive format, which is also named as Bellman Equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*mztS2xkWaIqtz5V41de_7Q.png" /></figure><p>The problem here is that in most cases the agent doesn’t have a ‘reward map’ at hand. It needs to understand the rewards by taking interactions with its environment. The good news is that the function is provided to converge to Q* with the algorithms such as Q-Learning .</p><h3>3. When Deep Learning Kicks in: DQN</h3><p>The mining example shown above is a simple one. Some of the problems may have infinitely many states. It’s hard to describe these problems by discrete states and simple look-up tables for optimal policy.</p><p>Alternatively, another exciting idea to train a deep-neural net for decision making. Deep-neural net is good at system identification and dynamic control. It can be trained by the methods of deep-learning. Taking the states, such as images, as input, a well trained neural net can provide the best action which maximize the total rewards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*w293uvXKWio2a8Se" /><figcaption>Fig. 3 Deep Neural Net</figcaption></figure><p>The DQN is firstly introduced by <a href="https://arxiv.org/pdf/1312.5602.pdf">Playing Atari with Deep Reinforcement Learning</a> on NIPS in 2013. Since then the DQN has been widely employed to finished different kinds of tasks. The efficiency of DQN is at a very high level compared with traditional optimization methods, such that it is sometimes been discussed as ‘human level decision making’.</p><p>The detailed implementation of DQN will be introduced in the next post of this series: A Jump Start of Reinforcement Learning by DQN.</p><p>Any question, email me at zlt1213@gmail.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14167c747689" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop STM32F4 Discovery(Cortex m4) with Eclipse on Mac OS _ PART 2]]></title>
            <link>https://medium.com/@zlt1213/develop-stm32f4-discovery-cortex-m4-with-eclipse-on-mac-os-part-2-d803f69592f4?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d803f69592f4</guid>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[stm32f4]]></category>
            <category><![CDATA[cortex-m4]]></category>
            <category><![CDATA[stm32f4-discovery]]></category>
            <category><![CDATA[eclipse]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Tue, 06 Mar 2018 08:39:26 GMT</pubDate>
            <atom:updated>2018-03-06T08:39:45.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*YPSs3hoU_5kyMhDdcZtwNw.jpeg" /></figure><p>This is the 2nd part of the Develop STM32F4 Discovery with Eclipse on Mac OS. The part #1 can be found at <a href="https://medium.com/@zlt1213/develop-stm32f4-discovery-board-on-mac-os-part-1-dca644816e5">https://medium.com/@zlt1213/develop-stm32f4-discovery-board-on-mac-os-part-1-dca644816e5</a>.</p><p><strong>Download and Install OpenOCD</strong></p><p>GNU MCU Eclipse is a distribution of OpenOCD. It’s a easy-to-use debug environment that works on both MacOS and Windows. The CNU MCU Eclipse can be downloaded from <a href="https://github.com/gnu-mcu-eclipse/openocd">https://github.com/gnu-mcu-eclipse/openocd</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*BNvNS6Obh3Gt0rpRqi4_SQ.png" /><figcaption>Fig. 1 GUN MCU OpenOCD on Github</figcaption></figure><p>On the github page, click on the ‘releases’ as shown in Fig. 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gY2JCK1lpIef6gDiyDs7eg.png" /><figcaption>Fig. 2 Release of OpenOCD</figcaption></figure><p>In the release page, click on the *****-win64.zip(or win32, depend on your operating system) link to download. After downloading, unzip the file and save it to some location you can find easily. In my case, I saved the file in D:\OpenOCD. After this, open the Eclipse and create a new c project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*zDBpkvwmOUX-cAqCCHIy8g.png" /><figcaption>Fig. 3 Create a new project in Eclipse</figcaption></figure><p>The function of OpenOCD is to download the source code to your Discovery board and debug, so before setting up the OpenOCD it is better to have a project successfully built in order to test the setup of OpenOCD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Moff6ZBXBcO3L6btqWxLw.png" /><figcaption>Fig. 4 Config OpenOCD as external tool</figcaption></figure><p>The next step is to config the OpenOCD as as external tool. Click on <strong>RUN -&gt; External Tools -&gt; External Tools Configurations… </strong>as shown in Fig. 4 above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3w8NA8VhiGUiRdA1PseE0w.png" /><figcaption>Fig. 5 Config OpenOCD as new external tool</figcaption></figure><p>In the left up corner of the External Tools Configurations window, click the New Launch Configuration button. Name the new configuration as OpenOCD. In the <em>Location field</em>, please enter the location of your openocd.exe that you have already downloaded as mentioned above. In my case, it is <strong>D:\OpenOCD\0.10.0–7–20180123–1217\bin\openocd.exe</strong>. In the Working Directory file, please enter the location of the scripts folder. In my case, it is <strong>D:\OpenOCD\0.10.0–7–20180123–1217\scripts</strong>. In the <em>Arguments</em> field, just enter <strong>-f board/stm32f4discovery.cfg</strong> for the reasone that we as going to use the Stm32f4 Discovry board(be careful, it “/” here, not the “\”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*j5Xng8V-doaQzyjQg8KZng.png" /><figcaption>Fig. 6 Check the External Tools box</figcaption></figure><p>Then open the <em>Commom </em>tab and check the <em>External Tools</em> check box<em>. </em>Please keep all the other settings and configs as default. After this, you can just click on the <em>Apply </em>button and close the configuration window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3QV61202sQ394qgfGxs_A.png" /><figcaption>Fig. 7 Start to debug with OpenOCD</figcaption></figure><p>At this time, you can connect your Stm32f4 Discovery Board to your computer. In Eclipse, at the top of the windows, extend the run external tool button to start OpenOCD. If your OpenOCD connected successfully, the big led on your discovery board will flash red and green and in the Console window you can see the information as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*u8S9EguxSm6qQinqL1kwpA.png" /><figcaption>Fig. 8 OpenOCD connected successfully</figcaption></figure><p>At this time, your Stm32f4 Discovery Board is connected by OpenOCD. If you have any question, you can ask me by leaving a comment.</p><p>The other posts of this series can be found at:</p><h3><a href="https://medium.com/@zlt1213/develop-stm32f4-discovery-board-on-mac-os-part-1-dca644816e5">Develop STM32F4 Discovery(Cortex m4) with Eclipse on Mac OS _ PART 1</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d803f69592f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop STM32F4 Discovery(Cortex m4) with Eclipse on Mac OS _ PART 1]]></title>
            <link>https://medium.com/@zlt1213/develop-stm32f4-discovery-board-on-mac-os-part-1-dca644816e5?source=rss-7cad01e666fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/dca644816e5</guid>
            <category><![CDATA[arm]]></category>
            <category><![CDATA[stm32f4]]></category>
            <category><![CDATA[discovery]]></category>
            <category><![CDATA[eclipse]]></category>
            <category><![CDATA[cortex-m4]]></category>
            <dc:creator><![CDATA[Lutong Zhang]]></dc:creator>
            <pubDate>Wed, 18 Oct 2017 08:36:15 GMT</pubDate>
            <atom:updated>2018-08-14T02:51:42.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFMz1-_pA-aNeBQd9woUyA.jpeg" /><figcaption>Fig. 1 Stm32f4 Discovery Board</figcaption></figure><p>The STM32F4 Discovery Board is a very popular choice for beginners to learn how to use the ARM Cortex M4 MCUs. This post mainly introduce the process of setting up the development environment and the toolchain for STM32F4 Discovery Board on Macbook. The Mac OS on my Macbook Air is Sierra 10.12.6. Ok, let’s rock and roll.</p><p>Before we begin, let’s create an empty directory named as ‘WorkSpace’. In ‘WorkSpace’, let’s create two directory named as ‘EclipseWorkSpace’ and ‘tools’.The structure of ‘WorkSpace’ should looks like this.</p><pre>-- WorkSpace<br>   |<br>   | -- EclipseWorkSpace<br>   | -- tools</pre><p><strong>1.Download Eclipse</strong></p><p>Eclipse is an open source IDE which is powerful as well as friendly. It can be downloaded from this link below.</p><p><a href="https://www.eclipse.org/downloads/eclipse-packages/">https://www.eclipse.org/downloads/eclipse-packages/</a></p><p>The most updated version of Eclipse at this moment is Oxygen, so on the main page, click and download the Eclipse Oxygen package (Eclipse IDE for C/C++ Developers) and install it on your mac.</p><p><strong>2. Download Cross-Toolchain for ARM Cortex Processor</strong></p><p>The next step is to download the GNU ARM Embedded Toolchain to your mac from this link <a href="https://launchpad.net/gcc-arm-embedded">https://launchpad.net/gcc-arm-embedded</a>.(Attention: 201808update: net link at <a href="https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads">https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads</a>). Please save the file to the newly created folder ‘tools’ and un-zip the downloaded file. In the sub directory named ‘bin’, there store all the cross toolchain programs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*pf-DGQQZRzlmSHBq5y6pMg.png" /><figcaption>Fig. 2 Download Toolchain</figcaption></figure><p><strong>3. Install GNU ARM Eclipse Plugins</strong></p><p>In order to make the Eclipse micro-controller-develop-friendly, the GNU ARM Eclipse Plugins need to be installed in Eclipse. These plugins are stored on github page <a href="https://github.com/gnu-mcu-eclipse/">https://github.com/gnu-mcu-eclipse/</a> . Click on “<a href="https://github.com/gnu-mcu-eclipse/eclipse-plugins">eclipse-plugins</a>” shown in the Fig. 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*igQTT_NzVGF6vljvkfDIqw.png" /><figcaption>Fig. 3 Eclipse Plugins</figcaption></figure><p>and then click on the releases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*WKwMYCjbWwz9u7qPxJVe-Q.png" /><figcaption>Fig. 4 Releases for Eclipse Plugins</figcaption></figure><p>Click on the “<a href="https://github.com/gnu-mcu-eclipse/eclipse-plugins/releases/tag/v4.1.1-201707111115">GNU MCU Eclipse plug-ins</a>” (the current version at this moment is <a href="https://github.com/gnu-mcu-eclipse/eclipse-plugins/releases/tag/v4.1.1-201707111115">v4.1.1–201707111115</a>) and click again on <a href="https://gnu-mcu-eclipse.github.io/blog/2017/07/11/plugins-v4.1.1-201707111115-released/">Continue reading »</a> will bring you to a blog. On the page of this informative blog, there’s one import link as shown in the figure below(http://gnu-mcu-eclipse.netlify.com/v4-neon-updates/). This is the link where we can extract our plugins in Eclipse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*73f-DA7ylyhJolQOPm2bgQ.png" /><figcaption>Fig. 5 The blog of GNU MCU Eclipse plugins</figcaption></figure><p>Now open the Eclipse. On the startup, Eclipse will ask you to specify a workspace directory. Please put in the path of ‘EclipseWorkSpace’ created in the previous steps. After the Eclipse window shows, go to ‘help =&gt; Install New Software…’ as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*RmY2xZAERZ17sm2w01fCJA.png" /><figcaption>Fig. 6 Install New Software in Eclipse</figcaption></figure><p>In the new window, click “Add…”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*_iu8iJdy7GUZGdWx0H07Rw.png" /><figcaption>Fig. 7Install New Software in Eclipse</figcaption></figure><p>Write “GNU MCU Eclipse Plugins” in the “Name:” field and add “http://gnu-mcu-eclipse.netlify.com/v4-neon-updates/” this link to the “Location:” field. Then click “OK”. After this, click on “select all” and “next” all the way to the “finish”.</p><p>After the installation finished, the Eclipse is ready to develop software for STM32F4 Discovery Board.</p><p>The other posts of this series can be found at:</p><h3><a href="https://medium.com/@zlt1213/develop-stm32f4-discovery-cortex-m4-with-eclipse-on-mac-os-part-2-d803f69592f4">Develop STM32F4 Discovery(Cortex m4) with Eclipse on Mac OS _ PART #2</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dca644816e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>