大家好,

我正在编程一个分拣单元,希望将托盘中的组件分拣到红色(基座2)或绿色(基座3)容器中。我已附上机器人程序的主要部分以及子程序。目前,机器人只将组件送到基座2(红色容器)。基座1定义在托盘下方的平台上。

我的想法是根据组件的某个属性(例如材料)进行分拣(例如,绿色组件放入绿色容器)。有人知道如何实现这一点,以及在IF语句中应使用什么条件吗?

(不倾向使用Python)

提前感谢。

你好,

使用过程建模,这很容易实现(请参考你之前帖子的回复:)在不教授50个目标点的情况下,从5×10托盘高效拾取50个零件(机器人程序)- #6 by mkittell 我认为如果不使用Python进行少量编程,仅靠机器人编程是无法实现的。 如果只有两种不同的颜色,可以让其他组件读取零件的材质,然后向机器人的输入端口发送真/假信号。在IF语句中,可以编写例如IN[100]来读取输入信号100的当前值。 您说的“其他组件读取零件材质”是什么意思? 在我的案例中该如何实现这一点? 提前感谢。 可以是流程语句、传感器或……Python脚本。 我同意@Tilma的观点:似乎不借助少量Python编程是无法实现的,而且我认为eCatalog中没有现成的组件可以读取/测量材质。)

I don’t think it is possible to do it with the robot programming without programming a little bit in Python.

In case of just two different colours, you can have some other component read the component’s material and then send a true/false signal to the robot’s inputs. To the IF statement, you can write for example IN[100] to read input signal 100:s current value.Robot Statements

What do you mean by another component reading the components material?

How would I go about implementing this in my case?

Thank you in advance

Something like a process statement, sensor, or a …python script.
I agree with@Tilma: it seems that this is not doable without a little Python, and I don’t think there’s any ready components in eCatalog to read/measure the material.

对你来说很幸运,我的硬盘里正好有一个颜色传感器的示例。它会检测与其射线碰撞的第一个表面的颜色。
我为你快速修改了它,现在如果与射线碰撞的材质名称中含有“绿色”或“红色”,它就会发送布尔信号。将此传感器连接到机器人的第5或第6个连杆,通过发送脉冲信号进行测量,并在IF语句中使用前面提到的表达式。
颜色传感器.vcmx(17.9 KB)

2个赞

这太棒了,谢谢!不过文件似乎没有正确上传。文件只包含了传感器。

你可以将此组件添加到你的布局中,并将其连接到你的夹爪上。

然后,你可以连接信号并在你的机器人程序中使用它们(如果需要,可以观看学院视频了解信号相关操作:机器人与信号 | Visual Components 学院

What does the print in output panel say? Did you remember to send the pulse signal to take a measurement?

Many thanks for the advice. I will definitely consider doing it this way for the next project. I’ve already committed to doing the sorting cell with the Robot Program Editor, so I want to see it through.:slight_smile:

Hello, i’ve tried the color sensor but didn’t work, in the image the box is red and the red bit doesn’t turn on! Any solution?

Thanks in advance!

The image, sorry.

Did you send a PulseSignal to take the measurement? It’s only checking the color when the PulseSignal is triggered

1 Like

没错,而且在建模选项卡中有一个隐藏参数可以修改,使其能够持续进行测量:


脉冲信号的作用是将其连接到例如体积检测器,这样就不会持续扫描,而只在感兴趣的对象靠近时才扫描,因为在3D世界中扫描三角形网格对性能的影响可能相当大。

3个赞

没想到是这样的。

谢谢!!这个社区真的很有帮助!!

1个赞

PLC信号也是类似的。实际上,我尽量少用连接到机器人的信号。我更喜欢在PLC中完成所有编程,并示教机器人点位,然后由PLC告诉机器人应该移动到哪个位置。顺便问一下,有没有地方可以看看其他人的项目来获取灵感?

提前感谢!

你可以看看案例研究:案例研究 - Visual Components

我觉得大多数人不会分享他们的项目,因为很多项目可能涉及保密内容。不过,在论坛上你仍然可以找到大量关于他人已完成或正在进行的项目的实例。 --- Gnome558 2026年1月27日 下午4:05 20 你好, 如何实现其他颜色,比如蓝色或绿色? 我尝试修改了,但结果不对。 先谢谢了! fddfsfds (图片:820×785,40.9 KB) --- Tilma 2026年1月28日 下午2:59 21 你创建了一个新的布尔信号,并在Python脚本中引用它了吗? grafik (图片:1065×647,53.4 KB) 我稍微尝试了一下: Layout_Color_Sensor.vcmx (844.5 KB) 1人点赞 --- Gnome558 2026年1月28日 下午5:50 22 谢谢,现在黄色也能正常工作了!!!

Hello again,

How can do with other color such as blue or green?

I have edited but its wrong.

Thanks in advance!

Did you create a new Boolean Signal, and reference it in the Python script?

I had a bit of fun:

Layout_Color_Sensor.vcmx(844.5 KB)

1 Like

Thanks now it also works with yellow!!!