commit for push

This commit is contained in:
caixiang 2025-04-23 14:25:02 +08:00
parent 51aa9c7561
commit 503b7e9f4c
3 changed files with 74 additions and 84 deletions

View File

@ -12,6 +12,7 @@ import org.opentcs.kc.udp.agv.param.function.b1.SubscribeParam;
import org.opentcs.kc.udp.agv.param.function.b1.SubscribeRsp;
import org.opentcs.kc.udp.agv.param.function.navigation.*;
import org.opentcs.kc.udp.agv.param.function.read.ReadParam;
import org.opentcs.kc.udp.agv.param.function.read.ReadRsp;
import org.opentcs.kc.udp.agv.param.function.read.ReadStrValue;
import org.opentcs.kc.udp.agv.param.function.read.ReadValueMember;
import org.opentcs.kc.udp.agv.param.function.write.WriteParam;
@ -37,28 +38,28 @@ import org.opentcs.kc.udp.io.UDPClient;
public class KCCommandDemo {
public static void main(String[] args)
throws Exception {
{
//0xAF(查询机器人状态)
AgvEvent agvEvent = queryStatus();
printInfo(agvEvent);
RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
if(rcv.isOk()){
System.out.println();
System.out.println("received transationId : "+ "isok:"+rcv.isOk());
for (byte b:rcv.getValue()){
System.out.print(byteToHex(b)+" ");
}
System.out.println();
System.out.println("---------------------");
for (byte c:rcv.getDataBytes()){
System.out.print(byteToHex(c)+" ");
}
QueryRobotStatusRsp queryRobotStatusRsp = new QueryRobotStatusRsp(rcv.getDataBytes());
}else {
System.out.println();
System.out.println("received transationId : "+ "isok:"+rcv.isOk());
}
}
// {
// //0xAF(查询机器人状态)
// AgvEvent agvEvent = queryStatus();
// printInfo(agvEvent);
// RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
// if(rcv.isOk()){
// System.out.println();
// System.out.println("received transationId : "+ "isok:"+rcv.isOk());
// for (byte b:rcv.getValue()){
// System.out.print(byteToHex(b)+" ");
// }
// System.out.println();
// System.out.println("---------------------");
// for (byte c:rcv.getDataBytes()){
// System.out.print(byteToHex(c)+" ");
// }
// QueryRobotStatusRsp queryRobotStatusRsp = new QueryRobotStatusRsp(rcv.getDataBytes());
// }else {
// System.out.println();
// System.out.println("received transationId : "+ "isok:"+rcv.isOk());
// }
// }
// {
// //0xB0(查询载货状态)
@ -210,19 +211,19 @@ public class KCCommandDemo {
// }
// }
{
//0xAE(导航控制导航点控制)
AgvEvent agvEvent = navigationControl();
printInfo(agvEvent);
RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
if(rcv.isOk()){
System.out.println("0xAE ok");
}else {
System.out.println();
System.out.println("0xAE fail");
System.out.println("received transationId : "+ "isok:"+rcv.isOk());
}
}
// {
// //0xAE(导航控制导航点控制)
// AgvEvent agvEvent = navigationControl();
// printInfo(agvEvent);
// RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
// if(rcv.isOk()){
// System.out.println("0xAE ok");
// }else {
// System.out.println();
// System.out.println("0xAE fail");
// System.out.println("received transationId : "+ "isok:"+rcv.isOk());
// }
// }
{
//0xB2(立即动作指令)
@ -238,19 +239,7 @@ public class KCCommandDemo {
}
}
{
//0xB2(立即动作指令)
AgvEvent agvEvent = navigationControl();
printInfo(agvEvent);
RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
if(rcv.isOk()){
System.out.println("0xAE ok");
}else {
System.out.println();
System.out.println("0xAE fail");
System.out.println("received transationId : "+ "isok:"+rcv.isOk());
}
}
}
@ -283,18 +272,18 @@ public class KCCommandDemo {
/**
* decs: read操作
* 指令0x02
* 指令0x01
* author: caixiang
* date: 2025/1/17 16:25
*/
public static AgvEvent readValue() {
AgvEvent agvEvent = new AgvEvent(AgvEventConstant.CommandCode_READ);
List<ReadValueMember> readValueMemberList = new ArrayList<>();
ReadValueMember readValueMember1 = new ReadValueMember(Short.valueOf("0"), Short.valueOf("1"));
ReadValueMember readValueMember1 = new ReadValueMember(Short.valueOf("10"), Short.valueOf("1"));
readValueMemberList.add(readValueMember1);
List<ReadStrValue> readStrValueList = new ArrayList<>();
ReadStrValue readStrValue = new ReadStrValue("Battry_SOC", 1, readValueMemberList);
ReadStrValue readStrValue = new ReadStrValue("Lift", 1, readValueMemberList);
readStrValueList.add(readStrValue);
ReadParam readParam = new ReadParam(agvEvent.getTransationId(), readStrValueList);
@ -351,36 +340,38 @@ public class KCCommandDemo {
//TODO 构建
Integer orderId = 1;
//构建Action指令
Action actionLiftUp = new Action(
ActionSet.stop0x00, //机器人移动到正常点 停止2个字节
(byte) 0x02, //只能执行当前动作
1, //actionID
ActionSet.fork0x12_paramsize,
ActionSet.fork0x12(
1.1f, //升降高度
(byte) 0x01, //1上升 2下降
(byte)0x01 //01 开始 任务
)
);
agvEvent.setBody(actionLiftUp.toBytes());
//
// //重置 空指令
// Action actionReset = new Action(
// ActionSet.stop0x00, //机器人移动到正常点 停止2个字节
// //构建Action指令
// Action actionLiftUp = new Action(
// ActionSet.fork0x12, //机器人移动到正常点 停止2个字节
// (byte) 0x02, //只能执行当前动作
// 2, //actionID
// ActionSet.cancle0x03_paramsize,
// ActionSet.cancel0x12(
// 1, //订单id
// (byte)0x01 //1 立即停止 2 正常移动到点再停止
// 1, //actionID
// ActionSet.fork0x12_paramsize,
// ActionSet.fork0x12(
// 1.1f, //升降高度
// (byte) 0x01, //1上升 2下降
// (byte)0x01 //01 开始 任务
// )
// );
// agvEvent.setBody(actionReset.toBytes());
// agvEvent.setBody(actionLiftUp.toBytes());
//重置 空指令
Action actionReset = new Action(
ActionSet.cancel0x03, //机器人移动到正常点 停止2个字节
(byte) 0x02, //只能执行当前动作
2, //actionID
ActionSet.cancle0x03_paramsize,
ActionSet.cancel0x12(
1, //订单id
(byte)0x01 //1 立即停止 2 正常移动到点再停止
)
);
agvEvent.setBody(actionReset.toBytes());
//
// //构建Action指令
// Action actionLiftDown = new Action(
// ActionSet.stop0x00, //机器人移动到正常点 停止2个字节
// ActionSet.fork0x12, //机器人移动到正常点 停止2个字节
// (byte) 0x02, //只能执行当前动作
// 1, //actionID
// ActionSet.fork0x12_paramsize,

View File

@ -11,8 +11,8 @@ public class ActionSet {
}
public static byte stop0x01 = 0x01;
public static byte stop0x00 = 0x00;
public static byte fork0x12 = 0x12;
public static byte cancel0x03 = 0x03;
public static byte recover0x02 = 0x02;
public static byte cancelTask0x03 = 0x03;

View File

@ -10,13 +10,12 @@ import org.opentcs.kc.udp.agv.param.AgvEvent;
public class main {
public static void main(String[] args) {
//size 148 ,contentSize = 148-28 = 120
String errSrc = "d4 97 44 9c cb cf 0b 4c 95 51 d8 61 70 f1 e7 94 01 01 00 00 10 af 00 00 00 68 00 00 00 00 00 00 53 3a 48 bd 32 fb 7b bc ca 13 03 ba 01 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 01 00 00 00 00 00 00 05 00 00 00 01 00 00 00 01 01 00 00 02 00 00 00 02 00 00 00 01 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
String okSrc = "d4 97 44 9c cb cf 0b 4c 95 51 d8 61 70 f1 e7 94 01 01 03 00 10 af 00 00 64 00 00 00 01 00 00 00 73 1c 30 3d 66 ba 03 3d d9 51 59 bb 00 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 01 02 00 00 00 00 00 00 00 00 00 73 1c 30 3d 66 ba 03 3d d9 51 59 bb 00 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 ";
String[] s = errSrc.split(" ");
System.out.println("size: " + s.length);
printInfo(s);
// //size 148 ,contentSize = 148-28 = 120
// String errSrc = "d4 97 44 9c cb cf 0b 4c 95 51 d8 61 70 f1 e7 94 01 01 00 00 10 af 00 00 00 68 00 00 00 00 00 00 53 3a 48 bd 32 fb 7b bc ca 13 03 ba 01 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 01 00 00 00 00 00 00 05 00 00 00 01 00 00 00 01 01 00 00 02 00 00 00 02 00 00 00 01 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
// String okSrc = "d4 97 44 9c cb cf 0b 4c 95 51 d8 61 70 f1 e7 94 01 01 03 00 10 af 00 00 64 00 00 00 01 00 00 00 73 1c 30 3d 66 ba 03 3d d9 51 59 bb 00 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 01 02 00 00 00 00 00 00 00 00 00 73 1c 30 3d 66 ba 03 3d d9 51 59 bb 00 00 00 00 0c 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 ";
// String[] s = errSrc.split(" ");
// System.out.println("size: " + s.length);
// printInfo(s);
}