rosbridge publish to /joy_node: Error Received a message without an op
I am trying to publish joystick movements to the /cmd_vel topic and the /joy_node topic from rosbridge Android. While publishing to the /cmd_vel node works perfectly fine, publishing to /joy_node fails with the Error: "Received a message without an op." over the same connection to the ROSbridge master.
My coding:
....
private float joy_axes[] = {0f, 0f, 0f, 0f, 0f, 0f};
private int joy_buttons[] = {0,0,0,0,0,0,0,0,0,0,0,0};
private int sequence_ID = 0;
private long time_stamp_sec= System.currentTimeMillis()/1000;
private long timestamp_nsec=222234283;
private long time_stamp_prev;
private String frame_id="";
private void onLoginSuccess() throws JSONException {
// we advertise the ROS topic node we want to use for the Joystick (cmd_vel supports only the analog axis movements,
// the joy node is the "real" ROS topic to publish all joystick features)
Advertise("/cmd_vel", "geometry_msgs/Twist");
Advertise("/joy_node", "sensor_msgs/Joy");
connected_to_ros =true;
connected_to_ros_message = "Connected to ROS Server: " + message;
// send a test message to /cmd_vel ***** this works
String cmdvel = "{\"op\":\"publish\",\"topic\":\"/cmd_vel\",\"msg\":{\"linear\":{\"x\":" + joy_axes[0] + ",\"y\":" + joy_axes[1] + ",\"z\":" + joy_axes[2] + "},\"angular\":{\"x\":" + joy_axes[3] + ",\"y\":" + joy_axes[4] + ",\"z\":" + joy_axes[5] + "}}}";
client.send(cmdvel);
//build the json array for the axes and buttons
JSONArray json_joy_axes= new JSONArray();
for (int i = 0; i < joy_axes.length; i++) {
json_joy_axes.put(joy_axes[i]);
}
JSONArray json_joy_buttons= new JSONArray();
for (int i = 0; i < joy_buttons.length; i++) {
json_joy_buttons.put(joy_buttons[i]);
}
//send a test message to /joy_node **** this fails
String joynode = "{\"op\":\"publish\",\"topic\":\"/joy_node\",\"msg\":{\"header\":{\"seq\": " + sequence_ID + ",\"stamp\":{\"secs\": " + time_stamp_sec + ",\"nsecs\": " + timestamp_nsec + "},\"frame_id\": " + frame_id + "},\"axes\":" + json_joy_axes +",\"buttons\":" + json_joy_buttons + "}}";
client.send(joynode);
}
I read here in this forum that rosbridge doesnt have a dedicated error handling for the parsing od json obects and that the error received indicates some problem with the json object definition. So I verified the json string in JSONlint and it appears valid and consistent with the message type definition at http://docs.ros.org/api/sensor_msgs/h...
What is wrong with my json object here? Thanks!
Not an answer, but a comment on something I noticed in your code:
cmd_vel
is a topic (not a node), and it carriesgeometry_msgs/Twist
messages. Those have no direct relationship with joysticks. They only encode a linear and angular velocity.joy
is a topic (the node is calledjoy_node
) which carriessensor_msgs/Joy
messages. Those do have a relationship with joysticks, in that they "Report the state of a joysticks axes and buttons".Joy
messages can be used to calculate values for aTwist
message, but the two are not related directly, nor do they have to be used together necessarily (in fact,Twist
is used for many purposes not even remotely related to joysticks).Yes I know. Thats why I am trying to use the /joy topic. I implemented the /cmd_vel topic only to verify that rosbridge is operational and to rule out any problems with the websocket connection.