当前位置: 首页 > wzjs >正文

西宁做网站公司哪家好网络推广的公司更可靠

西宁做网站公司哪家好,网络推广的公司更可靠,网站权限怎么设置,备案网站云迹机器人底盘调用还是比较友好的,就是纯socket收发指令就能实现,今天实现一个底盘移动到指定点位功能。底盘的默认IP是192.168.10.10通讯端口是31001,测试机与底盘接入统一网络后直接发指令即可。本文给出两种语言调用源码,选择…

云迹机器人底盘调用还是比较友好的,就是纯socket收发指令就能实现,今天实现一个底盘移动到指定点位功能。底盘的默认IP是192.168.10.10通讯端口是31001,测试机与底盘接入统一网络后直接发指令即可。本文给出两种语言调用源码,选择一种使用即可。

python调用源码:

import socket
import jsonyunji_ip = "192.168.10.10"#设定地盘ip地址,需要根据机器人实际ip地址修改#底盘-移动到指定为止
def YunjiGo(target):print(f"---------------------YunjiGo:{target}---------------------")port = 31001command = "/api/move?marker=" + target + "&distance_tolerance=0&theta_tolerance=0"client = socket.socket()client.connect((yunji_ip, port))print(f"command:{command}")client.send(command.encode())while True:try:data = client.recv(1024)if not data:print("Socket closed by peer.")return Nonestr_data = data.decode('utf-8')split_data = [s for s in str_data.split('\n') if s]for s in split_data:try:json_data = json.loads(s)print(json_data.get("description"))# 检查条件:任务完成且目标匹配if (json_data.get("description") == "The move task is finished."and "data" in json_dataand "target" in json_data["data"]and json_data["data"]["target"] == target):print("Task finished successfully!")client.close()  # 关闭 socketreturn True     # 返回成功except json.JSONDecodeError:print("Invalid JSON data, continue waiting...")continueexcept socket.timeout:print("Timeout reached, no matching data received.")return Noneexcept Exception as e:print(f"Error occurred: {e}")client.close()  # 确保异常时关闭 socketreturn None
YunjiGo("huahua")#移动到点位huahua

JAVA调用源码:(需要下载org.json-20161124.jar)

package examples;
import java.io.*;
import java.net.*;
import org.json.JSONObject;
import org.json.JSONException;/*
依赖安装:
sudo apt update
sudo apt install language-pack-zh-hans  # 简体中文
sudo apt install fonts-noto-cjk        # 中文字体
sudo apt install default-jdk*///make:
/*
cd /home/java
javac -encoding UTF-8 -cp .:\
org.json-20161124.jar \
examples/RobotControl.java
*/
//run : 
/*
cd /home/java
java -Dfile.encoding=UTF-8 -cp .:\
org.json-20161124.jar \
examples.RobotControl
*/public class RobotControl {String yunji_ip  = "192.168.10.10";  // 底盘ip地址int yunji_port = 31001;//底盘通讯端口private static RobotControl mInstance =null;public static synchronized RobotControl getInstance() {if (mInstance == null) {mInstance = new RobotControl();}return mInstance;}//底盘移动public void YunjiGo(String target) throws Exception{String command = "/api/move?marker=" + target + "&distance_tolerance=0.01&theta_tolerance=0.01";try {Socket client = new Socket(yunji_ip, yunji_port);//System.out.println("command:" + command);OutputStream out = client.getOutputStream();out.write(command.getBytes());out.flush();InputStream in = client.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(in));String strData;while ((strData = reader.readLine()) != null) {//System.out.println("strData:" + strData);try {JSONObject jsonData = new JSONObject(strData);System.out.println(jsonData.optString("description"));// 检查条件:任务完成且目标匹配if (jsonData.optString("description").equals("The move task is finished.")&& jsonData.has("data")&& jsonData.getJSONObject("data").has("target")&& jsonData.getJSONObject("data").getString("target").equals(target)) {System.out.println("Task finished successfully!");client.close(); // 关闭 socketreturn;    // 返回成功}} catch (JSONException e) {System.out.println("Invalid JSON data, continue waiting...");continue;}}throw new Exception("Socket closed by peer.");} catch (SocketTimeoutException e) {throw new Exception("Timeout reached, no matching data received.");} catch (Exception e) {throw new Exception("Error occurred: " + e.getMessage());}}public static void main(String[] args) {  RobotControl robotControl = RobotControl.getInstance();try{System.out.println("------------YunjiGo------------");robotControl.YunjiGo("huahua");} catch (Exception e) {System.out.println("YunjiGo Error occurred: " + e.getMessage());}System.out.println();}
}

运行输出:


------------YunjiGo------------The move task is started.
Start to leave charging pile..
Charge status off.
Succeed to leave charging pile.
traffic turn right.
traffic turn right.
The move task is finished.
Task finished successfully!

http://www.dtcms.com/wzjs/96757.html

相关文章:

  • 建设信访建设网站的意义口碑营销怎么做
  • 自己做的网站发布到网上视频播放不了陕西seo优化
  • 广东粤网建设有限公司seo运营培训
  • 物流业网站建设方案实验总结天津关键词优化平台
  • 网站被k 但收录内页网络营销概述ppt
  • 做图片推广的网站竞价托管sem服务
  • 江门做网站引流获客工具
  • 做房产信息网站seo免费资源大全
  • 金昌网站建设活动策划方案详细模板
  • 注册网站送金币网站竞价推广
  • 哈尔滨做网站公司推广产品的渠道
  • 网页设计与网站建设 作业免费网站注册平台
  • 合肥建委网站网络优化工程师主要做什么
  • wordpress资源下载站网络推广公司哪家好
  • 建大网站首页windows系统优化软件排行榜
  • 造价师注册管理系统杭州网站seo
  • 广州排名seo公司大连百度网站排名优化
  • 福建网站建建设在线工具
  • 视差 长沙做网站5118关键词查询工具
  • 江门网站建设方案国际购物网站平台有哪些
  • 贸易公司做网站有优势吗公众号软文是什么意思
  • 民宿预订网站制作中国域名注册官网
  • 动态网站的建设烟台seo关键词排名
  • 烟台网站建设策划方案黑帽seo教程
  • 建设工程查询系统持续优化疫情防控举措
  • 电商网站制作流程天津百度关键词seo
  • 公司字号大全seo百度关键词优化
  • 网站 报价方案企业查询
  • 做网站源代码怎么下载百度竞价点击一次多少钱
  • 介绍好的免费网站模板下载地址网页开发教程