Monday, March 16, 2020

URDF Link origin test





<?xml version="1.0"?>
<robot name="myfirst">
    <link name="base_link">
        <visual>
            <geometry>
                <cylinder length="0.6" radius="0.2"/>
            </geometry>
        </visual>
    </link>
</robot>

<?xml version="1.0"?>
<robot name="myfirst">
  <link name="base_link">
    <visual>
      <geometry>
        <cylinder length="0.6" radius="0.2"/>
      </geometry>
      <origin xyz="0.5 0 0" rpy="0 0 0" />
    </visual>
  </link>
</robot>

<?xml version="1.0"?>
<robot name="myfirst">
  <link name="base_link">
    <visual>
      <geometry>
        <cylinder length="0.6" radius="0.2"/>
      </geometry>
      <origin xyz="0 0 0" rpy="1.57075 0 0" />
    </visual>
  </link>
</robot>

Wednesday, December 26, 2018

explanation ROSTOPIC with drawing and source code


personally, I need to draw the relationship between the source codes and concept.
There are so many concept to understand but it was not easy.
That is why I draw this.



 source code refers to http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

Monday, November 19, 2018

(NEW version) Premiere Pro | lightroom Dial


Part List link

Amazon Links

Arduino pro micro
https://amzn.to/2k8NDCr

Encoder
https://amzn.to/2t5FcvH

Blu-Tack
https://amzn.to/2IqeFUe

Knob
https://amzn.to/2L9Rj37

pin headers
https://amzn.to/2JxkH5W


Aliexpress Link



Important link


    
3D Modeling File (STL)  


Note

I made a dial for creators.
As a premiere pro user, I needed a device which can control the timeline easily.
I tried to make this controller, finally, this is the second version of it.
The dial has a button, I made a code that changes its function every time I press it.
So, I can use this dial for not only premiere pro but Lightroom.
I’m going to share how to make, a short story and some information.

Monday, September 17, 2018

how to subscribe from server (javascript, html, python, ajax)

EventSource, stream.onmessage, Response()

javascript side


    var stream = new EventSource('/api/stream');
    stream.onmessage = function(e) {
      console.info(e.data);
      $("#received").append(e.data+"\n");
      $("#received")[0].scrollTop = $("#received")[0].scrollHeight;
    };


python side

#from queue import Queue
#from flask import Response
queue = Queue()
def event_stream():
    while True:
     # Question: how to break out of this loop when the app is killed?
        message = queue.get(True)
        print("Sending {}".format(message))
        yield "data: {}\n\n".format(message)


@app.route('/api/stream')
def stream():
    return Response(event_stream(), mimetype="text/event-stream")


reference 
https://www.w3schools.com/html/html5_serversentevents.asp

Friday, September 14, 2018

How to modify cache control max age value in Flask Python

@app.after_request
def add_header(response):
    response.cache_control.max_age = 1
    return response

just add this code

Thursday, August 23, 2018

[Study] Flask url_for example

Why is this needed?

A YouTube video was the first time I encountered url_for feature. I couldn't understand what it was, for what it is. And today, I began to read the official manual

http://flask.pocoo.org/docs/0.12/quickstart/#url-building

And there are a lot of example code from opensource projects
https://www.programcreek.com/python/example/51519/flask.url_for


in short, url_for() function looks up app.route('/here')
if there are more than one app.route('/here'), the function looks up right above the function

test.py

from flask import Flask, url_for, render_template

app = Flask(__name__)

@app.route("/")
@app.route("/1st")
@app.route("/2nd")
@app.route("/3rd")
def lookAtMe():
    return render_template('index.html')

if __name__ == "__main__":
    app.run(debug=True)


index.html

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    {{ url_for('lookAtMe') }}
  </body>
</html>

result


Tuesday, August 21, 2018

How to use render_template in Flask

Why template is needed?

Let's say we need to a number of dynamic html page. The page need to be changed based on data from outside. Without template, we need to make a static HTML page in manual way. "template" gives an easy way to replace page's content in a very simple way. it feels like a mail merge feature in a word processor.
As we want to make a dynamic page, we need to use this feature "template"

(I am following this Flask tutorial)

This instruction shows how to deal with template, url_for in Flask.

How to use "template"?

import class

in order to use "template", firstly we need to import a class named "render_template" in python file.


from flask import Flask, render_template

preparing a HTML file in "templates" folder

I prepared "hello.html" inside of templates folder.

templates/hello.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1>This is hello world</h1>
  </body>
</html>


code it (test.py)

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
@app.route("/hello")
def hello():
    return render_template("hello.html")

if __name__ == "__main__":
    app.run(debug=True)


result 


Sending Data 


from flask import Flask, render_template
app = Flask(__name__)

varForPython = ["welcome", "to", "my", "channel!"]

@app.route("/")
@app.route("/hello")
def hello():
    return render_template("hello.html", varForHtml = varForPython)

if __name__ == "__main__":
    app.run(debug=True)

Receiving Data and Using it in the HTML file



<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    
    {% for line in varForHtml%}
    <h1> {{ line.name }} </h1>
    <p> {{ line.title }}</p>
    <p>{{ line.date }}</p>
    {% endfor %}

  </body>
</html>

URDF Link origin test