/// <summary> /// 根据工具名称获取工具参数 /// </summary> /// <param name="strServerUrl">机械臂接口服务器地址</param> /// <param name="strToolName">工具名称</param> /// <param name="robotTool">工具参数</param> /// <returns>true成功 false失败</returns> public bool GetTool(string strServerUrl, string strToolName, out MetaData.ToolInEndDesc robotTool) { bool bfound = false; MetaData.Rpy rpy = new MetaData.Rpy(); robotTool = new MetaData.ToolInEndDesc(); string strURL = strServerUrl + "api/gettools"; string data = HttpGet(strURL); if (data != string.Empty) { try { JArray toolArray = Newtonsoft.Json.Linq.JArray.Parse(data) as JArray; foreach (JArray item in toolArray) { JObject toolJobject = Newtonsoft.Json.JsonConvert.DeserializeObject(item[0].ToString()) as JObject; if (toolJobject["tool_name"].ToString() == strToolName) { robotTool.cartPos.x = double.Parse(toolJobject["x"].ToString()); robotTool.cartPos.y = double.Parse(toolJobject["y"].ToString()); robotTool.cartPos.z = double.Parse(toolJobject["z"].ToString()); rpy.rx = double.Parse(toolJobject["rx"].ToString()); rpy.ry = double.Parse(toolJobject["ry"].ToString()); rpy.rz = double.Parse(toolJobject["rz"].ToString()); //欧拉角转四元数 rs_rpy_to_quaternion(rshd, ref rpy, ref robotTool.orientation); Console.WriteLine("tool.name=" + strToolName); Console.WriteLine("tool.pos.x=" + robotTool.cartPos.x.ToString()); Console.WriteLine("tool.pos.y=" + robotTool.cartPos.y.ToString()); Console.WriteLine("tool.pos.z=" + robotTool.cartPos.z.ToString()); Console.WriteLine("tool.ori.w=" + robotTool.orientation.w.ToString()); Console.WriteLine("tool.ori.x=" + robotTool.orientation.x.ToString()); Console.WriteLine("tool.ori.y=" + robotTool.orientation.y.ToString()); Console.WriteLine("tool.ori.z=" + robotTool.orientation.z.ToString()); bfound = true; break; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } else { Console.WriteLine("get tool error!"); } return(bfound); }
public static extern int rs_get_tool_kinematics_param(UInt16 rshd, ref MetaData.ToolInEndDesc tool);
public static extern int rs_set_tool_end_param(UInt16 rshd, ref MetaData.ToolInEndDesc tool);
public static extern int rs_base_to_base_additional_tool(UInt16 rshd, ref MetaData.Pos flange_center_pos_onbase, ref MetaData.Ori flange_center_ori_onbase, ref MetaData.ToolInEndDesc tool_pos, ref MetaData.Pos tool_end_pos_onbase, ref MetaData.Ori tool_end_ori_onbase);
public static extern int rs_user_to_base(UInt16 rshd, ref MetaData.Pos pos_onuser, ref MetaData.Ori ori_onuser, ref MetaData.CoordCalibrate user_coord, ref MetaData.ToolInEndDesc tool_pos, ref MetaData.Pos pos_onbase, ref MetaData.Ori ori_onbase);
public static extern int rs_move_joint_to(UInt16 rshd, ref MetaData.Pos target, ref MetaData.ToolInEndDesc tool, bool isblock);