connect to scale

More
10 years 11 months ago #65185 by markder13
connect to scale was created by markder13
for a new project with vision I'm working with openCV an linuxcnc. I'm able to reconise the markers and control based upon the location of the markers with the pyton linuxcnc command
Code:
c.mode(linuxcnc.MODE_MDI) c.wait_complete() # wait until mode switch executed c.mdi('G0 X%d Y%d Z.5' % (x_g/10, y_g/10))

However I would like to control the setting of opencv by gladevcp. How do I read the values of my scales in python file. See attached screen shot of gladevcd. the pin that are in use. I do not understand the what needs to be change in the exampel file
Code:
def on_button_press(self,widget,data=None): ''' a callback method parameters are: the generating object instance, likte a GtkButton instance user data passed if any - this is currently unused but the convention should be retained just in case ''' print "on_button_press called" self.nhits += 1 self.builder.get_object('hits').set_label("Hits: %d" % (self.nhits))

Any guidance would be helpful to get the readings for use in python.

Mark

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #65193 by cmorley
Replied by cmorley on topic connect to scale
Did you assign a signal callback in glade to call on_button_press()?

also a scale widget needs an adjustment widget assigned to it (with appropriate settings).
Does your scale have an adjustment?

Chris M

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #65196 by markder13
Replied by markder13 on topic connect to scale
Hi Chris,

The scale has adjustment attached. The change max value can be seen in the HAL configuration watch section. The code for this adjustment:
Code:
<object class="GtkAdjustment" id="adjustment3"> <property name="upper">179</property> <property name="step_increment">1</property> <property name="page_increment">10</property>

I think the problem is with the signal callback. I tried to modify the hitcounter.py example to get reading. But this was not successful. the added scale has the following name:
Code:
<object class="HAL_HScale" id="HighH_b"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="adjustment">adjustment3</property> <property name="round_digits">1</property>

An modified hitcounter.py reflecting this callback function would be highly appreciated.

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago - 10 years 11 months ago #65206 by newbynobi
Replied by newbynobi on topic connect to scale
Hallo Mark, (correct Name?)

with glade make a callback the adjustment of your slider to its changed value signal
and in your code get the value like this:
Code:
def on_adj_High_b_value_changed(self, widget, data = None): value = widget.get_value()

Maybe you have to convert the value to be used within opencv.
Does this answer your question?

May I email you if I have questions to opencv, as i am just in a middle of a project for shooting target evaluation.

Norbert
Last edit: 10 years 11 months ago by newbynobi.

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #65209 by markder13
Replied by markder13 on topic connect to scale
Dear Norbert,

Thanks for your feedback. I think I can not connect the callback in glade. Which property do I need to select. (see screen dump).
I tried several options but I did not get it working. (I use the HAL_Hscale and not the HALIO_Hscale)

I have add the UI and PY file

On openCV if you have a question please let me know, if can help

Thanks.

Mark

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #65229 by cmorley
Replied by cmorley on topic connect to scale
value_changed is the one to use

Please Log in or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.074 seconds
Powered by Kunena Forum