Get monitor output name from Gdk - python-3.x

My xrandr configuration is
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 480mm x 270mm
HDMI-2 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 480mm x 270mm
~/.config/monitors.xml
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<scale>1</scale>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>HDMI-1</connector>
<vendor>GSM</vendor>
<product>LG IPS FULLHD</product>
<serial>704NTFA9H451</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>1920</x>
<y>0</y>
<scale>1</scale>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>GSM</vendor>
<product>LG FULL HD</product>
<serial>508NTTQCZ625</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>
With Gdk i get information
import gi
gi.require_version("Gdk", "3.0")
from gi.repository import Gdk, GdkX11
display = Gdk.Display.get_default()
print('manufacturer', 'model', 'output')
for m in range(display.get_n_monitors()):
monitor = Gdk.Display.get_monitor(display, m)
print(
monitor.get_manufacturer(),
monitor.get_model(),
GdkX11.X11Monitor.get_output(monitor)
)
Outputs
manufacturer model output
GSM HDMI-1 66
GSM DP-1 68
Why output name on model property? Is this same on other distributions, Gtk version, other DM or Wayland and Xorg ? Can i convert integer from GdkX11.X11Monitor.get_output() to name suitable for xrandr and monitors.xml?
Can I rotate monitor using gir ?
Gtk 3.24 Xorg-server 1.20.11

Related

ORB SLAM2 + ROS transformation

I want to add an INS to tf which will transform pointcloud from ORB SLAM2 to real world coordinate. My idea is to do a transformation so that the INS is at the rotational center of the robot.
My tf_tree looks like this: INS -> map -> base_link -> camera_link
My problem - despite the set transformation, the point cloud is saved in the orb slam system, not in the real coordinate system with INS. For my future work I have to get point cloud with world coordinates in ECEF.
(Ubuntu 18.04 with ROS Melodic and orb_slam2__ros)
What I made:
Between INS and map I made a broadcaster that reads the data from IMU (x,y,z,w) and transforms it to ROS msg.
transform_msg.header.frame_id = "INS"
transform_msg.child_frame_id = "map"
If I understand correctly, ORB SLAM2 transforms the point cloud from base_link to the map. (These parameters can be changed na file Node.cc na file .launch of camera in OS2)
Between base_link and camera_link I have a static_transform_publisher.
node pkg="tf2_ros" type="static_transform_publisher" name="gopro_offset" args="0 0 0 0 0 0 base_link camera_link" / include file="$(find orb_slam2_ros)/ros/launch/GOPRO.launch" /

How can I get Monitor Connection information from Wayland?

When running under X, I can get information about the monitor connection as follows:
$ xrandr --verbose
DP-0.8 connected 2560x1440+2560+0 (0x1bd) normal (normal left inverted right x axis y axis) 597mm x 336mm
...
SignalFormat: DisplayPort
supported: DisplayPort
ConnectorType: DisplayPort
ConnectorNumber: 3
_ConnectorLocation: 3
non-desktop: 0
supported: 0, 1
2560x1440 (0x1bd) 241.500MHz +HSync -VSync *current +preferred
...
This information is available to applications via XRRListOutputProperties in #include <X11/extensions/Xrandr.h>
Is there an equivalent when running under Wayland? Specifically I need the information provided by ConnectorType and ConnectorNumber

cannot set position of wx.frame on openbox

i am playing with wxPython and try to set position of frame:
import wx
app = wx.App()
p = wx.Point(200, 200)
frame = wx.Frame(None, title = 'test position', pos = p)
frame.Show(True)
print('frame position: ', frame.GetPosition())
app.MainLoop()
even though print('frame position: ', frame.GetPosition()) shows the correct postion, the frame is shown in top left corner of screen.
Alternatively i tried
frame.SetPosition(p)
frame.Move(p)
without success.
my environment: ArchLinux 5.3.13, python 3.8.0, wxpython 4.0.7, openbox 3.6.1
On cinnamom the code works as expected. How to solve this on openbox?
edit 07,12,2019:
i could set postion of a dialog in openbox config ~/.config/openbox/rc.xml:
<application name="fahrplan.py"
class="Fahrplan.py"
groupname="fahrplan.py"
groupclass="Fahrplan.py"
title="Fahrplan *"
type="dialog">
<position force="no">
<x>760</x>
<y>415</y>
</position>
</application>
i got name, class etc. from obxprop. x and y are calculated to center a dialog of 400 x 250 px on screen of 1920 x 1080 px.
This static solution is not suitable for me. I want to place dynamically generated popups.
I had the same problem under Windows and played around with the style flags. With wxICONIZE sytle set active the window finally used the positioning information
The position is provided to the window manager as a "hint". It is totally up to the window manager whether it will actually honor the hint or not. Check the openbox settings or preferences and see if there is anything relevant that can be changed.

I can not calibrate correct accurate for resistive touch screen on Kivy app

I have a problem with my 5 inch resistive touch screen which I need to calibrate touch on Kivy app. My touch in Raspberry pi is correctly calibrated but when it comes to Kivy app it is not correct.
How can I calibrate the touch to get accurate touch in my Kivy app (GUI). I am using Raspberry pi 3 with Raspbian os (full version not lite) this.
Take a look at the configuration options for Kivy's mtdev input module: https://kivy.org/docs/api-kivy.input.providers.mtdev.html - in particular max_position_x, min_position_y, etc. From the documentation:
You can use a custom range for the X, Y and pressure values. On some drivers, the range reported is invalid. To fix that, you can add these options to the argument line:
invert_x : 1 to invert X axis
invert_y : 1 to invert Y axis
min_position_x : X minimum
max_position_x : X maximum
min_position_y : Y minimum
max_position_y : Y maximum
min_pressure : pressure minimum
max_pressure : pressure maximum
min_touch_major : width shape minimum
max_touch_major : width shape maximum
min_touch_minor : width shape minimum
max_touch_minor : height shape maximum
rotation : 0,90,180 or 270 to rotate
In ~/.kivy/config.ini, you should put something like this:
[input]
mtdev_%(name)s = probesysfs,provider=mtdev,max_position_x=12345,max_position_y=12345
This is if you're using mtdev, but you can also use hidinput from kernel 2.6.34 onwards. See also: https://kivy.readthedocs.io/en/master/api-kivy.input.providers.hidinput.html

How to communicate through a serial port with python?

I am creating a Solar Array Simulator with python to simulate the voltage and current being created with different angles and intensities of sunlight as a satellite orbits around the earth. I have a very simple program that outputs the voltage and current just with the angle (no orbiting parameters yet). However, I need it to communicate the outputs generated with a E4350B model solar array simulator through a serial port, and I don't know where to start. I have installed pip and used that to install PySerial but do not know what to do from there. How do I communicate the voltage and amp outputs to the simulator through COM ports? Here is what I have for my program that runs the simulator.
from math import sin,radians,pi
import time
'''Needed information:
Voc (per one cell) = 2,680mV
Vmp (per one cell = 2,325mV
Isc (per one cell) = 453mA
Imp (per one cell) = 434mA
angular velocity = .05d/s'''
#Timer eclipse set for total eclipse tim ein seconds
timeEclipse = 1800
#total eclipse time = 30 mins
#Timer sun set for how many seconds it takes to change one degree
timeSun = 20
#Total sun exposer time = 60 mins
#Find the Vmp, Voc, Imp, and Isc from Beta angles 0 - 180
def Exposure():
tSun = timeSun
for x in range(0,181):
angle = sin(radians(x))
Voc = 2680 * angle
Vmp = 2325 * angle
#Amps are going to be a function of voltage
Isc = 453 * angle
Imp = 434 * angle
#
print('At angle ',x,' Vmp = ',Vmp,
'mV, Voc = ',Voc,'mV, Isc = ',Isc,'mA, and Imp = ',Imp,'mA')
time.sleep(tSun)
#Simulate time during eclipse
#Outputs nothing
def Eclipse():
tEclipse = timeEclipse
time.sleep(tEclipse)
#Run loop through Exposure and eclipse
def Run():
run = True
while(run):
Exposure()
Eclipse()
P.S. For anybody who dabbles in a little bit of physics, I need a way to find the current as a function of the voltage at every angle.

Resources