Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Call Extruder converting to a string

#1
I recently updated my software to the most recent version of RoboDK (5.7.4) from an older version and have experienced an issue that may be due to this software update and an update to the post processor scripts.

I primarily use my Universal Robots UR5e cobot for 3D printing operations, and implement an extruder driver function that allows the digital and analog pins on my robot controller to be addressed based on the "Extruder(value)" commands. Depending on the "value" in the parenthesis. The following function has been pasted below.

Code:
def Extruder(value):
    # use the value as an output:
    if value == 0:
        set_digital_out(1,False)
        set_digital_out(2,False)
        set_analog_out(0,0.0) # Stop extruder
    elif value < 0:
        set_digital_out(0,False)  
        set_digital_out(1,True)  
        set_digital_out(2,True)  
        set_analog_out(0,0.1 * value) # Retract extruder
    else:    
        set_digital_out(0,True)  
        set_digital_out(1,True)  
        set_digital_out(2,True)  
        set_analog_out(0,(0.1 * value)) # Start extruder      
    end      
end

It can be seen that non-zero values correspond to extruder motor direction, as well as analog output. This function worked for interpreting extrusion values without any issues, until the software was updated.

Inserting this function into the first line of my program before sending it to the robot enables the "Extruder(value)" lines to be properly interpreted by the robot.

The problem that is arising is due to the generation of the program by the post processor, as it appears to change the value in the extruder lines to a string. This is evident, as the decimal has been converted from a float value to a string (ex: Extruder(5.00000) becomes Extruder(500000), which cannot be correctly interpreted by the system when running a program. 

The online help forums recommend implementing the following function into the post processor:
Code:
def RunCode(self, code, is_function_call = False):
    if is_function_call:
        if code.startswith("Extruder("):
            # Intercept the extruder command.
            # if the program call is Extruder(123.56)
            # we extract the number as a string
            # and convert it to a number
            self.PRINT_E_NEW = float(code[9:-1])
            # Skip the program call generation
            return
        else:
            self.addline(code + "()")
    else:
        # Output program code
        self.addline(code)
I attempted to implement this into the post processor, and it does not appear to fix my issue. Is there any resource I can look into for guidance?
#2
RoboDK should not remove this decimal point by default.

Did you obtain this result by doing post processor customization?
Can you share your RoboDK project file?
#3
Attached is the workstation for the project. I have tried using a default Universal Robots post processor to see if the issue was arising due to changes in the pp, but that does not appear to be so.

Sevcik


Attached Files
.rdk   UR5e Setup for RoboDK.rdk (Size: 8.54 MB / Downloads: 246)
#4
We'll be fixing this program call issue for Universal Robots with our next release next week.

In the meantime, you can apply the fix by implementing the RunCode function below.
Code:
    def RunCode(self, code, is_function_call = False):
        """Adds code or a function call"""
        if is_function_call:
            if "(" in code:
                idx_fcn = code.index("(")
                code = FilterName(code[:idx_fcn]) + code[idx_fcn:]
            else:
                code = FilterName(code)
                
            self.addline(code)
                
        else:
            code = FilterBackSlash(code)
            self.addline(code)
  




Users browsing this thread:
1 Guest(s)