analitics

Pages

Tuesday, January 26, 2021

Python 3.6.0 : Django 3.2 alpha 1 released.

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. 

I tested it and I was satisfied with the way it works with this framework and it has many good features for the web. 
Django 3.2 is designated as a long-term support release.

Today, Django 3.2 alpha 1 is available with new features.
A good roadmap towards Django 3.2. can be found on this schedule webpage.
As with all alpha and beta packages, this is not for production use.
Django 3.2 supports Python 3.6, 3.7, 3.8, and 3.9. The next release is expected in April 2021, see:
  • January 14, 2021, Django 3.2 alpha; feature freeze;
  • February 18 Django 3.2 beta; non-release blocking bug fix freeze;
  • March 18 Django 3.2 RC 1; translation string freeze;
  • April 6 Django 3.2 final release.

Sunday, December 27, 2020

Python 3.9.1 : Testing the drawSvg python package.

The tutorial for today is about drawSvg python package.
This python package let you to create SVG images (vector drawings) and rendering them or displaying them in a Jupyter notebook.
Let's install it with pip3 tool:
[mythcat@desk ~]$ cd PythonProjects/
[mythcat@desk PythonProjects]$ pip3 install drawSvg
...
Successfully installed drawSvg-1.7.0 imageio-2.9.0
A simple source code test added to svg_001.py python script:
import drawSvg as draw

# Draw a frame of the animation
def draw_frame(t):
    #Create draw surface and add a geometric shapes ...
    out = draw.Drawing(1, 1, origin=(0,0))
    out.setRenderSize(h=460)
    out.append(draw.Rectangle(0, 0, 5, 5, fill='white'))
    y = t + 0.3
    out.append(draw.Circle(0.5, y, 0.5, fill='blue'))
    return out

with draw.animate_video('example.gif', draw_frame, duration=0.01) as anim:
    # Add each frame to the animation
    for i in range(20):
        anim.draw_frame(i/10)
You can change the source code and open the GIF animation file:
[mythcat@desk PythonProjects]$ vi svg_001.py
[mythcat@desk PythonProjects]$ python svg_001.py 
[mythcat@desk PythonProjects]$ google-chrome example.gif
The result of the source code is this:

Monday, December 21, 2020

Python 3.6.9 : Ursina python game engine - part 001 .

I wrote the tutorial a few days ago and today I completed it with a video clip ...
The official webpage comes with this intro:
Ursina makes it easier to develop games, visualizations and other kinds of software.
The concise API combined with the power of the Python programming language, makes life easier for the developer so they can focus on what they are making.

Ursina can be used on Windows and Linux
Today I tested on Fedora Linux and works great.
First, the install process is easy with pip3 tool.
[mythcat@desk ~]$ pip3 install ursina
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: ursina in ./.local/lib/python3.9/site-packages (3.2.2)
Requirement already satisfied: screeninfo in ./.local/lib/python3.9/site-packages (from ursina) (0.6.6)
Requirement already satisfied: numpy in /usr/lib64/python3.9/site-packages (from ursina) (1.19.4)
Requirement already satisfied: panda3d in ./.local/lib/python3.9/site-packages (from ursina) (1.10.7)
Requirement already satisfied: pyperclip in ./.local/lib/python3.9/site-packages (from ursina) (1.8.1)
Requirement already satisfied: pillow in /usr/lib64/python3.9/site-packages (from ursina) (7.2.0)
Let's create some examples and see how this python package works.
Create a python script file:
[mythcat@desk ~]$ cd PythonProjects/
[mythcat@desk PythonProjects]$ vi ursina_001.py
Add this simple example:
from ursina import *
# create the application
app = Ursina()
# set some data , like a cube
ground = Entity(
    model = 'cube',
    color = color.blue,
    z = -.1,
    y = -3,
    origin = (0, .5),
    scale = (50, 1, 10),
    collider = 'box'
    )
# run the application
app.run()
And the last pas, run it with python:
[mythcat@desk PythonProjects]$ python ursina_001.py 
ursina version: 3.2.2
package_folder: /home/mythcat/.local/lib/python3.9/site-packages/ursina
asset_folder: .
psd-tools not installed
which: no blender in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:
/home/mythcat/.composer/vendor/bin:/home/mythcat/.dotnet/tools:/var/lib/snapd/snap/bin)
blender_paths:
{}
OS: posix
screen resolution: (1280, 1024)
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
render mode: default
no settings.py file
no settings.py file
development mode: True
application successfully started
You can read on web!:

Sunday, December 6, 2020

Python 3.6.9 : My colab tutorials - part 010.

In this tutorial created with Colab online tool I used HTML and JavaScript source code.
The tutorial is easy to understand and use it.
You can see all my examples of my GitHub repo.

Thursday, December 3, 2020

Python 3.6.9 : My colab tutorials - part 009.

I update may colab work and I add new notebooks.
You can see all of these on my GitHub account.
These are examples:
  • catafest_009.ipynb - show you how to use %% colab features;
  • catafest_010.ipynb - example with Detectron2 is Facebook AI Research's with state-of-the-art object detection algorithms;
  • catafest_011.ipynb - test a sound classification with YAMNet from a web example - not very happy with the result;

Sunday, November 22, 2020

Python 3.9.0 : Physics simulation with PyBullet .

I took a look at the documentation of this python packet to give you a brief introduction:
PyBullet is a fast and easy to use Python module for robotics simulation and machine learning, with a focus on sim-to-real transfer. With PyBullet you can load articulated bodies from URDF, SDF, MJCF and other file formats. PyBullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics, collision detection and ray intersection queries. The Bullet Physics SDK includes PyBullet robotic examples such as a simulated Minitaur quadruped, humanoids running using TensorFlow inference and KUKA arms grasping objects.
...
PyBullet can be easily used with TensorFlow and OpenAI Gym.
...
The GUI connection will create a new graphical user interface (GUI) with 3D OpenGL rendering, within the same process space as PyBullet. On Linux and Windows this GUI runs in a separate thread, while on OSX it runs in the same thread due to operating system limitations.
...
For UDP networking, there is a App_PhysicsServerUDP that listens to a certain UDP port.
...
By default, there is no gravitational force enabled. setGravity lets you set the default gravity force for all objects. The loadURDF will send a command to the physics server to load a physics model from a Universal Robot Description File (URDF). The URDF file is used by the ROS project (Robot Operating System) to describe robots and other objects, it was created by the WillowGarage and the Open Source Robotics Foundation (OSRF).

I tested with Fedora 33 and Python version 3.9.0.
The first step was installation.
[mythcat@desk ~]$ pip3 install pybullet --upgrade --user
Collecting pybullet
  Downloading pybullet-3.0.6.tar.gz (89.8 MB)
     |████████████████████████████████| 89.8 MB 51 kB/s 
Using legacy 'setup.py install' for pybullet, since package 'wheel' is not installed.
Installing collected packages: pybullet
    Running setup.py install for pybullet ... done
Successfully installed pybullet-3.0.6
The next step was to test with examples already built using urdf file type.
import pybullet as p
# Can alternatively pass in p.DIRECT 
client = p.connect(p.GUI)
p.setGravity(0, 0, -10, physicsClientId=client) 

import pybullet_data
p.setAdditionalSearchPath(pybullet_data.getDataPath())
planeId = p.loadURDF("plane.urdf")

my_racecar = p.loadURDF("racecar/racecar.urdf", basePosition=[0,0,0.2])

position, orientation = p.getBasePositionAndOrientation(my_racecar)

for _ in range(10000): 
    p.stepSimulation()
I run the script and all works well.
It can be seen that in the cycle for which I have the simulation for 10000 steps of time.
A smaller number will quickly interrupt the simulation.
You can create your own URDF files because they are formatted in XML format.
A good area for learning is this webpage.