Professional Documents
Culture Documents
HansRobot SDK Document
HansRobot SDK Document
HansRobot SDK Document
Install SDK
<dependency>
<groupId>com.hansrobot</groupId>
<artifactId>robot-sdk</artifactId>
<version>1.0.0</version>
</dependency>
//为 common
<dependency>
<groupId>com.hansrobot</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
</dependency>
Uninstall SDK
COS Java SDK class name is com.hansrobot.robotsdk.*,You can import the classes
required for program execution through IDE tools such as Eclipse or Intellij.
There are two situations when executing an action, one is that the status
will be returned synchronously, and the other is that the status will be
returned asynchronously. The asynchronous state is that when the interface
is called, it will immediately return a call state of the interface, and
then asynchronously return an execution state; For example, navigation
interface: Calling a navigation interface will immediately return a status
indicating whether the call was successful or not (immediately), and then
return a status indicating whether the AGV navigation was successful or not
(asynchronously)
。
Connecting robots
Before operating a robot, you need to connect the robot
subscribe(SubscribeTopic.ROBOT_DATA.name(), true,null);
Interface call instructions
When calling the robot, you need to confirm two things: 1. Before the robot
confirms the positioning, it needs to confirm whether the robot is in the normal
position, or is not moved in the case of shutdown 2. Before calling, you need to seize
the control of the robot, otherwise the action cannot be executed (the control can
be seized repeatedly)
AGV navigation
The AGV can navigate to a certain site of the map based on the built
parameters
if (CallResult.check(cr)) {
CallResult finalResult = CallResult.success();
NavigateRequestParam param = new
NavigateRequestParam();
//
param.setCmd(CommonTypes.RunCmdEnum.START);
//Site name
param.setDestPosition("LM30");
//Map name
param.setDestMap("0823");
//result For pullback parameters
cr = api.navigate(param, result -> {
if (CallResult.check(result))
System.out.println("navigate successfully");
else
System.out.println("navigate failed");
finalResult.fromOther(result);
finalResult.setData("");
System.out.println("error:" + result.getError() + "
msg:" + result.getMessage());
});
Assert.assertEquals(HansRobotError.SUCCESS,
cr.getError());
while (finalResult.getData() == null) {
CommonClass.sleep(1000);
}
}
NavigateRequestParam:
AGV can navigate to a certain site in the map based on the built parameters,
and since the method is a synchronous method, there is no need to wait for
a callback
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
Assert.assertEquals(cr.getError(),
HansRobotError.SUCCESS);
if (CallResult.check(cr)) {
CallResult finalResult = CallResult.success();
NavigateRequestParam param = new
NavigateRequestParam();
param.setCmd(CommonTypes.RunCmdEnum.START);
param.setDestPosition("LM1");
param.setDestMap("testMap");
cr = api.navigateForSync(param);
Assert.assertEquals(HansRobotError.SUCCESS,
cr.getError());
}
NavigateRequestParam:
Site information
destPosition String
within the map
ARM can perform actions already preset in the robotic arm, simply passing
the script name, or transfer parameters to perform IF conditions
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
Assert.assertEquals(cr.getError(),
HansRobotError.SUCCESS);
if (CallResult.check(cr)) {
RunArmFunctionRequestParam param = new
RunArmFunctionRequestParam();
param.setCmd(CommonTypes.RunCmdEnum.START);
param.setFunctionName("Func_test");
CallResult finalResult = CallResult.success();
cr = api.runArmFunction(param, result -> {
if (CallResult.check(result))
System.out.println("run arm script function
successfully");
else
System.out.println("run arm script function
failed");
finalResult.setData("");
RunArmFunctionRequestParam :
The incoming
functionParams Enum
parameters
Timeout time, -1 is no
timeout int
timeout
ARM performs robotic arm action (synchronization method)
The ARM can perform actions that are already preset in the robotic arm, and
only need to transmit Script name, or transmit parameters to perform IF
conditions
if (CallResult.check(cr)) {
RunArmFunctionRequestParam param = new
RunArmFunctionRequestParam();
param.setCmd(CommonTypes.RunCmdEnum.START);
param.setFunctionName("Func_test");
CallResult finalResult = CallResult.success();
cr = api.runArmFunctionForSync(param);
}
RunArmFunctionRequestParam :
The incoming
functionParams Enum
parameters
Timeout time, -1 is no
timeout int
timeout
SetParamsForSdkParam:
Need to be charged
needChargePowerLevel (automatically charged String
when less than how much)
Need to be charged
needChargePowerLevel (automatically charged String
when less than how much)
EmergencyStopRequestParam :
Reposition request
});
System.out.println(result.getData());
System.out.println(result.getError());
System.out.println(result.getMessage());
RelocateRequestParam :
false
repoint
Relocation x coordinates in
robotX float
meters
radius parameters.
The robot confirms the positioning request, the robot needs to manually
confirm the positioning, and cannot automatically confirm the positioning,
because it cannot be determined whether the robot is moved when it is shut
down
System.out.println(result.getData());
Preemption of control
The robot takes control, and before you can control the robot, you need to
seize control, otherwise it can't executive command
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
CallResult result = api.takeControl();
System.out.println(result.getData());
Release of control
Initialize the clamp claw of the mechanical arm 485type, which cannot hang
articles on the clamp claw, and the mechanical arm needs to be at the home
point
Control claw
The claw of control arm 485type, true is closed and false is open
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
CtrlGripperRequestParam params = new
CtrlGripperRequestParam();
params.setClose(false);
CallResult result = api.ctrlGripper(params);
System.out.println(result.getData());
The mechanical arm back to the preset home point, call this interface need
to pay attention to the safety of the mechanical arm, there is anyone around
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
CallResult result = api.armGoHomePose(callResult -> {
});
System.out.println(result.getData());
The mechanical arm opens zero force teaching, at this time the mechanical
arm can swing at will
BooleanRequestParam :
System.out.println(result.getData());。
RunCmdRequest :
To obtain the site information in the map, it can be used with the acquisition
map information interface
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
GetPositionsRequestParam param = new
GetPositionsRequestParam();
//map name
param.setMapName("0823");
CallResult result = api.getPositions(param);
System.out.println(result.getData());
GetPositionsRequestParam :
To obtain the site information in the map, it can be used with the acquisition
map information interface
HansRobotSDK api = new HansRobotSDK();
CallResult cr = api.connectRobot(robotIp, 32000, 32001);
GetMapInfoRequestParam param = new
GetMapInfoRequestParam();
param.setMapName("0823");
param.setContainPixelData(false);
CallResult result = api.getMapInfo(param);
System.out.println("4" + result.getData());
GetMapInfoRequestParam :
The mechanical arm moves continuously, but it needs to be used with another
interface
longMoveEvent
axisId
Point axis ID(0-5) int
(0:X,1:Y,2:Z,3:RX,4:RY,5:RZ)
Movement mode: 1.
moveMode Continuous movement, and 2. int
Fixed movement
When the above interface is moving, it needs to be called once every 500
milliseconds, otherwise the mechanical arm will stop, only need to pass the
true parameter directly can be, need to stop, can pass false can
api.longMoveEvent(true);
The interface allows the AGV to rotate at an Angle and the speed can be
controlled
});
System.out.println(result.getData());
RotateRequestParam :
});
System.out.println(result.getData());
MoveLineRequestParam:
SwitchMapRequestParam :
ManualMoveRequestParam 类,主要成员属性如下:
vy Pass 0 float
The preset robotic arm script can be programmed in the robotic arm and then
used
here
});
System.out.println(result.getData());
RunArmScriptRequestParam :
The preset robotic arm script can be programmed in the robotic arm and then
used here
HansRobotSDK api = new HansRobotSDK();
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());
CtrlArmRequestParam :
valid。
0:powerOn
2:stop
3:clearFaults
4:armSpeed