How would you design a real time application for cnc control in c / c++ ???

More
09 Jun 2021 12:58 - 09 Jun 2021 13:07 #211615 by Grotius
Hi,

Just leave the opencascade.h untouched.

I want to connect slider to 3d model, but this string crash all compile
Ah. This make sence.

For example how to connect a button, the .cpp file :
void Robot::onClicked(const QString& in1, const QString& in2, const QString& in3)
has a slot in the .h file:
public slots:
    void onClicked(const QString& in1,const QString& in2,const QString& in3);
t
is controlled by the .qml file :
Button {
            robot.onClicked(input1.text,input2.text,input3.text)
    }

Personally i never pass argument's in button's themself. Qt has no interface for this. But if above example works it's ok for me.

For a slider you have information like a float value for the slider value. It is no string value !
You just use a float value. Hal has no double value's present.
For info : It's not always a good idea to use onClicked. the "on" is used by qt internals.

Try to integrate the slider function first make it work in the cpp an h file.
Pass some value's with the existing buttonpress function.
After that create the connection to the qml.
Last edit: 09 Jun 2021 13:07 by Grotius.

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

More
09 Jun 2021 14:24 #211621 by TheRoslyak
Ok
I connect slider to interface. It counts in both directions. But if I use opencascade function - project is crash.
dropmefiles.com/Cammf
Attachments:

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

More
09 Jun 2021 21:04 - 09 Jun 2021 21:15 #211639 by Grotius
Hi,

In the main.cpp the opencascade is named occ.
engine.rootContext()->setContextProperty("occ", new Opencascade);

In main.qml you create the robot scene by calling :
occ.createrobotscene();

So for passing the slider values to occ it would be something like :
occ.setslidervalue(10);
(calling that from your qml code)

What you did is calling a c++ opencascade function directly. An sich this is no problem. This methode can be used, but not alway's.
Why not then?
Opencascade has to be initialized, started etc before it can be used.

Normally this is done once in a program loop. For c++ :
Opencascadewidget *occ = new Opencascadewidget;

Then in your program you call a function like :
occ->setslidervalue(10);

Then it will show no error.
I hope this give you an idea how to handle this. In the beginning it can be quite confusing. But when you have practiced
a little more, you will begin to understand how things work in c++.

P.s.
Very nice to see, you are using qt design studio.
Can you tell us your experience with this program? Is it nice to use? Is it difficult?
Last edit: 09 Jun 2021 21:15 by Grotius.

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

More
10 Jun 2021 08:18 #211678 by TheRoslyak
I thought of doing this, but as soon as I start writing in Robot.h:
include <opencascade.h>
project not compile

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

More
10 Jun 2021 11:16 - 10 Jun 2021 11:20 #211687 by Grotius
Hi,

You can add the code to your project.
Mention creating the slot signal in opencascade.h and then call it from qml with : occ.yourslotsignal()
Now you can happely go on with coding !

In the main.qml:
Warning: Spoiler!


Opencascade.h:
Warning: Spoiler!


Opencascade.cpp:
Warning: Spoiler!


And your robot is moving !
You have to check your model rotation-translation yourself.

You can look at this function to rotate your model. It's based on a quaternion. But first try to get it correct using the
existing example.

Warning: Spoiler!


Attachments:
Last edit: 10 Jun 2021 11:20 by Grotius.

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

More
10 Jun 2021 11:27 - 10 Jun 2021 12:21 #211688 by TheRoslyak
Thank you so much.
I know about rotation problem. I think I can do it :)

How you can hide yellow cross?

PS Can you check "LinuxCNC S-Curve Accelerations" topic
Attachments:
Last edit: 10 Jun 2021 12:21 by TheRoslyak.

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

More
12 Jun 2021 12:11 #211868 by Grotius
Hi,

For reading a stepfile, there are different options. Try this example :
Warning: Spoiler!


PS Can you check "LinuxCNC S-Curve Accelerations" topic

If you have problem's with a nice motion output. Try to integrate a stepgen component between your motion command and
motor drives. The stepgen component can finetune the acceleration-deacceleartion very nice.
The following user(s) said Thank You: tommylight, bkt

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

More
19 Aug 2021 15:02 - 19 Aug 2021 15:08 #218142 by udoS
Hi Grotius... remember me ?

In reference to your "Qt_C-_Lcnc_Gui"

there is a section ...toolpos.x=emcStatus->motion.traj.position.tran.x; in get_position.h
Where do I find things like distance_to_go.x and/or other related values or maybe a relevant documentation.

Oh... and how to index if I have a gantry like I realy do.

Best regards

udo
Last edit: 19 Aug 2021 15:08 by udoS.

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

More
20 Aug 2021 13:37 - 20 Aug 2021 13:41 #218239 by Grotius
Hi, i "duckducked".

Motion distance-to-go is inside the motion controller.
linuxcnc.org/docs/2.7/html/man/man9/motion.9.html

motion.distance−to−go OUT FLOAT
Distance remaining in the current move

You can retrieve this value by reading the halpin of the motion ..
In c++ you can setup a gui component with a hal-in pin of type float.

In the current repository their seems not to be a gui-component. The
level of coding was quite low at that time.

Then connect in the .hal file the motion-halpin type::hal_out to your gui input pin.
Examples how to setup this, see the attachements. rename .txt to .cpp

Oh... and how to index if I have a gantry like I realy do.
You mean activate the home sequence?
Attachments:
Last edit: 20 Aug 2021 13:41 by Grotius.

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

More
21 Aug 2021 16:48 - 21 Aug 2021 16:50 #218332 by udoS
Hi, thanks. 
That’s not it. 
The distance-to-go is ok but that is the total move. 
I‘m looking for .dtg that comes as a tuple from the nml emcSatus. 
So it should be available somewhere at:
std:get<0>(emcSatus-> ........  .dtg);
Using Qtcreator 4.8 

Best regards
Attachments:
Last edit: 21 Aug 2021 16:50 by udoS.

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

Time to create page: 0.232 seconds
Powered by Kunena Forum