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

Open-loop odometry #39

Merged
merged 4 commits into from
Jul 21, 2014
Merged

Open-loop odometry #39

merged 4 commits into from
Jul 21, 2014

Conversation

efernandez
Copy link

The purpose of this PR is to support open loop odometry when there are no encoders.
It basically adds:

  • open_loop param
  • extends Odometry class to update using the last linear and angular velocities received by the controller, i.e. set the odometry twist directly with then and integrate the position (x, y)

@@ -108,7 +108,8 @@ static bool getWheelRadius(const boost::shared_ptr<const urdf::Link>& wheel_link
namespace diff_drive_controller{

DiffDriveController::DiffDriveController()
: command_struct_()
: open_loop_(false)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better style to add new parameters at the bottom. This can help prevent ABI breaks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to put it together with other odometry related attributes in the header file.
It just happened to be before command_struct_, so I had to put it at the beginning.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem. This is not really a library anyway, so nothing builds against this API.

@efernandez
Copy link
Author

Nice refactoring @bmagyar
👍

Now we use period instead of time for the odometry integration.
@po1 What do you think?
I add @adolfo-rt to the loop.

* \param time Current time
* \return true if the odometry is actually updated
*/
void update_open_loop(double linear, double angular, const ros::Duration &period);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateOpenLoop

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
also, same as above for update()

@lucamarchionni
Copy link

Period is constant in every control loop execution.
It happens that there is jitter and using time differences in between control loop executions could be more accurate.

@adolfo-rt
Copy link

Could you provide a brief summary of the PR, to better match the code with the expectations of the PR? (and to make sure that no extra changesets made it through by mistake).

Also, please mention API additions and changes. This PR changes public interfaces, but the affected classes might be internal.

/// Current pose:
double x_; // [m]
double y_; // [m]
double heading_; // [rad]

/// Current velocity (for open loop mode):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after Bence's refactoring it's now for both open loop and closed loop

@po1
Copy link

po1 commented Jul 18, 2014

@bmagyar thanks for the refactoring, but the title of the commit is misleading, since you also changed the behavior (time -> period)

@efernandez
Copy link
Author

@adolfo-rt The purpose of this PR was originally to support open loop odometry when there are no encoders.
It basically adds:

  • open_loop param
  • extends Odometry class to update using the last linear and angular velocities received by the controller, i.e. set the odometry twist directly with then and integrate the position (x, y)

Some refactoring was done later that basically simplifies setting the odometry message and tf with the odometry values (especially the getLinear and getAngular methods).

We also changed the behaviour to use period instead of time, but that might go to another PR IMHO.
@lucamarchionni Here we're basically asking what should we use. period to filtered out the jitter (as it's constant), or time`?

@efernandez
Copy link
Author

@adolfo-rt This PR only affects internal classes. It adds updateOpenLoop method and a few attributes to the class.

@po1
Copy link

po1 commented Jul 19, 2014

It also adds a rosparam, that is external API that has to be documented.
If this is to be merged upstream, and it should be, then a unit test exercising the new feature would be welcome.

@po1 po1 changed the title adds open loop odometry Open-loop odometry Jul 19, 2014
@efernandez
Copy link
Author

@po1 I think the simple test I've added should be enough.
Could you give it a try?

@efernandez
Copy link
Author

Testing on REEM-H2.
With open_loop it's easy to see that the odometry has no noise, while in close loop it has. :)
This is normal and expected, and it's a signal that the changes are OK.
Anyway, I still have to test a little more, moving the robot, and also using close loop, to verify that there's no regression.

@efernandez
Copy link
Author

It works, both open and close loops.
@lucamarchionni @po1 @bmagyar @adolfo-rt Any other comment or something missed before merging?

@po1
Copy link

po1 commented Jul 21, 2014

all good for me

@efernandez
Copy link
Author

After talking with @lucamarchionni we have decided that it's better to use the time difference instead of the period.
I'll do and test that.

@po1
Copy link

po1 commented Jul 21, 2014

@efernandez I'd be curious to have a short summary of the motivation for reverting to time

@efernandez
Copy link
Author

I've gone back to time for the odometry computations.

I've also detected a potential bug with the timestamp_ not initialized correctly.
Therefore, I've added an init method in a separate commit.

@po1 @bmagyar Could you give it a look?
I'll test it on the robot.

@efernandez
Copy link
Author

BTW, all (8/8) unit tests passed.

@bmagyar
Copy link

bmagyar commented Jul 21, 2014

The reason for using time is that period is fixed, the theoretical update cycle of the controller, while the update function might be called with slight differences. This could potentially introduce small jitter in the controller, while another reason for not changing could be IfItAintBrokeDontFixIt.

The init function definitely makes things better, now we won't have a big bump upon the first update. This wasn't causing problems on REEM but might do on other platforms, better be safe.

@efernandez
Copy link
Author

Last changes tested on REEM-H2 robot.
Everything looks OK.

@po1 I've followed @lucamarchionni recommendation to use the time because it's more accurate, especially if the real time system doesn't really follow the period.

@bmagyar @adolfo-rt If you find it right now, I'll merge it.

@bmagyar
Copy link

bmagyar commented Jul 21, 2014

I'd squash the 2 commits about cosmetics, and rebase the rest, but the contents are fine.

@bmagyar
Copy link

bmagyar commented Jul 21, 2014

+1

@efernandez
Copy link
Author

Cosmetic changes squashed into one.

I don't feel like merging my own PR...

@po1
Copy link

po1 commented Jul 21, 2014

@bmagyar @efernandez IIRC that was exactly the motivation to use period in the first place. The jitter introduced by the controller in the odometry will be amplified in the computation of the velocities, which would be way smoother if you used the a priori knowledge about the frequency of the controller, which is period. I understand that it works that way for now, but I seem to remember that it works the other way around in our walking controller, which is far more sensible to jitter...

@efernandez I suggest you give a try to both options, especially on a system that has a very low resolution odometry, if you see what I refer to.

In the mean time, let's merge this and open more PRs if needed.

@po1
Copy link

po1 commented Jul 21, 2014

@bmagyar in the future, please don't label a commit as 'cosmetic' if it contains changes in the API (even internal) and the logic.

po1 added a commit that referenced this pull request Jul 21, 2014
@po1 po1 merged commit 077ba0b into pal-robotics-forks:hydro-devel Jul 21, 2014
@efernandez efernandez deleted the open_loop_odometry branch July 22, 2014 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants