Hello, my name is Lisandro Massera and I´ve been lurking this list for a year 
now. I´m from Argentina and I´ve been trying to get LinuxCNC to work with a 5 
axis machine (XYZAC configuration) I've built.After all kind of problems, the 
only one left is that when I jog in world mode, I get following errors. Due to 
the dynamics of my machine, when I have to jog in world mode I have to decrease 
the max velocity (the linear axes move faster than the rotary axes, and 
LinuxCNC only lets you specify a single max speed for everyone). The strange 
part is that it only happens in the negative direction. For example, when I jog 
in the A+ direction everything is OK, but when I try to go back jogging in the 
A- direction I get following error. 
I tracked the bug to command.c and control.c. When they decide whether the 
desired speed is > than max speed, they compare desired speed > max speed. This 
is ok if desired speed is positive, but it fails if it is negative. It should 
be abs(desired speed) > max speed. The same happens with the acceleration.
I tried to fix the code (I attach the git diff). It compiles OK but still the 
same keeps happening. Is there a problem with using abs() in that context? I 
don't know enough of linux and programming to answer that question. Or is the 
bug elsewhere?

Thanks

Lisandro Massera


                                          
diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c
index 3ee0f76..7952b7c 100644
--- a/src/emc/motion/command.c
+++ b/src/emc/motion/command.c
@@ -1429,14 +1429,14 @@ check_stuff ( "before command_handler()" );
                double velmag;
                emcmotDebug->teleop_data.desiredVel = emcmotCommand->pos;
                pmCartMag(emcmotDebug->teleop_data.desiredVel.tran, &velmag);
-               if (emcmotDebug->teleop_data.desiredVel.a > velmag) {
-                   velmag = emcmotDebug->teleop_data.desiredVel.a;
+               if (abs(emcmotDebug->teleop_data.desiredVel.a) > velmag) {
+                   velmag = abs(emcmotDebug->teleop_data.desiredVel.a);
                }
-               if (emcmotDebug->teleop_data.desiredVel.b > velmag) {
-                   velmag = emcmotDebug->teleop_data.desiredVel.b;
+               if (abs(emcmotDebug->teleop_data.desiredVel.b) > velmag) {
+                   velmag = abs(emcmotDebug->teleop_data.desiredVel.b);
                }
-               if (emcmotDebug->teleop_data.desiredVel.c > velmag) {
-                   velmag = emcmotDebug->teleop_data.desiredVel.c;
+               if (abs(emcmotDebug->teleop_data.desiredVel.c) > velmag) {
+                   velmag = abs(emcmotDebug->teleop_data.desiredVel.c);
                }
                if (velmag > emcmotConfig->limitVel) {
                    pmCartScalMult(emcmotDebug->teleop_data.desiredVel.tran,
diff --git a/src/emc/motion/control.c b/src/emc/motion/control.c
index d3590a2..2352b24 100644
--- a/src/emc/motion/control.c
+++ b/src/emc/motion/control.c
@@ -1303,14 +1303,14 @@ static void get_pos_cmds(long period)
            (emcmotDebug->teleop_data.desiredVel.c -
            emcmotDebug->teleop_data.currentVel.c) /
            servo_period;
-       if (emcmotDebug->teleop_data.desiredAccell.a > accell_mag) {
-           accell_mag = emcmotDebug->teleop_data.desiredAccell.a;
+       if (abs(emcmotDebug->teleop_data.desiredAccell.a) > accell_mag) {
+           accell_mag = abs(emcmotDebug->teleop_data.desiredAccell.a);
        }
-       if (emcmotDebug->teleop_data.desiredAccell.b > accell_mag) {
-           accell_mag = emcmotDebug->teleop_data.desiredAccell.b;
+       if (abs(emcmotDebug->teleop_data.desiredAccell.b) > accell_mag) {
+           accell_mag = abs(emcmotDebug->teleop_data.desiredAccell.b);
        }
-       if (emcmotDebug->teleop_data.desiredAccell.c > accell_mag) {
-           accell_mag = emcmotDebug->teleop_data.desiredAccell.c;
+       if (abs(emcmotDebug->teleop_data.desiredAccell.c) > accell_mag) {
+           accell_mag = abs(emcmotDebug->teleop_data.desiredAccell.c);
        }
        
        /* accell_mag should now hold the max accell */
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to