Professional Documents
Culture Documents
单机机器人SDK文档
单机机器人SDK文档
1. <dependency>
2. <groupId>com.hansrobot</groupId>
3. <artifactId>robot-sdk</artifactId>
4. <version>1.0.0</version>
5. </dependency>
6.
7. //为 common
8. <dependency>
9. <groupId>com.hansrobot</groupId>
10. <artifactId>common</artifactId>
11. <version>1.0.0</version>
12. </dependency>
The package name of COS Java SDK is com.hansrobot.robotsdk.* , and you can import the
classes needed for program running through IDE tools such as Eclipse or Intellij.
There are two cases when executing an action, one is to return the status synchronously, and the
other is to return the status asynchronously. The asynchronous state is that when the interface is
called, it will immediately return a calling state of the interface, and then return an execution state
asynchronously; for example, the navigation interface: calling the navigation interface will
immediately return a status of whether the call is successful (return immediately ), and then return
a status of whether the AGV navigation is successful or not (asynchronous return).
Connect robot
6. Assert.assertEquals(cr.getError(), HansRobotError.SUCCESS);
14. }
subscribe(SubscribeTopic.ROBOT_DATA.name(), true,null);
1. Before the robot confirms the position, you need to confirm whether the robot is in the normal
position, or has not been moved by people when it is turned off
2. Before calling, the control right of the robot needs to be preempted, otherwise the action
cannot be executed (the control right can be preempted repeatedly)
AGV navigation
AGV can navigate to a certain site on the map according to the constructed parameters
5. if (CallResult.check(cr)) {
6. CallResult finalResult = CallResult.success();
7. NavigateRequestParam param = new NavigateRequestParam();
8. //
9. param.setCmd(CommonTypes.RunCmdEnum.START);
10. //position name
11. param.setDestPosition("LM30");
12. //map name
13. param.setDestMap("0823");
14. //result is the call parameters
15. cr = api.navigate(param, result -> {
16. if (CallResult.check(result))
17. System.out.println("navigate successfully");
18. else
19. System.out.println("navigate failed");
20. finalResult.fromOther(result);
21. finalResult.setData("");
22. System.out.println("error:" + result.getError() + " msg:" + result.getMessage());
23. });
24. Assert.assertEquals(HansRobotError.SUCCESS, cr.getError());
25. while (finalResult.getData() == null) {
26. CommonClass.sleep(1000);
27. }
28. }
Whether it arrives
noNeedPrecision Boolean
accurately is generally false
The AGV can navigate to a certain site on the map according to the constructed parameters.
Since this method is a synchronous method, there is no need to wait for the callback
4. if (CallResult.check(cr)) {
5. CallResult finalResult = CallResult.success();
6. NavigateRequestParam param = new NavigateRequestParam();
7. param.setCmd(CommonTypes.RunCmdEnum.START);
8. param.setDestPosition("LM1");
9. param.setDestMap("testMap");
10. cr = api.navigateForSync(param);
11. Assert.assertEquals(HansRobotError.SUCCESS, cr.getError());
12. }
Whether it arrives
noNeedPrecision Boolean
accurately is generally false
ARM performs robotic arm actions
ARM can execute preset actions in the robot arm, just need to pass the script name, and also can
transfer parameters to perform if conditional operation
4. if (CallResult.check(cr)) {
5. RunArmFunctionRequestParam param = new RunArmFunctionRequestParam();
6. param.setCmd(CommonTypes.RunCmdEnum.START);
7. param.setFunctionName("Func_test");
8. CallResult finalResult = CallResult.success();
9. cr = api.runArmFunction(param, result -> {
10. if (CallResult.check(result))
11. System.out.println("run arm script function successfully");
12. else
13. System.out.println("run arm script function failed");
14. finalResult.setData("");
21. }
ARM can execute preset actions in the robot arm, just need to pass the script name, and also can
transfer parameters to perform if conditional operation
4. if (CallResult.check(cr)) {
5. RunArmFunctionRequestParam param = new
RunArmFunctionRequestParam();
6. param.setCmd(CommonTypes.RunCmdEnum.START);
param.setFunctionName("Func_test");
CallResult finalResult = CallResult.success();
5. System.out.println(result.getData());
8. System.out.println(result.getMessage());
Relocation request
15. System.out.println(result.getMessage());
When the robot confirms the positioning request, the robot needs to manually confirm the
positioning, and cannot automatically confirm the positioning, because it is impossible to
determine whether the robot was moved by someone when it was turned off.
System.out.println(result.getData());
Seize control
The robot seizes the control right. Before controlling the robot, it needs to seize the control right,
otherwise the command cannot be executed.
System.out.println(result.getData());
release control
System.out.println(result.getData());
Query control
System.out.println(result.getData());
Initialize the gripper
Initialize the 485-type gripper of the robotic arm. When the gripper is initialized, no items can be
hung on the gripper and the robotic arm needs to be at the home point.
System.out.println(result.getData());
Control Gripper
The gripper of the controlled robotic arm 485 type, true is closed, false is open
params.setClose(false);
CallResult result = api.ctrlGripper(params);
System.out.println(result.getData());
The robot arm returns to the preset home point. When calling this interface, you need to pay
attention to the safety of the robot arm. Is there anyone around?
});
System.out.println(result.getData());
The mechanical arm is turned on for zero-force teaching, and the mechanical arm in this state
can swing freely.
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
BooleanRequestParam params = new BooleanRequestParam();
params.setParam(false);
CallResult result = api.startArmZeroForce(params);
System.out.println(result.getData());
System.out.println(result.getData());。
System.out.println(result.getData());
Get AGV map collection information
System.out.println(result.getData());
Obtain the site information in the map, which can be used in conjunction with the interface for
obtaining map information
System.out.println(result.getData());
Obtain the site information in the map, which can be used in conjunction with the interface for
obtaining map information.
1 HansRobotSDK api = new HansRobotSDK();
2 CallResult cr = api.connectRobot(robotIp, 32000, 32001);
3 GetMapInfoRequestParam param = new GetMapInfoRequestParam();
4 param.setMapName("0823");
5 param.setContainPixelData(false);
6 CallResult result = api.getMapInfo(param);
7 System.out.println("4" + result.getData());
// System.out.println("" + result.getData());
When the above interface is moving, it needs to be called once every 500 milliseconds, otherwise
the mechanical arm will stop, just pass the true parameter directly, and pass false when it needs
to stop
api.longMoveEvent(true);
This interface allows the AGV to rotate at a certain angle, and the speed can also be controlled.
});
System.out.println(result.getData());
});
System.out.println(result.getData());
System.out.println(result.getData());
Execute the preset robotic arm script, which can be programmed in the robotic arm and then
used HansRobotSDK api = new HansRobotSDK(); here
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
//执行机械臂脚本
RunArmScriptRequestParam param = new RunArmScriptRequestParam();
param.setCmd(CommonTypes.RunCmdEnum.START);
param.setFunctionParams(null);
param.setScriptName("");
param.setFunctionName("Func_1");
param.setTimeout(-1);
CallResult result = api.executeArmScript(param, callResult -> {
});
System.out.println(result.getData());
Execute the preset robotic arm script, which can be programmed in the robotic arm and then
used HansRobotSDK api = new HansRobotSDK(); here
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
CtrlArmRequestParam param = new CtrlArmRequestParam();
param.setArmIndex(0);
param.setArmSpeed(0);
param.setValidParam(CtrlArmRequestParam.ValidParamEnum.STOP_VALID);
param.setEnable(false);
param.setStop(false);
param.setClearFaults(false);
param.setClearFaults(false);
CallResult result = api.ctrlArm(param);
System.out.println(result.getData());