gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.19k stars 480 forks source link

wrench topic prints incorrectly #2080

Closed osrf-migration closed 8 years ago

osrf-migration commented 8 years ago

Original report (archived issue) by Peter Mitrano (Bitbucket: peter_mitrano).


I'm building from source (at de341de4c4495efc4b51c3625d11674d6717a5e3), and I've just noticed that gz topic -e on a wrench gives something very weird. It looks like it's skipping the x field, and printing some pointer instead?

gz topic -e /gazebo/default/table/link/wrench 
force {
  y: 0
  z: 0
  4: 0x0000000000000000
}
torque {
  y: 0
  z: 0
  4: 0x0000000000000000
}

steps to reproduce:

  1. launch gazebo and insert any model
  2. apply a force via the gui (can be zero)
  3. gz topic -e /gazebo/default/your_model/wrench
  4. apply a force again, check the output of gz topic
osrf-migration commented 8 years ago

Original comment by Peter Mitrano (Bitbucket: peter_mitrano).


osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


It works fine on gazebo7. I wonder if it's a problem with ignition msgs?

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I'm suspicious of the difference in field numbering of the vector3d.proto between gazebo (234) and ignition msgs (123):

https://github.com/osrf/gazebo/blob/31bf145decbfe470038f0cdcd1fb68a97579b585/gazebo/msgs/vector3d.proto

syntax = "proto2";
package gazebo.msgs;

/// \ingroup gazebo_msgs
/// \interface Vector3d 
/// \brief Message for a vector3 double

message Vector3d
{
  required double x = 2;
  required double y = 3;
  required double z = 4;
}

https://bitbucket.org/ignitionrobotics/ign-msgs/src/c67f57a8e5d/ignition/msgs/vector3d.proto

package ignition.msgs;
option java_package = "com.ignition.msgs";
option java_outer_classname = "Vector3dProtos";

/// \ingroup ignition.msgs
/// \interface Vector3d 
/// \brief Message for a vector3 double

message Vector3d
{
  optional double x = 1;
  optional double y = 2;
  optional double z = 3;
}
osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Fix issue 2080

→ \<\<cset abc7695a3243874d098210a958a47343ab0060da>>

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Changing the field numbering did fix the problem. However, I'm not sure why. Gazebo doesn't use ignition messages with the wrench topic.

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


My guess is that gz topic -e has trouble distinguishing between the two messages. Maybe it's a protobuf bug?

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


I checked that. gz topic constructs messages using the "gazebo.msgs.Wrench" type via the Gazebo message factory.

I setup a test that also sent a message through the transport system, same as gz topic -e, and the message printed out correctly. I gave up at this point.

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I added the following patch to tools/gz_topic.cc:

diff -r 3884f956f1b9f46e029f1518d31eb1bdcd67efe8 tools/gz_topic.cc
--- a/tools/gz_topic.cc Fri Oct 28 14:11:58 2016 +0000
+++ b/tools/gz_topic.cc Mon Oct 31 15:34:35 2016 -0700
@@ -191,7 +191,11 @@
     return;
   }

+  std::cout << "intended type: " << msgTypeName << std::endl;
   this->echoMsg = msgs::MsgFactory::NewMsg(msgTypeName);
+  std::cout << "actual type: " << this->echoMsg->GetTypeName() << std::endl;
+  std::cout << "message descriptor: " << this->echoMsg->GetDescriptor()->DebugString()
+            << std::endl;

   if (!this->echoMsg)
   {

then I inserted a box, applied a force torque and gave an echo command:

$ gz topic -e /gazebo/default/unit_box/link/wrench
intended type: gazebo.msgs.Wrench
actual type: ignition.msgs.Wrench
message descriptor: message Wrench {
  optional .ignition.msgs.Vector3d force = 1;
  optional .ignition.msgs.Vector3d torque = 2;
  optional .ignition.msgs.Vector3d force_offset = 3;
}

somehow, it is trying to create a .gazebo.msgs.Wrench object, but it is getting an ignition one instead.

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Merged in issue_2080 (pull request #2482)

Fix issue 2080

→ \<\<cset b63d811244382e0d5510a0c8e4c672c7d20c2600>>

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


See issue #2094 for a linking issue that was discovered when resolving this issue.

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).