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

New heading command #955

Merged
merged 3 commits into from
Jan 4, 2023
Merged

New heading command #955

merged 3 commits into from
Jan 4, 2023

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Jan 4, 2023

Define a new command heading : cmd dir which returns the robot's current heading (or down if it doesn't have one, or if the heading is some weird vector).

My immediate motivation is that I want to be able to define excursion : cmd unit -> cmd unit which executes the given command and then returns to the same location and orientation as before. The heading command is one of the last missing pieces of machinery necessary to be able to implement this.

@byorgey byorgey marked this pull request as ready for review January 4, 2023 14:25
@byorgey byorgey requested review from xsebek and kostmo January 4, 2023 14:26
Copy link
Member

@kostmo kostmo left a comment

Choose a reason for hiding this comment

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

Makes sense.

Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@@ -104,6 +107,9 @@ instance ToJSONKey AbsoluteDir where
instance FromJSONKey AbsoluteDir where
fromJSONKey = genericFromJSONKey defaultJSONKeyOptions

-- | A relative direction is one which is defined with respect to the
Copy link
Member

Choose a reason for hiding this comment

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

I like this definition, it makes sense to have DDown relative this way. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was confused about DDown so I added these comments after I figured it out. 😄

-- for players in the vast majority of cases. We rather choose
-- to just return the direction 'down' in any case where we don't
-- otherwise have anything reasonable to return.
return $ Out (VDir (fromMaybe (DRelative DDown) $ mh >>= toDirection)) s k
Copy link
Member

Choose a reason for hiding this comment

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

Why not use maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

How would you use it, exactly?

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, I thought this was maybe (DRelative Down) toDirection mh but I see now its two Maybes. 👍

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Jan 4, 2023
@mergify mergify bot merged commit d62d8c5 into main Jan 4, 2023
@mergify mergify bot deleted the feature/heading branch January 4, 2023 19:02
mergify bot pushed a commit that referenced this pull request Jan 5, 2023
Add a new `GPS receiver` device which enables the `senseloc` capability (and hence the `whereami` command).  Towards #26 .

- My immediate motivation is that I want to be able to define `excursion : cmd unit -> cmd unit` which executes the given command and then returns to the same location and orientation as before.  Being able to use the `whereami` command is one of the last missing pieces of machinery necessary to be able to do this in classic mode (the other is a `heading` command, see #955).
- The proposed recipe for `GPS receiver` is `antenna + circuit + clock + compass`, which is a somewhat difficult recipe (`antenna` requires `silver` which requires a `deep mine`; a `clock` requires `quartz` + a bunch of `iron gears`, etc.).  One might wonder whether we should make the recipe easier since finding out where you are seems like a kind of fundamental operation.  However, consider that in order to even be able to make use of the result of `whereami` you need at least (1) an `ADT calculator` to deal with the pair (which transitively requires `typewriter` -> `circuit` -> `silicon` -> `quartz`) (2) probably things like `comparator` and `calculator` to do anything useful with the coordinates.  By the time you have those things you can definitely already build `circuit` + `clock` + `compass`, and you're probably not that far away from getting some `silver` for an `antenna`.  Also, in practice it's an interesting/fun constraint to build up machinery that has to work entirely based on *relative* position without being able to find out your absolute coordinates.
- For some reason this is causing `Testing/508-capability-subset` to fail.  I think perhaps it is due to #397 ?  I will investigate. *EDIT*: unfortunately, that wasn't it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants