{"id":16540164,"url":"https://github.com/rickstaa/gazebo-torque-calculation-bug","last_synced_at":"2026-03-04T23:31:54.601Z","repository":{"id":104251837,"uuid":"432194525","full_name":"rickstaa/gazebo-torque-calculation-bug","owner":"rickstaa","description":"Small example repository that showcased a gazebo torque bug that was discussed in frankaemika/franka_ros/issues/160.","archived":false,"fork":false,"pushed_at":"2021-12-14T09:13:48.000Z","size":3838,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T03:24:23.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rickstaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-26T13:49:38.000Z","updated_at":"2021-12-09T14:11:15.000Z","dependencies_parsed_at":"2023-07-22T12:17:07.995Z","dependency_job_id":null,"html_url":"https://github.com/rickstaa/gazebo-torque-calculation-bug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rickstaa/gazebo-torque-calculation-bug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2Fgazebo-torque-calculation-bug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2Fgazebo-torque-calculation-bug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2Fgazebo-torque-calculation-bug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2Fgazebo-torque-calculation-bug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickstaa","download_url":"https://codeload.github.com/rickstaa/gazebo-torque-calculation-bug/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2Fgazebo-torque-calculation-bug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30099378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T23:31:22.529Z","status":"ssl_error","status_checked_at":"2026-03-04T23:31:22.112Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T18:51:43.352Z","updated_at":"2026-03-04T23:31:54.561Z","avatar_url":"https://github.com/rickstaa.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gazebo-torque-calculation-bug\n\nSmall example repository that showcased a Gazebo torque bug that was discussed in [frankaemika/franka_ros#160](https://github.com/frankaemika/franka_ros/issues/160#issuecomment-961780423). To summarize the [gazebo::physics::ODEJoint::GetForceTorque()](https://github.com/osrf/gazebo/blob/gazebo9/gazebo/physics/ode/ODEJoint.cc#L651-L849) calculates the wrong torque when the joint orgin is rotated.\n\n## Installation\n\nFirst make sure you have all the required dependencies installed by executing the following command:\n\n```bash\nrosdep install --from-path src --ignore-src -r -y\n```\n\nFollowing install the [catkin-tools](https://catkin-tools.readthedocs.io/en/latest/) package and build the catkin workspace in debug mode:\n\n```bash\ncatkin build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON\n```\n\nYou can ofcourse also use `catkin_make`. The `DCMAKE_EXPORT_COMPILE_COMMANDS` is only neede when you want [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) support.\n\n## Gazebo example instructions\n\nThere are three modes in which you can see the bug the first mode is when `load_several_sticks` is `false`. In this you can see the working example using the following command:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick.launch load_several_sticks:=false initial_joint_positions:='-J stick_joint1 -1.57079632679'\n```\n\nYou can then step through the simulation to see the torques in the terminal and the plot. After you inspected this version you can\nrun the following command to see the example in which the `GetForceTorque()` function calculates the wrong torque:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick.launch load_several_sticks:=false rotated:=true initial_joint_positions:='-J stick_joint1 1.57079632679'\n```\n\nAlternatively, you can see both in action when `load_several_sticks` is `true`:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick.launch load_several_sticks:=true\n```\n\nIn this:\n\n- `stick`: Is the normal working example.\n- `stick2`: Same as above but now the joint is rotated by 180 degrees.\n- `stick3`: The fliped (WRONG) example.\n- `stick4`: Same as above but now the joint is rotated by 180 degrees.\n\nThe last mode uses another launch file `stick_long.launch` to launch a 7DOF  stick. In all options you can control the stick joints using the `rqt_joint_trajectory_controller` windows.\n\n### Parameters\n\nThe script contains the following ROS parameters:\n\nThe script contains the following ROS parameters:\n\n- `log_bug_info`: Enable/disable bug console logs.\n- `sparse_bug_info`: Only show debug info for first joint.\n- `gravity_compensation`: Enable/disable gravity compensation.\n\nAll these parameters are also found as arguments on the `stick.launch` launch file.\n\n### Gravity compensation\n\nAs explained above you can enable gravity compensation using the `gravity_compensation` launch file argument:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick.launch load_several_sticks:=false load_controllers:=false\n```\n\n### Topics\n\nThe bug info that is printed to the console is also published under the `/\u003cSTICK_NAME\u003e/gazebo_bug` topic. The error is the difference between the calculated effort and gravity torque. The distinction between `error` and `error2` lies in the fact that the `error` is calculated as follows:\n\n```cpp\nauto gazebo_effort = Eigen::Vector3d(\n      gazebo_torque.X(),\n      gazebo_torque.Y(),\n      gazebo_torque.Z()\n    ).dot(urdf_axis);\n```\n\nwhere error2 uses the effort that comes from the gazebos [GetForce](https://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1physics_1_1Joint.html#aebc39094623208f497a38b91cc51f7fe) method.\n\n## Ignition Gazebo example\n\nYou can also check whether this bug is present in [ignition 6.0](https://ignitionrobotics.org/home). Use the following command to start the nominal case:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick_ignition.launch\n```\n\nTo start the bugged case use:\n\n```bash\nroslaunch gazebo_torque_calculation_bug stick_ignition.launch rotated:=true\n```\n\nAfter you started the simulation you can check the joint force and torque by using the following command:\n\n```bash\nign topic -e -n1 -t /stick_joint1/force_torque\n```\n\nIn both options you can control the stick joints using the `Joint position controller` GUI.\n\n## Bug report\n\nThe full bug report can be found [here](https://github.com/frankaemika/franka_ros/issues/160#issuecomment-961780423).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstaa%2Fgazebo-torque-calculation-bug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickstaa%2Fgazebo-torque-calculation-bug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstaa%2Fgazebo-torque-calculation-bug/lists"}