Friday, August 31, 2018

Setting Title for Tab in Terminator

  • Add code to ~/.bashrc
  • Run source ~/.bashrc
  • Usage: set_title <Title>

  • source

    set_title() {


    Tuesday, August 28, 2018


    Start to follow and implement LIVE CLASS from "The Construct"
    are a greate and funny guide

    #13:ROS Navigation Stack How To

    In this ROS LIVE-Class Ricardo show how to
    making a differential drive robot create a map (SLAM), localize on that map (robot localization), and then navigate on the environment using the map (path planning and obstacle avoidance).

    #14: How To Control Robot Joints With ROS

    In this ROS LIVE-Class Ricardo show how to add ROS control to a joint in a simulated robot

    #19: Let’s Use Gazebo Plugins

    In this ROS LIVE-Class Ricardo show how to create a Gazebo plugin for a robot simulated world. The plugin will allow us to connect/disconnect the light of the world by means of a ROS topic .

    Friday, August 24, 2018

    NodeMCU AT commands


    ESP 8266 has few firmware options

    • AT+command (default)
    • NodeMCU
    • Custom Firmware (using the Arduino IDE)

    In this tutorial we will flash AT FW with esptool and use Arduino Serial monitor to send AT commands

    Connect NodeMCU and use Arduino serial monitor to send AT commands

    • Flash AT firmware
    • Connect with arduino
    • from arduino serial monitor send commands

    Connect device to usb port

    Note: in linux no additional driver need to be install, CP2102 is recognized without the need for installing drivers

    • dmesg output
    usbserial: USB Serial support registered for cp210x cp210x 3-1:1.0: cp210x converter detected usb 3-1: cp210x converter now attached to ttyUSB0

    Flush default firmware (AT support)

    • download default FW FW location
    • download flashing tool (esptool)

    run esptool to flash FW

    python --port /dev/ttyUSB0 write_flash 0x00000 ~/Downloads/v1111ATFirmware.bin

    Usag and run.

    • Use Arduino IDE

    • Config arduino serial monitor

      • set baud rate: 115200
      • set Both NL & CR
    • Run AT commands(AT+)

    AT OK AT+GMR AT version: 5 2015 16:27:16) SDK version:1.1.1 Ai-Thinker Technology Co. Ltd. Jun 23 2015 23:23:50 OK


    Wednesday, August 22, 2018

    Pymavlink Ardupilot SITL

    • ardupilot SITL

    • pamavlink

    • Terminal 1 --console
    • Terminal 2 (python code)
    from pymavlink import mavutil master = mavutil.mavlink_connection('tcp:') # Get some information ! while True: try: print(master.recv_match().to_dict()) except: pass

    • Terminal 3 (netstat -natp)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0* LISTEN 5976/arducopter tcp 0 0* LISTEN 5976/arducopter tcp 0 0* LISTEN 5976/arducopter

    python output

    {'mavpackettype': 'TIMESYNC', 'ts1': 1854891080001, 'tc1': 0} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3} {'custom_mode': 0, 'system_status': 3, 'base_mode': 81, 'autopilot': 3, 'mavpackettype': 'HEARTBEAT', 'type': 2, 'mavlink_version': 3}

    Friday, August 17, 2018

    PyMavlink and PX4 SITL

    python implementation of the MAVLink protocol

    • Terminal 1: from PX4 Firmware run
    make posix_sitl_default jmavsim

    Tip: Run SITL without GUI , good performance save resource


    • Edit this file, which is part of jMAVSim repository, Visualizer3D.java13, and change setVisible(true) to setVisible(false).
    # find . -name vim `find . -name` # search setVisible(true) //line 175 # change setVisible(true) to setVisible(false) # compile and run again make posix_sitl_default jmavsim

    Now the SITL run without JMavsim GUI

    | ___ \ \ \ / /   /   |
    | |_/ /  \ V /   / /| |
    |  __/   /   \  / /_| |
    | |     / /^\ \ \___  |
    \_|     \/   \/     |_/
    px4 starting.
    INFO  [Unknown] Calling startup script: bash etc/init.d-posix/rcS 0
    INFO  [simulator] Waiting for initial data on UDP port 14560. Please start the flight simulator to proceed..
    Init MAVLink
    4000000 B/s on udp port 14556 remote port 14550
    INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14557 remote port 14540

    • use ipython/ python console
    from pymavlink import mavutil master = mavutil.mavlink_connection("udp:") #master # <pymavlink.mavutil.mavudp at 0x7..> master.recv_match() _.to_dict() {'alt': 487971, 'hdg': 40, 'lat': 473977416, 'lon': 85455938, 'mavpackettype': 'GLOBAL_POSITION_INT', 'relative_alt': -12, 'time_boot_ms': 357265, 'vx': -3, 'vy': 0, 'vz': 0}

    Thursday, August 9, 2018

    PX4 SITL Dronekit

    • dependencies
    • run jmavsim as simulator
    • run dronekit sample code

    Install dependencies

    sudo apt-get install python-jinja2 sudo pip install numpy toml

    Download PX4 and build

  • ROS and gazebo are preinstalled
  • mkdir px4 cd px4 git clone cd Framework wget source #First Build (Using the jMAVSim Simulator) make posix jmavsim


    • droneKit
    • dronekit-sitl
    sudo pip install dronekit


    • Dronekit read data from PX4 SITL
    • Run PX4 SITL (simulation)

    dronekit sample code

    from dronekit import connect, VehicleMode connection_string = "" # Connect to the Vehicle. print("Connecting to vehicle on: %s" % (connection_string,)) vehicle = connect(connection_string, wait_ready=True) # Get some vehicle attributes (state) print " System status: %s" % vehicle.system_status.state

    Run gazebo simulation (without gzclient)

    HEADLESS=1 make posix_sitl_default gazebo

    Wednesday, August 8, 2018

    Programing NodeMcu with Arduino IDE

    1. setup additional board url
    2. install board manage
    3. set board and port
    4. select blink example
    5. upload and run

    Setup additional board url

    file -> preference paste the link into field "Additional Bard Manager URL"

    Install board

    Tools -> Board -> Board manager
    filter: esp8266

    Set board and port

    board: NodeMcu 1.0
    port: /dev/USB0

    Select blink example

    File -> Example -> esp8266 -> blink

    Upload and run

    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);

    void loop() {
      digitalWrite(LED_BUILTIN, LOW);
      digitalWrite(LED_BUILTIN, HIGH);

    GO lang on Ubuntu 16.04

    Downloading and installing Go 1.9.1, Setup environment, building a simple Hello World application

    Download and setup

    curl -O
    tar -xvf go1.9.1.linux-amd64.tar.gz
    sudo mv go /usr/local 

    Setting path

    vim ~./profile
    #add as last line
    export PATH=$PATH:/usr/local/go/bin


    source ~/.profile


    mkdir $HOME/gowork
    mkdir -p $HOME/gowork/src/hello

    Set gopath

    export GOPATH=$HOME/gowork

    Write hello.go

    Note: save under $HOME/gowork/src/hello

    package main
    import "fmt"
    func main() {
         fmt.Printf("hello, world\n")

    Compile and run 

    use run, compile or install
    from source folder run
    go run hello.go
    go build hello.go

    cd $GOPATH
    go install hello

    Install and config Go extension on VSCode

    This extension uses a set of Go tools to provide the various rich features. These tools are installed in your GOPATH by default


    "go.gopath": "/home/user/gowork"




    Install Go 1.9.1 on Ubuntu 16.04

    Tuesday, August 7, 2018

    Hello Arduino and FIRMATA

    Firmata is a protocol for communicating with microcontrollers from software on a computer
    Like Arduino for example :
    In essence it turns your Arduino device into a slave with a simple provided sketch. Then using the python/or any other language you can interface the Arduino via Serial bus and exposed API provided by the Firmata system

    1. Install arduino IDE
    2. Add dialup group to user `sudo adduser $USER dialout
    3. Upload Firmata to arduino
      1. File -> Examples -> Firmata -> StandardFirmata
    4. Install python library
      1.  sudo pip install pyfirmata
    5. Write some code

    code example to turn on output 13 (build-in led)

    from pyfirmata import Arduino, util
    board = Arduino('/dev/ttyACM0')[13].write(1)


    Sunday, August 5, 2018

    VSCode tips for ROS

    Tip1 - Adding a file extension to a language

    You can add new file extensions to an existing language with the files.associations setting, for example assign gazebo .world file to XML

     ".world": "xml"

    Tip2 - use code runner to check urdf files

    code runner:  Run code snippet or code file for multiple languages
    • install 'Code runner' extension into vscode 
    • install check_urdf (apt-get install liburdfdom-tools)
    • from settings append file extension into code runner mapping
    "code-runner.executorMapByFileExtension": { 
    ".urdf": "check_urdf"

    Tip3 - use code runner to check xacro files

    ROS node xacro in package xacro convert xacro  file to urdf

    rosrun xacro xacro <file_name.xacro>

    The idea is to run the above command redirect the output to tmp file and then run check_urdf on it.

    ".xacro": "rosrun xacro xacro --inorder $fullFileName > /tmp/tmp.urdf && check_urdf /tmp/tmp.urdf"

    code runner supported parameters
    • $workspaceRoot: The path of the folder opened in VS Code
    • $dir: The directory of the code file being run
    • $dirWithoutTrailingSlash: The directory of the code file being run without a trailing slash
    • $fullFileName: The full name of the code file being run
    • $fileName: The base name of the code file being run, that is the file without the directory
    • $fileNameWithoutExt: The base name of the code file being run without its extension