# Best practice for sequential operations on a robot?

**URL:** <https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926>\
**Category:** General\
**Created:** [26 January 2025 19:16 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926 "2025-01-26T19:16:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palmhoej](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Palmhoej](https://discourse.nodered.org/u/Palmhoej)\
**Post date:** [26 January 2025 19:16 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/1 "2025-01-26T19:16:20Z")

</div>

So i am doing this little home project:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/1124df0ca2b7a50f8f86b208fe5117adc9b1e42a.jpeg)

Its a small Dobot MG400 robot arm that takes my families old pictures, put them into a scanner, takes them out and on and on it goes.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/628b93f1d667a7fd803a28f79943046f15bce413.png)

It works using TCP, so I will inject a command and the robot arm will start doing that command. Once the robot arm is done, it returns the exact same message that started it, letting me know that the operation has been completed successfully.

What is the best/neatest code you would use for continuously injecting the commands in the given order (see above picture)? I am not quit sure how the best way to approach this.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 January 2025 19:54 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/2 "2025-01-26T19:54:54Z")

</div>

One way:

1. Set your commands in a array e.g `["op1","op2","opn"]`
2. Feed that into a split node. (That will cause them to be split and released 1 at a time)
3. Use something to queue the stream of messages and release them once you get a response (I'd use [node-red-semaphore-plus (node) - Node-RED](https://flows.nodered.org/node/@marcus-j-davies/node-red-semaphore-plus))

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [27 January 2025 08:52 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/3 "2025-01-27T08:52:07Z")

</div>

Wow, what a cool project - looks like a lot of fun!

> [@Palmhoej](#):
>
> I am not quit sure how the best way to approach this.

Does the robot answer with state information, i.e., "the arm is at this position" - if so then you can have a switch node that ensures the appropriate command for the position is sent to the robot. Something like:

state --\> command  
arm is at rest --\> send command to pick up photo  
arm has picked up picture --\> move arm to scanner  
arm is at scanner --\> drop picture on scanner  
...

Sending blindly commands in order ensures that if something goes wrong, it will get worse! I.e. if you're not inspecting state of the robot arm then sending commands might well just make it worse.

Also do you get feedback from the scanner? Can you fully automate this process?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 January 2025 09:23 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/4 "2025-01-27T09:23:01Z")

</div>

To guarantee that one command is finished before the next is started you can use this simple flow to run them sequentially. ["wait until" node changed behavior after recent update - #2 by Colin](https://discourse.nodered.org/t/wait-until-node-changed-behavior-after-recent-update/92129/2)

---

<div class="post-metadata">

**Author:** ![Palmhoej](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Palmhoej](https://discourse.nodered.org/u/Palmhoej)\
**Post date:** [1 February 2025 19:59 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/5 "2025-02-01T19:59:31Z")

</div>

I used your suggestion and now it looks like this and it works. Feel free to criticize, that's the only way we can learn 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/059d5ce24cb07508c8460b17abaa60f75d0a836c.png)

So, the next thing I need to solve is a mechanical "issue": When I apply a vacuum to the photos on the scanner, the suction goes right through the pictures (a photo is apparently VERY permeable), so instead of the robot lifting the picture as intended, it tries to lift the whole scanner... to be continued 🙄

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 February 2025 20:19 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/6 "2025-02-01T20:19:03Z")

</div>

> [@Palmhoej](#):
>
> instead of the robot lifting the picture as intended, it tries to lift the whole scanner

You could strap a gecko to the robot arm and use his sticky feet. A cyborgecko.  
[https://stanforddaily.com/2023/02/01/lab-develops-stickiest-non-sticky-material/](https://stanforddaily.com/2023/02/01/lab-develops-stickiest-non-sticky-material/)

---

<div class="post-metadata">

**Author:** ![Palmhoej](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Palmhoej](https://discourse.nodered.org/u/Palmhoej)\
**Post date:** [2 February 2025 10:07 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/7 "2025-02-02T10:07:03Z")

</div>

I could, but then I would also have to make the automatic feeding and watering system for him... and I am also a little bit skeptical about the reliability, how do you keep him motivated to keep taking photo number 151 of Aunt Gerdas infamous boring birthday party out of the scanner? I do not want to make him watch, what I have already lived 😬

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 February 2025 14:56 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/8 "2025-02-02T14:56:33Z")

</div>

> [@Palmhoej](#):
>
> how do you keep him motivated to keep taking photo number 151 of Aunt Gerdas infamous boring birthday party out of the scanner?

Perhaps you could train him to simply eat the boring photos! 🤣

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 February 2025 14:59 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/9 "2025-02-02T14:59:26Z")

</div>

> [@Palmhoej](#):
>
> When I apply a vacuum to the photos on the scanner, the suction goes right through the pictures (a photo is apparently VERY permeable), so instead of the robot lifting the picture as intended, it tries to lift the whole scanner... to be continued

One possible approach might be to switch to a sliding motion rather than a lifting one? It would require some re-arrangement of the hoppers of course.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 February 2025 14:59 UTC](https://discourse.nodered.org/t/best-practice-for-sequential-operations-on-a-robot/94926/10 "2025-02-16T14:59:43Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
