Skip to content

Conversation

@felixvd
Copy link
Contributor

@felixvd felixvd commented Nov 12, 2020

With Ubuntu 20.04 and Noetic, Python 3.8 has become the default. The circle constant tau = C/r = 2*pi has been added to the Python math module in 3.6.

I don't want to open the whole debate here - this page and this video should summarize the arguments well enough. In short, it is an extremely useful representation for robotics, because we constantly write rotations using radians, and using tau saves mental operations. Although rotating around an axis is not difficult to do, chaining rotations in your head is confusing enough that Robert made this helper tool and I keep using this one. Something as seemingly simple as multiplying by (or was it dividing by?) 2 to describe a rotation is similarly "not difficult, but still confusing". We should not have unnecessary confusions in our way.

The natural way we think of rotations is in full turns. Just consider this part of the tutorial where we define joint angles. Try to imagine the configuration of this robot in your head*:

joint_goal[0] = 0
joint_goal[1] = -pi/4
joint_goal[2] = 0
joint_goal[3] = -pi/2
joint_goal[4] = 0
joint_goal[5] = pi/3
joint_goal[6] = 0

Now try to do it with this description, remembering that one tau is one turn, as per this outrageously simple diagram:

image

joint_goal[0] = 0
joint_goal[1] = -tau/8
joint_goal[2] = 0
joint_goal[3] = -tau/4
joint_goal[4] = 0
joint_goal[5] = tau/6
joint_goal[6] = 0

Did converting the angles in your head give you the slightest bit of pause? Likely not much, since as I said, it isn't difficult. But that's because dealing with these numbers all the time is literally our job. It is much more cumbersome for anyone who starts out, and this layer of obfuscation serves no use.

I am convinced that using "1 turn" as the unit for rotations makes writing rotations in radians a ton easier. I have started using it myself and have no idea why I hadn't done so earlier. It is just the weight of convention**.

Converting is trivial, as this affects only 3 files, and there is no need to change anything in the main code base. This is just introducing a useful shorthand in our educational materials, for users who would benefit from seeing it. There is precedent for saying "I'm just going to do this" in
this somewhat amusing discussion of the issue. I think we should follow this example.

This works on Python 2.7 since I guarded the Python include, so it can be backported to Melodic and Kinetic.

Pinging @tylerjw and @DLu since they've been working on the tutorials.

* I know robot configurations are already hard to imagine because the axes inconveniently switch signs, but you get the point.
** Actually I was expressing all rotations in degrees because it was so annoying to do the conversion in my head.

edit: This issue is a little controversial, so if you could add a reaction to this post (:+1: , :confused: or :-1:) on this post, that will be helpful.

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Nov 12, 2020

This is not a nay on your proposal, but I typically just use math.radians(some_value_in_degrees).

Also has the benefit to give some sort of indication of what units the value your assigning there has.

@felixvd
Copy link
Contributor Author

felixvd commented Nov 12, 2020

That came up on the Discord, too. My response:

  • There's no equivalent to math.radians in C++; defining a custom function is icky and non-standard
  • Using tau works the same way in C++ and Python
  • tau works in xacro files from Noetic

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Nov 12, 2020

Using tau works the same way in C++ and Python

Where is tau defined as a C++ constant? I can't find it.

Personally, I'd rather we start using something like nholthaus/units or bernedom/SI.

tau works in xacro files from Noetic

I guess because of the updated Python? There's nothing special in xacro for this afaik.

@felixvd
Copy link
Contributor Author

felixvd commented Nov 12, 2020

Where is tau defined as a C++ constant? I can't find it.

For the moment only at the top of the two changed files :) But if Python can do it, so can C++.

tau works in xacro files from Noetic

I guess because of the updated Python? There's nothing special in xacro for this afaik.

Yes. The Python update made this possible in a whole chunk of the ecosystem, which is another reason why I think it's worth teaching. A custom deg2rad function or C++ header won't work in xacro.

@gavanderhoorn
Copy link
Member

A custom deg2rad function or C++ header won't work in xacro.

It would also not be needed. There's radians(..) in xacro. It's built-in.

@felixvd
Copy link
Contributor Author

felixvd commented Nov 13, 2020

There's radians(..) in xacro. It's built-in.

Much like the real circle constant tau :) I'm happy to add the example to the help page.

It seems like Travis is failing independently of this PR due to a Ruby issue, by the way.

@AndyZe
Copy link
Member

AndyZe commented Nov 19, 2020

Not a huge fan of this. I don't think the tutorial is a good place to introduce a new variable that's not even MoveIt-related

@felixvd
Copy link
Contributor Author

felixvd commented Nov 20, 2020

I consider it useful for MoveIt users, since they will specify rotations in their code. We already point out helpful patterns to new users in other sections of the tutorials, like here or here.

The change is very limited in scope and won't negatively impact understanding. In the best case, a reader will go "Oh that's convenient" and have learned something. Worst case they will go "ok some angles, whatever" and proceed as they normally would have. It is as unobtrusive as it gets:

Before:
tutorial_pi

After:
tutorial_tau

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

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

In general I approve. You wasted half my day by pointing me to \tau, @felixvd. well... sigh
This can be quite useful for roboticists, so they might get to hear about it in a tutorial.

I do see @gavanderhoorn's arguments to use deg2rad methods.
They are useful and I guess especially relevant for engineers and fresh students (I've had to explain radians to a lot of students in terms of degrees over the years...).
In the context of this tutorial I personally prefer \tau though (of course also for its touch of nerdiness). But it also raises awareness for the radian unit in the messages. You can obviously specify radian(45), but it does give you an excuse not to look into what 0.78539... actually means. Whereas you definitely start thinking about it when pi or tau is involved.

Please resolve the conflict @felixvd .

Tau is the circle constant C/r (diameter over radius) = 2*pi = tau. This makes writing rotations easier.

See https://tauday.com/tau-manifesto for more reasoning.
@felixvd
Copy link
Contributor Author

felixvd commented Mar 3, 2021

In general I approve. You wasted half my day by pointing me to \tau, @felixvd. well... sigh

You're welcome 😎

This can be quite useful for roboticists, so they might get to hear about it in a tutorial.

I have used it in multiple projects and attest to the usefulness. It is like removing a pebble from your shoe you didn't know was there. All the arguments you mention are correct.

Please resolve the conflict @felixvd .

I rebased and added one line-end comment like this to each file as a pedagogical measure / mnemonic aid:

joint_goal[1] = -tau/8 # 1/8 of a turn

@v4hn
Copy link
Contributor

v4hn commented Mar 3, 2021 via email

@gavanderhoorn
Copy link
Member

I'm still not a big fan of this, for all the previously mentioned reasons, but I'm just one voice here and I also don't care enough to prevent this from getting merged.

From a didactic point of view I find it strange to introduce a new concept for something so fundamental in a tutorial which deals with completely different aspects of MoveIt, while conversion methods to-from radians and degrees are readily available and are used almost everywhere.

But again: please merge if the consensus is there.

@felixvd
Copy link
Contributor Author

felixvd commented Mar 4, 2021

From a didactic point of view I find it strange to introduce a new concept for something so fundamental in a tutorial which deals with completely different aspects of MoveIt, while conversion methods to-from radians and degrees are readily available and are used almost everywhere.

My first reaction was "MoveIt doesn't reach people in 6th grade, so...", my second was "The amount of 'basic' things that confuse university students and graduates is off the charts, and there are high school students in robotics clubs reading these tutorials", and my third was "We're just using it, not holding a lecture on it". I don't know which to choose, but I know that this is a useful conceptual tool that readers are unlikely to know about, so I think it has a place in a tutorial.

Since you mentioned that conversion methods are used almost everywhere (a testament to pi's unwieldiness, imo), I had a look through our tutorials but couldn't find them in there. However, I found a raw radian usage that I took the liberty of converting.

joint_goal[1] = -tau/8 # 1/8 of a turn
If you think such comments are helpful, at least keep the sign. :)

I moved the comment to a positive value to avoid confusion. I think they might be helpful for certain readers at this stage.

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

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

It's a matter of ideology I guess.
I approve this proposal as-is.

Either way it's good to streamline radian specifications in the tutorials.
I was very surprised to see 90.0/180.0*M_PI in the tutorial code.

@davetcoleman
Copy link
Member

This is a pretty great thread. "You wasted half my day" lol!

@henningkayser
Copy link
Member

I agree that tau is a much better alternative to pi, even if pi is probably more commonly used and known across the board. +1 from me to get this merged as is.

Copy link
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

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

After reviewing further, seems good to me.

@v4hn v4hn merged commit 73e7226 into moveit:master Mar 10, 2021
Abishalini pushed a commit to Abishalini/moveit_tutorials that referenced this pull request Apr 29, 2021
Tau is the circle constant C/r (diameter over radius) = 2*pi = tau. This makes writing rotations easier.

See https://tauday.com/tau-manifesto for more reasoning.

* Add more explicit comments

* Add clearer radian definition in MGI C++ tutorial

Co-authored-by: v4hn <me@v4hn.de>
@felixvd felixvd mentioned this pull request May 2, 2021
5 tasks
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.

6 participants