You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
4.3 KiB
125 lines
4.3 KiB
2 years ago
|
package ros;
|
||
|
|
||
|
import cn.hutool.core.date.DateUtil;
|
||
|
import cn.hutool.core.util.HexUtil;
|
||
|
import cn.hutool.setting.SettingUtil;
|
||
|
import com.mchange.v1.util.SetUtils;
|
||
|
import edu.wpi.rail.jrosbridge.Ros;
|
||
|
import edu.wpi.rail.jrosbridge.Service;
|
||
|
import edu.wpi.rail.jrosbridge.Topic;
|
||
|
import edu.wpi.rail.jrosbridge.callback.TopicCallback;
|
||
|
import edu.wpi.rail.jrosbridge.messages.Message;
|
||
|
import edu.wpi.rail.jrosbridge.services.ServiceRequest;
|
||
|
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
|
||
|
import net.sf.json.JSON;
|
||
|
import net.sf.json.JSONArray;
|
||
|
import net.sf.json.JSONObject;
|
||
|
import org.apache.commons.collections.list.SetUniqueList;
|
||
|
import org.nl.agv.unit.sendToAgvUtil;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Set;
|
||
|
import java.util.function.BiConsumer;
|
||
|
|
||
|
public class Test2 {
|
||
|
|
||
|
public static void main31231(String[] args) {
|
||
|
// Ros ros = new Ros("192.168.137.41", 9290);
|
||
|
Ros ros = new Ros("192.168.137.41", 9290);
|
||
|
ros.connect();
|
||
|
Service addTwoInts = new Service(ros, "/Service_HMIString", "lu_ps20l_msgs/Srv_HMIString");
|
||
|
JSONObject json = new JSONObject();
|
||
|
//IFCONFIG
|
||
|
json.put("HMI_String_Input", "HMIStepOrRTPathFollow:0;18;1#");
|
||
|
//日志列表
|
||
|
//json.put("HMI_String_Input", "GetLogList");
|
||
|
//ros请求列表
|
||
|
//json.put("HMI_String_Input", "GetROSNodeList");
|
||
|
//芯片温度
|
||
|
//json.put("HMI_String_Input", "Temperature");
|
||
|
//获取站点(刘先源写正则表达式)
|
||
|
//json.put("HMI_String_Input", "GetStationFloorIndexTable");
|
||
|
//获取坐标(第二个)
|
||
|
//json.put("HMI_String_Input", "GetNodePointManagerTable");
|
||
|
ServiceRequest request = new ServiceRequest(json.toString());
|
||
|
ServiceResponse response = addTwoInts.callServiceAndWait(request);
|
||
|
System.out.println(response.toString());
|
||
|
ros.disconnect();
|
||
|
}
|
||
|
|
||
|
public static void main9090(String[] args) {
|
||
|
//调试信息
|
||
|
Ros ros = new Ros("192.168.0.40", 9290);
|
||
|
ros.connect();
|
||
|
while (true) {
|
||
|
Topic echoBack = new Topic(ros, "/Topic_Display_State", "lu_ps20l_msgs/Msg_DisplayState");
|
||
|
echoBack.subscribe(new TopicCallback() {
|
||
|
@Override
|
||
|
public void handleMessage(Message message) {
|
||
|
JSONObject jo = JSONObject.fromObject(message.toString());
|
||
|
System.out.println(message.toString());
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void main132(String[] args) {
|
||
|
ServiceResponse response = sendToAgvUtil.send("GetStationFloorIndexTable");
|
||
|
String result_info = response.toString();
|
||
|
String a = JSONObject.fromObject(response.toString()).optString("ROS_String_Output");
|
||
|
String[] split = a.split("\\n");
|
||
|
JSONObject json = new JSONObject();
|
||
|
for (int i = 0; i < split.length; i++) {
|
||
|
String row = split[i];
|
||
|
String[] rowArr = row.split("\\s+");
|
||
|
json.put(rowArr[3], rowArr[4].contains("<") ? "" : rowArr[4]);
|
||
|
}
|
||
|
JSONArray arr = new JSONArray();
|
||
|
for (Object key : json.keySet()) {
|
||
|
String value = (String) json.get(key);
|
||
|
System.out.println("Key = " + key + ", Value = " + value);
|
||
|
JSONObject row = new JSONObject();
|
||
|
row.put("point_code", key);
|
||
|
row.put("point_name", value);
|
||
|
arr.add(row);
|
||
|
}
|
||
|
System.out.println(arr);
|
||
|
}
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
JSONObject returnjo = new JSONObject();
|
||
|
JSONArray results = new JSONArray();
|
||
|
|
||
|
JSONObject jo = new JSONObject();
|
||
|
|
||
|
int a =1;
|
||
|
for (int i = 0; i < 3; i++) {
|
||
|
JSONArray ja = new JSONArray();
|
||
|
JSONObject jo1 = new JSONObject();
|
||
|
for (int j = 0; j < 3; j++) {
|
||
|
|
||
|
jo.put("point_code","A11");
|
||
|
jo.put("point_name","A11");
|
||
|
jo.put("code_name","A11");
|
||
|
ja.add(jo);
|
||
|
}
|
||
|
|
||
|
jo1.put("point_group_code",a);
|
||
|
a=a+1;
|
||
|
jo1.put("rows",ja);
|
||
|
results.add(jo1);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
returnjo.put("code", "1");
|
||
|
returnjo.put("desc", "更新成功!");
|
||
|
returnjo.put("results", results);
|
||
|
System.out.println("测试完成");
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|