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

Question regarding mecanum drive plugin & feature request #2261

Closed
PerFrivik opened this issue Dec 7, 2023 · 17 comments
Closed

Question regarding mecanum drive plugin & feature request #2261

PerFrivik opened this issue Dec 7, 2023 · 17 comments
Labels
enhancement New feature or request help wanted We accept pull requests!

Comments

@PerFrivik
Copy link

Desired behavior

My question is how the current mecanum plugin works, I don't see any force control in the plugin, so I feel like the plugin is actually friction-based simulation? If that is the case, how do you manage it? When looking at the collision model, the wheels are spheres with only one joint. This can be found around 12 seconds into the video.

https://www.youtube.com/watch?v=keGh5wYqTOg

I would like to propose a feature where we can individually manage the angular velocities of each wheel, instead of just controlling the overall linear velocities in the x and y axes and the yaw velocity. This feature would allow us to directly publish commands to a topic that controls each of the four (or more) wheels separately. The primary benefit of this approach is that it enables us to handle the inverse kinematics calculations on our end, rather than relying on the existing plugin to do so.

Implementation suggestion

Add another topic to control all 4 or more wheels independently :)! The topic only needs 4 wheels, but we can map more in the URDF.

@PerFrivik PerFrivik added the enhancement New feature or request label Dec 7, 2023
@PerFrivik
Copy link
Author

@mjcarroll I was wondering if you maybe know more about this?

@azeey
Copy link
Contributor

azeey commented Dec 12, 2023

@scpeters any thoughts?

@PerFrivik
Copy link
Author

Screencast.from.15.12.2023.15.04.14.webm

Any updates? I am really confused on how this plugin works, I even swapped the spheres for cylinders and it works. But I see no forces applied to any body? Just pure wheel speeds.

@azeey
Copy link
Contributor

azeey commented Dec 15, 2023

It works using the same principle as tracked vehicles (see https://arxiv.org/pdf/1703.04316.pdf) where the desired velocity is part of the constraints on a contact point, in addition to normal force and friction. The constraint solver is asked to satisfy this desired velocity so it will apply the necessary force on the wheels. This is a much more efficient way of modelling tracked vehicles and mecanum wheels than simulating the individual wheels. At least for tracked vehicles, we've tried in the past to simulate individual wheels, and while it works, the performance drops due to the sheer number of contacts to process.

@PerFrivik
Copy link
Author

@azeey, thank you for your recent clarifications! They were really helpful. Could you please guide me to where I can find these equations in our codebase? I'd like to take a closer look.

Additionally, I wanted to come back to the feature I proposed earlier. Would you consider this feature beneficial and something you would consider merging if I implemented it? I am trying to implement a mecanum rover in PX4, but I want the controller to output the wheel speeds, that's why I would like to control the wheels directly, instead of the linear- and yaw velocity.

@PerFrivik
Copy link
Author

Any updates on this? @azeey sorry for the constant tagging, I just really need this done for a project.

@azeey
Copy link
Contributor

azeey commented Dec 20, 2023

Any updates on this? @azeey sorry for the constant tagging, I just really need this done for a project.

If you want to control the velocities of each joint, we already have the JointController system. Can you not use that? It has topics for each wheel and can be set up to use velocity or force mode. Alternatively, it can use actuator messages to control all wheels with a single topic.

@PerFrivik
Copy link
Author

Ah, so the mecanum force logic, is already built into gazebo. So if I simulate a rover and use 4 JointControllers, and use my custom mecanum inverse kinematics to control the 4 individual motors, the rover will behave like a mencaum rover even if I don't have the mecanum plugin in the sdf?

@azeey
Copy link
Contributor

azeey commented Dec 20, 2023

No, I thought you meant you'd model the wheels of a mecanum wheel. So are you asking about extending the Mecanum plugin so it accepts joint velocities as an alternative to cmd_vel, but still uses the current velocity constraint based approach to actually move the robot?

@PerFrivik
Copy link
Author

"extending the Mecanum plugin so it accepts joint velocities as an alternative to cmd_vel, but still uses the current velocity constraint based approach to actually move the robot"

This is exactly what I mean! Sorry for being unclear.

@azeey
Copy link
Contributor

azeey commented Dec 20, 2023

In that case, yes, I think we'd welcome a PR. Thanks for your patience.

@PerFrivik
Copy link
Author

Awesome! Thank you for your help :). Do you have any preference on what message type I should use for this? I think if we make something new or use something existing, we should make sure that the message type can get reused in other plugins, like differential drive, or Ackermann too. Or if required, make separate message types.

@azeey
Copy link
Contributor

azeey commented Dec 21, 2023

Would the Actuators message work? https://github.com/gazebosim/gz-msgs/blob/gz-msgs10/proto/gz/msgs/actuators.proto

@bperseghetti
Copy link
Member

Awesome! Thank you for your help :). Do you have any preference on what message type I should use for this? I think if we make something new or use something existing, we should make sure that the message type can get reused in other plugins, like differential drive, or Ackermann too. Or if required, make separate message types.

I would suggest actuators msg as that is already used across most "drive" plugins and eliminates the painful need for super specific joint/entity names otherwise.

@azeey azeey removed this from Core development Jan 8, 2024
@azeey azeey added the help wanted We accept pull requests! label Jan 8, 2024
@scpeters
Copy link
Member

Ah, so the mecanum force logic, is already built into gazebo.

Sorry I'm late to this discussion. Yes, the mecanum force logic is encoded within a given model's friction parameters:

  • //surface/friction/ode/mu
  • //surface/friction/ode/mu2
  • //surface/friction/ode/fdir
  • //surface/friction/ode/fdir/@gz:expressed_in

See examples/worlds/mecanum_drive.sdf for an example. I need to write a tutorial to explain how these parameters all work together

So if I simulate a rover and use 4 JointControllers, and use my custom mecanum inverse kinematics to control the 4 individual motors, the rover will behave like a mencaum rover even if I don't have the mecanum plugin in the sdf?

yes, this should be the case

@bperseghetti
Copy link
Member

Ah, so the mecanum force logic, is already built into gazebo.

Sorry I'm late to this discussion. Yes, the mecanum force logic is encoded within a given model's friction parameters:

  • //surface/friction/ode/mu
  • //surface/friction/ode/mu2
  • //surface/friction/ode/fdir
  • //surface/friction/ode/fdir/@gz:expressed_in

See examples/worlds/mecanum_drive.sdf for an example. I need to write a tutorial to explain how these parameters all work together

So if I simulate a rover and use 4 JointControllers, and use my custom mecanum inverse kinematics to control the 4 individual motors, the rover will behave like a mencaum rover even if I don't have the mecanum plugin in the sdf?

yes, this should be the case

This means you can just link it up from the Actuators message to control each joint.

@PerFrivik
Copy link
Author

PerFrivik commented Jan 17, 2024

Ah, so the mecanum force logic, is already built into gazebo.

Sorry I'm late to this discussion. Yes, the mecanum force logic is encoded within a given model's friction parameters:

  • //surface/friction/ode/mu
  • //surface/friction/ode/mu2
  • //surface/friction/ode/fdir
  • //surface/friction/ode/fdir/@gz:expressed_in

See examples/worlds/mecanum_drive.sdf for an example. I need to write a tutorial to explain how these parameters all work together

So if I simulate a rover and use 4 JointControllers, and use my custom mecanum inverse kinematics to control the 4 individual motors, the rover will behave like a mencaum rover even if I don't have the mecanum plugin in the sdf?

yes, this should be the case

Ohh, awesome! I was quite confused, but now it makes sense! Thank you, but then I don't need to make the PR, I can just use 4 joint controllers and leave away the mecanum plugin.

Also, yes a video would be awesome, I think it would help a lot of beginners (like me :D) and save you guys some time.

Thank you for the help guys, I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted We accept pull requests!
Projects
None yet
Development

No branches or pull requests

4 participants