Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracked vehicles go backwards. #2008

Closed
rodericktaylor opened this issue Jun 8, 2023 · 13 comments
Closed

Tracked vehicles go backwards. #2008

rodericktaylor opened this issue Jun 8, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@rodericktaylor
Copy link

Environment

  • OS Version: Ubuntu 22.04
  • Source or binary build?
    Source 3bde4b5 (gz-sim7 branch on garden)

Description

  • Expected: tracked_vehicle_simple.sdf, pressing W should make the robot go forward, pressing D should make the robot turn clockwise.
  • Actual: pressing W makes the robot go backwards and pressing D makes the robot go anti-clockwise.

The TrackedVehicle plugin does not take into account that TrackController's moving in the positive direction make the part of the track that touches ground go the opposite direction.

Steps to reproduce

  1. gz sim -r tracked_vehicle_simple.sdf
  2. Press W, then press S to stop. The robot moves backwards.
  3. Press D, then press S to stop. The robot turns anti-clockwise.
@rodericktaylor rodericktaylor added the bug Something isn't working label Jun 8, 2023
@osrf-triage osrf-triage added this to Inbox in Core development Jun 8, 2023
@Bi0T1N
Copy link
Contributor

Bi0T1N commented Jun 10, 2023

I've an environment setup as written in #1662 for Fortress (@jrutgeer for Garden) and there it works as expected. W moves the robot forward and D moves it clockwise. Thus this must be a recent regression in gz-sim or DART if it is reproducible by others.

@azeey azeey moved this from Inbox to In progress in Core development Jun 12, 2023
@azeey azeey self-assigned this Jun 12, 2023
@azeey
Copy link
Contributor

azeey commented Jun 12, 2023

I was able to reproduce this. It looks like there's a sign convention mismatch between our fork of DART and upstream. @peci1 Do you recall this being the case?

@jrutgeer
Copy link
Contributor

I can confirm it is inversed in Garden + Dart 6.13, i.e. W moves as indicated in the image below.

@Bi0T1N Be aware that the 3D model is (imo) confusing: the top part is shifted to the back, which can easily be mistaken for the front:

image

It is also inversed in the conveyor demo:

image

@peci1
Copy link
Contributor

peci1 commented Jun 12, 2023

I have no idea why this is happening.

Could you compare the contents of params in

using CollectContactSurfaceProperties = gz::common::EventT<
in Fortress and Garden? I.e. to figure out whether the problem lies on Gazebo side or DART side?

@azeey
Copy link
Contributor

azeey commented Jun 13, 2023

I'm using just Garden but with DART 6.10 (fork) vs DART 6.13.0 from upstream.

Here's the print out from setting <debug>1</debug> on one of the TrackController plugins and pressing W:

With DART 6.13

[Dbg] [TrackController.cc:512] Link: left_track
[Dbg] [TrackController.cc:513] - is collision 1 track 1
[Dbg] [TrackController.cc:515] - velocity cmd         1
[Dbg] [TrackController.cc:516] - limited velocity cmd 1
[Dbg] [TrackController.cc:517] - friction direction   -1 1.5088e-11 0
[Dbg] [TrackController.cc:518] - surface motion       -1
[Dbg] [TrackController.cc:519] - contact point             2.58091
    0.247139
-0.000164322
[Dbg] [TrackController.cc:520] - contact normal       0 0 1
[Dbg] [TrackController.cc:521] - track rot            -1.66882e-08 -9.13289e-07 -1.50728e-11
[Dbg] [TrackController.cc:522] - track Y              1.5088e-11 1 -1.66882e-08
[Dbg] [TrackController.cc:523] - belt direction       -1 1.5088e-11 0

With DART 6.10 from our fork

[Dbg] [TrackController.cc:512] Link: left_track
[Dbg] [TrackController.cc:513] - is collision 1 track 1
[Dbg] [TrackController.cc:515] - velocity cmd         1
[Dbg] [TrackController.cc:516] - limited velocity cmd 1
[Dbg] [TrackController.cc:517] - friction direction   -1 -1.50255e-11 0
[Dbg] [TrackController.cc:518] - surface motion       -1
[Dbg] [TrackController.cc:519] - contact point             3.25509
    0.247139
-3.71957e-05
[Dbg] [TrackController.cc:520] - contact normal       0 0 1
[Dbg] [TrackController.cc:521] - track rot            -3.08715e-08 -1.52132e-06 1.50724e-11
[Dbg] [TrackController.cc:522] - track Y              -1.50255e-11 1 -3.08715e-08
[Dbg] [TrackController.cc:523] - belt direction       -1 -1.50255e-11 0

They look very similar to me, so I'm inclined to think it's a difference in implementation between our fork of DART and upstream.

@azeey
Copy link
Contributor

azeey commented Jun 13, 2023

I've tracked this down to the way the TangentBasisMatrix is calculated in DART. When we upstreamed our changes in dartsim/dart#1427, there was a review comment that caused us to flip the direction of the tangent. At the time, the change didn't seem to break any behavior, so we didn't think to sync our fork with the upstream version.

@peci1 Do you think we can simply negate the sign of the contactSurfaceMotionVelocity vector in gz-physics for DART versions 6.13.0 and later?

@peci1
Copy link
Contributor

peci1 commented Jun 13, 2023

Good investigation. It seems negating the velocity vector in gz-physics would be the cleanest way.

The only thing I fear is whether it will be sufficient to distinguish the fork and upstream based on the version number. I remember times where there were the same versions upstream and in the fork with different behaviors.

@Bi0T1N
Copy link
Contributor

Bi0T1N commented Jun 13, 2023

I've updated my Fortress version (still compiled against same DART PPA) to the new release from 2023-05-31 and the buttons are inverted now. I'm pretty sure this wasn't the case before (working on different robots, not the ones from the Gazebo example) but can't easily verify it...

@rodericktaylor
Copy link
Author

rodericktaylor commented Jun 20, 2023

I'm building from source. Is the fork available for me to include in my build?

In the interest of accelerating a solution, may I suggest you define something like. #define DART_HAS_POSITIVE_SURFACE_MOTION_VELOCITY 1. and negate based on #ifndef instead of checking version numbers. When or if your fork is not used, the code will still work... forever.

@jrutgeer
Copy link
Contributor

@rodericktaylor

I'm building from source. Is the fork available for me to include in my build?

Refer to #1662 (comment)

@azeey
Copy link
Contributor

azeey commented Jun 20, 2023

The only thing I fear is whether it will be sufficient to distinguish the fork and upstream based on the version number. I remember times where there were the same versions upstream and in the fork with different behaviors.

Our fork is currently at 6.10, so we can easily distinguish between the two. If we ever update our fork to be >= 6.13, we'll need to change the TangentBasisMatrix to match what's in upstream. In addition to opening an issue on our fork, we should add a test in gz-physics to make sure we don't forget.

In the interest of accelerating a solution, may I suggest you define something like. #define DART_HAS_POSITIVE_SURFACE_MOTION_VELOCITY 1. and negate based on #ifndef instead of checking version numbers. When or if your fork is not used, the code will still work... forever.

Where are you suggesting we put this #define? If we put it in our fork, and update gz-physics to check for it, I'm concerned that users that aren't following the developments in our fork will have a silent change of behavior. We already make assumptions that >=6.13 is upstream, so I think fixing it that way is our best option. /cc @scpeters

@rodericktaylor
Copy link
Author

rodericktaylor commented Jan 15, 2024

This looks like it is fixed in the harmonic release when compiled from source with DART 6.13. Ta heaps!

@azeey
Copy link
Contributor

azeey commented Jan 16, 2024

Yes, I closed #1662, but forgot to close this.

@azeey azeey closed this as completed Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Core development
In progress
Development

Successfully merging a pull request may close this issue.

5 participants