private string serializeJointState(JointState js) { string topic = "\"topic\": \"/joint_states\", "; // platzhalter, topic vom RosMessage- objekt später holen // Baue Header string headerString = RosHeaderCoder_.serializeSingleHeader(js.header); // Baue Velocityarray double[] velocity = js.velocity; string velocityString = RosArrayService_.baueDoubleWertArrayUm(velocity, "\"velocity\": ", false); // Baue Effortarray double[] effort = js.effort; string effortString = RosArrayService_.baueDoubleWertArrayUm(effort, "\"effort\": ", false); // Baue Namearray string[] name = js.name; string nameString = RosArrayService_.baueStringWertArrayUm(name, "\"name\": ", false); // Baue Positionarray double[] position = js.position; string positionString = RosArrayService_.baueDoubleWertArrayUm(position, "\"position\": ", true); // Einzelteile zusammenkleben und formatiert zurückgeben return("\"{" + topic + "\"msg\": {" + headerString + velocityString + effortString + nameString + positionString + "}, \"op\": \"publish\"}\""); }
private string serializeJointTrajectory(JointTrajectory jt) { //serialisiere Topic string topic = "\"topic\": \"/preview_trajectory\", "; // platzhalter, topic vom RosMessage- objekt später holen // serialisiere header Header jtheader = jt.header; string headerString = RosHeaderCoder_.serializeSingleHeader(jtheader); //serialisiere joint_names string[] jtjoint_names = jt.joint_names; string joint_names_string = RosArrayService_.baueStringWertArrayUm(jtjoint_names, "\"joint_names\": ", false); //serialisiere JoinTrajectoryPoints JointTrajectoryPoint[] jtps = jt.points; string points_string = ""; for (int i = 0; i < jtps.Length - 2; ++i) { points_string = points_string + RosJointTrajectoryPointCoder_.serializeSingleJointTrajectoryPoint(jtps[i]) + ", "; } points_string = points_string + RosJointTrajectoryPointCoder_.serializeSingleJointTrajectoryPoint(jtps[jtps.Length - 1]); points_string = "\"points: \"[" + points_string + "]"; // Einzelteile zusammenkleben und formatiert zurückgeben return("\"{" + topic + "\"msg\": {" + headerString + joint_names_string + points_string + "}, \"op\": \"publish\"}\""); }