![]() |
Mechanum wheel programming in C++
Has anyone programmed the mechanum wheels using C++?/
if so could you share? thanks |
Re: Mechanum wheel programming in C++
The WPI library provides the RobotDrive object that includes a method:
Code:
void RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rotation)To calculate the magnitude and direction from joystick reading, you can do: Code:
MecanumDrive_Polar(joystick->GetMagnitude(), joystick->GetDirectionDegrees(), 0.0); |
Re: Mechanum wheel programming in C++
my understand is that we need to specify each motor/wheel assembly , ie all four individually as each wheel is connected indepedently to a single motor.
so then do we use the above statements for each motor/wheel assembly? thanks have you actually written some code just to move the bot with mechanum wheels? |
Re: Mechanum wheel programming in C++
Quote:
You take the commands from the joysticks and you process them (it's called inverse kinematics) to create the 4 wheel speeds. The drive interface could be a single 3-axis joystick, or two 2-axis joysticks, or any other input device(s). Mecanum has three completely independent degrees of freedom: fore/aft strafe (right/left) rotate (turn, yaw) A mecanum vehicle can perform all three of these motions simultaneously. Here's some reference C code for you: Code:
// 3-axis joystick interface to a mecanum drive |
Re: Mechanum wheel programming in C++
Quote:
Code:
Either: |
Re: Mechanum wheel programming in C++
Quote:
Quote:
-Joe |
Re: Mechanum wheel programming in C++
so does one need only two joysticks or do you need to use 4 with two drivers. seems to me two joysticks would work. Did you find any brand or type better than another. I am looking at the Logitech Extreme 3D Pro. It has the 3 axis capability.
thanks |
Re: Mechanum wheel programming in C++
For driving mecanum, two joysticks would work. Even one would work if the joystick has at least 3 axes (e.g. X, Y and Twist). I don't have the Logitech Extreme 3D Pro, so I can't comment on it.
|
Re: Mechanum wheel programming in C++
Quote:
|
Re: Mechanum wheel programming in C++
Quote:
Did you use two joysticks? thanks John |
Re: Mechanum wheel programming in C++
Yes, It would be extremely helpful if the sample C++ Code for Mechanum Wheels is provided with a good explaination :)
Thanks |
Re: Mechanum wheel programming in C++
1 Attachment(s)
Quote:
Quote:
-Joe |
Re: Mechanum wheel programming in C++
Quote:
Thanks |
Re: Mechanum wheel programming in C++
Quote:
-Joe |
Re: Mechanum wheel programming in C++
Quote:
John |
Re: Mechanum wheel programming in C++
Ok, I am really new to C++, we are using the SimpleRobot class. can help me out by telling me what kind of a loop I put around it (MecanumDefaultCode.cpp) and some details like that. Do I need a .h file to go with it? What else do I need to add to make it work with the default sample code? by the way, does anyone know of a tutorial that explains how to use most/all of the WPI Library commands? I don't know how to use hardly any of them. this is my first year coding and all of the programmers graduated last year so I'm looking for any possible help.
|
Re: Mechanum wheel programming in C++
Most likely, you would want to put the mecanum code inside of the "while(IsOperatorControl())" loop of the OperatorControl function of the SimpleRobot class. Also, I believe the code would change slightly as the SimpleRobot template uses different variable names, and does not use pointers. (I don't have our classmate in front of me, so someone correct my code if I'm mistaken)
Code:
while(IsOperatorControl())http://firstforge.wpi.edu/sf/docman/...tation/doc1197 While I haven't looked through this very much yet, this should document most, if not all the WPILib classes with examples of using them. It is written for both Java and C++, so make sure you don't get the code mixed up. http://firstforge.wpi.edu/sf/docman/...tation/doc1196 |
Re: Mechanum wheel programming in C++
Quote:
|
Re: Mechanum wheel programming in C++
Quote:
|
Re: Mechanum wheel programming in C++
So Joe I downloaded your code and am trying to get it to build in Windriver.
Sorry but myself and the kids are just getting familiar with Windriver. I opened it but it would build. Any suggestions? thanks John Quote:
|
Re: Mechanum wheel programming in C++
Quote:
|
Re: Mechanum wheel programming in C++
Would you be able to program/run it with only a two axis joystick? My team wants to run this years bot as a CO-OP and have two joysticks with one Logictech controller for the shooter/loader system.
|
Re: Mechanum wheel programming in C++
Quote:
How are you planning to take advantage of the 3 degrees of freedom of a mec drivetrain using only one 2-axis joystick? Changing modes with a button perhaps?? WPILib has code for mecanum. |
Re: Mechanum wheel programming in C++
Quote:
Code:
[...] gyro->Reset(); float theta = gyro->GetAngle(); [...] |
Re: Mechanum wheel programming in C++
Quote:
|
Re: Mechanum wheel programming in C++
1 Attachment(s)
Our team uses SimpleRobot and here's our code for Mecanum/Omni drive using a 3 axis joystick (you may have to reverse some motors for it to work right and/or switch axis channels around)
|
| All times are GMT -5. The time now is 13:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi