How do i combine an object tracking code with engine movement code ?

11 views (last 30 days)
I have an object tracking code-(1) and a code that moves a simple robot-manipulator-(2). Code No (1) is made to track red objects with a camera and to display their coordinates in the command window. And Code No (2) is for moving/rotation of the electric engines(dynamixel) by manually typing in the coordinates.
How do i combine the two codes so that when a red object is displayed the robot-manipulator automatically moves to its coordinates ?
Here are the links to Google Drive Documents to the codes: (1) - https://docs.google.com/document/d/1h6Ip4v_R6LQcC0DfTJqrdNbwPA0lBRgc51A9k40nsrU/edit?usp=sharing (2) - https://docs.google.com/document/d/1A9miXVto9GJppjdVQLFZ3NaW_Qd3Zq2NLnk3ckBfx1Y/edit?usp=sharing These are just regular documents like on microsoft word but you can view them without downloading them.
I know this is a pretty big and complex question and im gonna be extremely lucky if anybody can answer. Thank you in advance for your time.

Accepted Answer

Cam Salzberger
Cam Salzberger on 31 Aug 2017
Hello George,
It looks like both of the pieces of code are written as scripts. Scripts generally are written for single-shot purposes, usually testing some algorithm or getting some data, but not made to work together. I would suggest modifying the scripts to make them into functions. There are some documentation pages that can give you an overview of what the difference is.
I would create a overall control script or parameter-less function. This control code would call the image processing function, which would return the position of the object. The control code could then call the robot movement function with the position as an input.
I am assuming that the robot movement controller is already doing the translation from pixel position from the camera to Euler position of the arm? If not, you may need a third piece of code in between the two calls to do that.
Also, remember that you don't need to declare variables with their type in MATLAB.
int32 GoalPos;
does nothing useful for you.
Hope this gives you a direction to move in!
-Cam

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!