AX-12a ball picker
Nawawi from Malaysia  [4 posts]
4 years
Hai everybody,

How can I do this using Java with roborealm?

Steven Gentner from United States  [1370 posts] 4 years
First start by getting the control system up and running. Can you program the servos in Java to move the arm? Then work on where you will place the camera and get some initial shots to work with that can be detected. They used yellow balls on a black background for a reason, they are easier to detect. Once you have all those pieces in place you can start looking into the vision processing.

Nawawi from Malaysia  [4 posts] 4 years
Hai Steven,

This is my Java programming and a link below showing my AX-12a arm robot movement. I'm a little bit blur about how to integrate Java with the Roborealm or the PING ultrasonic sensor. What API do i have to use or any other tips from you Stevens? Thanks in advance.


public class Test {
    public static void main(String args[]) throws InterruptedException
int init = dynamixel_jni.dxl_initialize(); // initiating Dynamixel.
if(init == 1)
// dynamixel_jni.dxl_write_word(<servo number> , <addresses> , <value>);
dynamixel_jni.dxl_write_word(1, Control_Addresses.MOVING_SPEED, 150); // set servo1 moving speed is 150.
//dynamixel_jni.dxl_write_word(1, Control_Addresses.GOAL_POSITION, 0); // moving servo1 to 0 position.
Thread.sleep(1000); // wait 1 second. (Note that: 1000 miliseconds is equal to 1 second)
dynamixel_jni.dxl_write_word(1, Control_Addresses.GOAL_POSITION, 823); // moving servo1 to 1023 position
Thread.sleep(2000); // wait 2 second.
dynamixel_jni.dxl_write_word(2, Control_Addresses.MOVING_SPEED, 80); // set servo4 moving speed is 80.
dynamixel_jni.dxl_write_word(3, Control_Addresses.MOVING_SPEED, 80); // set servo5 moving speed is 80.
dynamixel_jni.dxl_write_word(2, Control_Addresses.GOAL_POSITION, 512); // moving servo4 to 623 position
//since servo 4 & 5 is in pair, the balance value from servo4 must be added to servo5 (1023 - 623 = 400).
dynamixel_jni.dxl_write_word(3, Control_Addresses.GOAL_POSITION, 511);
Thread.sleep(3000); // wait 1 second.
// same as above
//dynamixel_jni.dxl_write_word(4, Control_Addresses.GOAL_POSITION, 400); // moving servo4 to 623 position
//dynamixel_jni.dxl_write_word(5, Control_Addresses.GOAL_POSITION, 623); // balance value to servo5
//Thread.sleep(1000); // wait 1 second.
//dynamixel_jni.dxl_write_word(1, Control_Addresses.GOAL_POSITION, 512); // moving servo1 to 512 position.
//Thread.sleep(500); // wait 0.5 second.
dynamixel_jni.dxl_write_word(6, Control_Addresses.GOAL_POSITION, 512); // moving servo6 to 512 position, default speed.
dynamixel_jni.dxl_write_word(7, Control_Addresses.GOAL_POSITION, 480); // moving servo7 to 512 position, default speed.
//Thread.sleep(5000); // wait 2 second.
dynamixel_jni.dxl_write_word(7, Control_Addresses.GOAL_POSITION, 670); // moving servo7 to 512 position, default speed.

dynamixel_jni.dxl_write_word(2, Control_Addresses.GOAL_POSITION, 200); // moving servo7 to 512 position, default speed.
dynamixel_jni.dxl_write_word(3, Control_Addresses.GOAL_POSITION, 823); // moving servo7 to 512 position, default speed.
Thread.sleep(2000); /// wait 2 seconds
dynamixel_jni.dxl_write_word(1, Control_Addresses.GOAL_POSITION, 200);
dynamixel_jni.dxl_write_word(2, Control_Addresses.GOAL_POSITION, 512);

dynamixel_jni.dxl_write_word(3, Control_Addresses.GOAL_POSITION, 511);
dynamixel_jni.dxl_write_word(7, Control_Addresses.GOAL_POSITION, 480);
//dynamixel_jni.dxl_write_word(1, Control_Addresses.GOAL_POSITION, 200);
Thread.sleep (500);
dynamixel_jni.dxl_write_word(2, Control_Addresses.GOAL_POSITION, 200);        
dynamixel_jni.dxl_write_word(3, Control_Addresses.GOAL_POSITION, 823);

dynamixel_jni.dxl_terminate(); // close Dynamixel.
Steven Gentner from United States  [1370 posts] 4 years
That's a very good start. Now you can look at the API and download the examples which include one in Java. That's what you will use to get the result of the image processing from RoboRealm. At the same time, you will have to create a Roborealm configuration that will recognize your cube. At this point, you will need to create a setup that you can use each time. Remember in the original video how the background was different than the blocks ... once you start to create a processing pipeline to extract out where the blocks are you will see why. So try to first replicate their results by creating a nice solid color for the base (you can try using a very large mouse pad) and get some nice high contrast blocks ... or alternatively use a white base with your currently black blocks. the blue you currently have has to go further to encompass the entire block from the cameras point of view. Once you get something you think might work, paste a couple of those images here from what the camera sees and we can help create that roborealm configuration.

Nawawi from Malaysia  [4 posts] 4 years

Do you have link for source code, tutorial, or youtube that I may refer?
Steven Gentner from United States  [1370 posts] 4 years
The API can download at


other than that, no, there is no source code for you to refer to as what you are doing is quite unique. Same goes for the youtube videos. Like mentioned in the previous post, get your setup ready and post some images here from the camera's point of view and we can help further.

Nawawi from Malaysia  [4 posts] 4 years
Hai Steve

I have setup the roborealm for object detection (http://www.youtube.com/watch?v=4p87X2pF928)

But I still have the problem to execute the dll file.
Steven Gentner from United States  [1370 posts] 4 years
What dll file are you referring to?


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index