This commit is contained in:
wait
2025-04-24 17:06:20 +08:00
parent 09582c474b
commit affe72c308
6 changed files with 180 additions and 71 deletions

View File

@@ -4,6 +4,8 @@ import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import org.opentcs.kc.common.byteutils.ByteUtils;
import org.opentcs.kc.udp.Service.ActImmediately;
import org.opentcs.kc.udp.Service.ReadValue;
import org.opentcs.kc.udp.agv.param.AgvEvent;
import org.opentcs.kc.udp.agv.param.AgvEventConstant;
import org.opentcs.kc.udp.agv.param.function.af.QueryRobotStatusRsp;
@@ -225,19 +227,90 @@ public class KCCommandDemo {
// }
// }
{
//0xB2(立即动作指令)
AgvEvent agvEvent = actionNow();
printInfo(agvEvent);
RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
if(rcv.isOk()){
System.out.println("0xB2 ok");
}else {
System.out.println();
System.out.println("0xB2 fail");
System.out.println("received transationId : "+ "isok:"+rcv.isOk());
}
}
// {
// //0xB2(立即动作指令)
// AgvEvent agvEvent = actionNow();
// printInfo(agvEvent);
// RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
// if(rcv.isOk()){
// System.out.println("0xB2 ok");
// }else {
// System.out.println();
// System.out.println("0xB2 fail");
// System.out.println("received transationId : "+ "isok:"+rcv.isOk());
// }
// }
// {
//
// //todo 读取动作执行状态
// byte[] value = ReadValue.command();
// int execStatus = value[0];
//
// Thread.sleep(200);
//
// while (execStatus == 2) {
// byte[] value1 = ReadValue.command();
// execStatus = value1[0];
// }
//
//
// ActImmediately.reset();
//
// //todo 读取动作执行状态
// byte[] value2 = ReadValue.command();
// int execStatus2 = value2[0];
//
// Thread.sleep(200);
//
// while (execStatus2 == 2) {
// byte[] value1 = ReadValue.command();
// execStatus2 = value1[0];
// }
//
// float height = 1.1f;
// byte modeOfMovement = 0x01;
//
// //抬升叉齿指令
// ActImmediately.command(height, modeOfMovement);
// }
{
ActImmediately.reset();
}
// {
//
// //todo 读取动作执行状态
// byte[] value = ReadValue.command();
// int execStatus = value[0];
//
// Thread.sleep(200);
//
// while (execStatus == 2) {
// byte[] value1 = ReadValue.command();
// execStatus = value1[0];
// }
//
//
// ActImmediately.reset();
//
// //todo 读取动作执行状态
// byte[] value2 = ReadValue.command();
// int execStatus2 = value2[0];
//
// Thread.sleep(200);
//
// while (execStatus2 == 2) {
// byte[] value1 = ReadValue.command();
// execStatus2 = value1[0];
// }
//
// float height = 0.1f;
// byte modeOfMovement = 0x02;
//
// ActImmediately.command(height, modeOfMovement);
// }
@@ -338,26 +411,10 @@ public class KCCommandDemo {
public static AgvEvent actionNow() {
AgvEvent agvEvent = new AgvEvent(AgvEventConstant.CommandCode_ACT_IMMEDIATELY);
//TODO 构建
Integer actionID = 5;
Integer actionID = 102;
// //构建Action指令
Action actionLiftUp = new Action(
ActionSet.fork0x12, //机器人移动到正常点 停止2个字节
(byte) 0x02, //只能执行当前动作
actionID, //actionID
ActionSet.fork0x12_paramsize,
ActionSet.fork0x12(
1.1f, //升降高度
(byte) 0x01, //1上升 2下降
(byte)0x01 //01 开始 任务
)
);
agvEvent.setBody(actionLiftUp.toBytes());
// //重置 空指令
// Action actionReset = new Action(
// Action actionLiftUp = new Action(
// ActionSet.fork0x12, //机器人移动到正常点 停止2个字节
// (byte) 0x02, //只能执行当前动作
// actionID, //actionID
@@ -365,10 +422,26 @@ public class KCCommandDemo {
// ActionSet.fork0x12(
// 1.1f, //升降高度
// (byte) 0x01, //1上升 2下降
// (byte)0x00 //01 开始 任务
// (byte)0x01 //01 开始 任务
// )
// );
// agvEvent.setBody(actionReset.toBytes());
// );
// agvEvent.setBody(actionLiftUp.toBytes());
// //重置 空指令
Action actionReset = new Action(
ActionSet.fork0x12, //机器人移动到正常点 停止2个字节
(byte) 0x02, //只能执行当前动作
actionID, //actionID
ActionSet.fork0x12_paramsize,
ActionSet.fork0x12(
0.0f, //升降高度
(byte) 0x01, //1上升 2下降
(byte)0x00 //01 开始 任务
)
);
agvEvent.setBody(actionReset.toBytes());
//
// //构建Action指令
// Action actionLiftDown = new Action(

View File

@@ -9,7 +9,7 @@ import org.opentcs.kc.udp.io.UDPClient;
public class ActImmediately extends BaseCommand{
private static Integer actionId = 20;
private static Integer actionId = 115;
/**
* decs: 立即动作指令

View File

@@ -49,7 +49,7 @@ public class HybridNavigation
/**
* 订单映射最大订单ID.
*/
private static int currentMaxiOrderId = 25;
private static int currentMaxiOrderId = 100;
/**
@@ -78,7 +78,7 @@ public class HybridNavigation
Path[] paths = new Path[]{
new Path(
pathSerialNum, pathID, 0f, (byte) 0x00, (byte) 0x01, ByteUtils.usintTo1Byte(0), 1f, 1f, null
pathSerialNum, pathID, 0f, (byte) 0x00, (byte) 0x00, ByteUtils.usintTo1Byte(0), 1f, 1f, null
),
};
pathSerialNum += 2;

View File

@@ -35,7 +35,7 @@ public class ReadValue extends BaseCommand{
RcvEventPackage rcv = UDPClient.localAGV.send(agvEvent);
if (rcv.isOk()) {
System.out.println();
System.out.println("-received " + "isok:" + rcv.isOk() + " dataBytes:");
System.out.println("-received readvalue" + "isok:" + rcv.isOk() + " dataBytes:");
printInfo(rcv);
ReadRsp readRsp = new ReadRsp(rcv.getDataBytes());
return readRsp.dataValue;

View File

@@ -154,10 +154,6 @@ public enum UDPClient {
public void subscribeKC(RcvEventPackage rcv, byte[] body) {
if (rcv.isOk()) {
Date date = new Date();
System.out.println("time:" + date.getTime());
for (byte b : body) {
System.out.print(byteToHex(b) + " ");
}