[go: up one dir, main page]

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

TouchSensor return zero force when used in a Joint #6563

Open
ShuffleWire opened this issue Jun 14, 2024 · 0 comments
Open

TouchSensor return zero force when used in a Joint #6563

ShuffleWire opened this issue Jun 14, 2024 · 0 comments

Comments

@ShuffleWire
Copy link
Contributor

Describe the Bug
I'm using a TouchSensor as a (3d) force sensor, which is placed at the endPoint of a Hinge. But in this configuration, it return 0.
However, if configured as a bumper, it work just fine (return 1, indicating collision).
If I use the TouchSensor at the root of the Robot, it work just fine.

Code that do not work :

Robot {
  children [
    HingeJoint {
      endPoint TouchSensor {
        children [
          Shape {
            appearance PBRAppearance {
            }
            geometry Cylinder {
            }
          }
        ]
        boundingObject Cylinder {
        }
        physics Physics {
        }
        type "force-3d"
        lookupTable []
      }
    }
  ]
  controller "my_controller"
}

Code that do work, but it's not my use-case

Robot {
  children [
    TouchSensor {
      children [
        Shape {
          appearance PBRAppearance {
          }
          geometry Cylinder {
          }
        }
      ]
      boundingObject Cylinder {
      }
      physics Physics {
      }
      type "force-3d"
      lookupTable []
    }
  ]
  controller "my_controller"
}

the value of the force is measured using this code

#include <stdlib.h>
#include <unistd.h>
#include <webots/Robot.hpp>
#include <webots/TouchSensor.hpp>

int main()
{
    auto robot = webots::Robot();
    const int timeStep{static_cast<int>(robot.getBasicTimeStep())}; /* Ms */

    webots::TouchSensor *tyreForces = robot.getTouchSensor("touch sensor");
    tyreForces->enable(timeStep);

    while (robot.step(timeStep) != -1)
    {
        const double *forceValues = tyreForces->getValues();
        printf("forceValues %f %f %f\n", forceValues[0], forceValues[1], forceValues[2]);
    }

    return 0;
}

Expected behavior
The value of the 3d force (0.000000 0.000000 61418.695377), should be always the same, whatever the setup.

System

  • Operating System: Debian 12
  • Webots 2023b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant