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

[RSDK-1008] Support GPIO pins in the Jetson Orin AGX #1759

Closed
wants to merge 5 commits into from

Conversation

penguinland
Copy link
Member

The important line is the last line of go.mod, which references https://github.com/viamrobotics/periphio_host/pull/1. All the other changes to go.mod and go.sum were automatically created from running a go get command that the compiler prompted me to do.

Tried at my desk: GPIO pins still work on Raspberry Pi, and work for the first time on a Jetson Orin AGX!

@penguinland penguinland changed the title Support GPIO pins in the Jetson Orin AGX [RSDK-1008] Support GPIO pins in the Jetson Orin AGX Jan 11, 2023
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 11, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 11, 2023
@penguinland
Copy link
Member Author

Ugh. The linter isn't happy because it wants to disallow all replacements in go.mod. Any thoughts on what to do? Some possibilities:

  1. I could go back to adding the extra features periph.io wanted and get something committed upstream, and then just update the minimum version that we depend on.
  2. Maybe I could replace all mentions of periph's libraries with our version? but then going back to the old one if periph gets updated sounds annoying
  3. Is there a way to mark a single line to be excluded from a single linting rule? and even if there is, should I use it here? Part of me says "no" to that second question.

Copy link
Member

@randhid randhid left a comment

Choose a reason for hiding this comment

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

One ask - can you test on a beagle?

@randhid
Copy link
Member

randhid commented Jan 11, 2023

Ugh. The linter isn't happy because it wants to disallow all replacements in go.mod. Any thoughts on what to do? Some possibilities:

1. I could go back to adding the extra features periph.io wanted and get something committed upstream, and then just update the minimum version that we depend on.

2. Maybe I could replace all mentions of periph's libraries with our version? but then going back to the old one if periph gets updated sounds annoying

3. Is there a way to mark a single line to be excluded from a single linting rule? and even if there is, should I use it here? Part of me says "no" to that second question.

@edaniels @Otterverse what should he do here?

Base library we use for other boards is missing a lot of functionality, we'd want to use our own fork of it, Alan has the functionality fixed on there.

If we want to fix inside rdk, would need more thought and this is blocking Orin usage currently which consulting engineers want. He's going to add a ticket for more long-term adds to periph.io, which I think it the way to go.

@edaniels
Copy link
Member

Replace will not work. Replace is not transitive to other modules. For example, if someone were to import RDK, the replace wouldn't take effect. The end user would also have to go mod replace.

We should make a PR against periph.

@penguinland
Copy link
Member Author

We should make a PR against periph.

I made one at periph/host#27, but it doesn't support pinmuxing. Periph doesn't want to merge without that, and I had hoped that because Viam is not using pinmuxing I was unblocked enough that I could get back to working on our code, and Periph could do pinmux stuff themselves if they wanted. Eric, it sounds like you'd prefer that I work on Periph's requests some more, yeah?

For background: Periph currently does not support any GPIO pins on the Jetson Orin board, so an end user importing the RDK and using Periph's library would be unable to use any GPIO features on an Orin (but would still be able to seamlessly work on a non-Orin board: our changes didn't modify that behavior at all).

@penguinland
Copy link
Member Author

One ask - can you test on a beagle?

I tried the appimage on a fresh beaglebone: was able to toggle a GPIO pin high and low through app.viam.com, and verified with a multimeter that it did the expected thing.

@penguinland
Copy link
Member Author

Eric, how would you feel if we imported "github.com/viamrobotics/host/v3" in our code instead of "periph.io/host/v3", with a comment about switching back if Periph ever adds support for the Jetson Orin? That's, like, a 5-line change that doesn't depend on a third party.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 13, 2023
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 56% 0.00%
go.viam.com/rdk/components/arm/universalrobots 41% 0.00%
go.viam.com/rdk/components/arm/xarm 2% 0.00%
go.viam.com/rdk/components/arm/yahboom 7% 0.00%
go.viam.com/rdk/components/audioinput 55% +0.34%
go.viam.com/rdk/components/base 63% 0.00%
go.viam.com/rdk/components/base/agilex 62% 0.00%
go.viam.com/rdk/components/base/boat 41% 0.00%
go.viam.com/rdk/components/base/wheeled 76% 0.00%
go.viam.com/rdk/components/board 68% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/commonsysfs 47% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 65% 0.00%
go.viam.com/rdk/components/camera/align 63% 0.00%
go.viam.com/rdk/components/camera/fake 67% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 77% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 78% 0.00%
go.viam.com/rdk/components/camera/videosource 50% 0.00%
go.viam.com/rdk/components/encoder 4% 0.00%
go.viam.com/rdk/components/encoder/fake 76% 0.00%
go.viam.com/rdk/components/gantry 60% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 84% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 86% 0.00%
go.viam.com/rdk/components/generic 83% 0.00%
go.viam.com/rdk/components/gripper 68% 0.00%
go.viam.com/rdk/components/input 87% 0.00%
go.viam.com/rdk/components/input/gpio 84% 0.00%
go.viam.com/rdk/components/motor 77% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 63% 0.00%
go.viam.com/rdk/components/motor/dmc4000 69% 0.00%
go.viam.com/rdk/components/motor/fake 57% 0.00%
go.viam.com/rdk/components/motor/gpio 64% 0.00%
go.viam.com/rdk/components/motor/gpiostepper 56% 0.00%
go.viam.com/rdk/components/motor/tmcstepper 62% 0.00%
go.viam.com/rdk/components/movementsensor 75% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 40% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 36% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 28% 0.00%
go.viam.com/rdk/components/posetracker 86% 0.00%
go.viam.com/rdk/components/sensor 86% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 32% 0.00%
go.viam.com/rdk/components/servo 68% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 76% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 79% 0.00%
go.viam.com/rdk/examples/customresources/demos/complexmodule 0% 0.00%
go.viam.com/rdk/examples/customresources/demos/remoteserver 0% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 70% 0.00%
go.viam.com/rdk/module 63% 0.00%
go.viam.com/rdk/module/modmanager 79% 0.00%
go.viam.com/rdk/motionplan 59% -11.44%
go.viam.com/rdk/octree 98% 0.00%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 72% -0.09%
go.viam.com/rdk/protoutils 59% 0.00%
go.viam.com/rdk/referenceframe 71% 0.00%
go.viam.com/rdk/registry 89% 0.00%
go.viam.com/rdk/resource 84% 0.00%
go.viam.com/rdk/rimage 78% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 73% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 85% 0.00%
go.viam.com/rdk/robot/client 81% 0.00%
go.viam.com/rdk/robot/framesystem 65% 0.00%
go.viam.com/rdk/robot/impl 80% 0.00%
go.viam.com/rdk/robot/server 55% 0.00%
go.viam.com/rdk/robot/web 62% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/armremotecontrol 71% 0.00%
go.viam.com/rdk/services/armremotecontrol/builtin 52% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 79% 0.00%
go.viam.com/rdk/services/datamanager 79% 0.00%
go.viam.com/rdk/services/datamanager/builtin 78% 0.00%
go.viam.com/rdk/services/datamanager/datacapture 70% 0.00%
go.viam.com/rdk/services/datamanager/datasync 0% 0.00%
go.viam.com/rdk/services/motion 63% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 53% 0.00%
go.viam.com/rdk/services/sensors 77% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 14% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 73% 0.00%
go.viam.com/rdk/services/vision 80% 0.00%
go.viam.com/rdk/services/vision/builtin 74% 0.00%
go.viam.com/rdk/session 97% 0.00%
go.viam.com/rdk/spatialmath 86% 0.00%
go.viam.com/rdk/subtype 92% 0.00%
go.viam.com/rdk/utils 72% 0.00%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 25% 0.00%
Summary 65% (20892 / 32217) -0.70%

@edaniels
Copy link
Member

Eric, how would you feel if we imported "github.com/viamrobotics/host/v3" in our code instead of "periph.io/host/v3", with a comment about switching back if Periph ever adds support for the Jetson Orin? That's, like, a 5-line change that doesn't depend on a third party.

If that works fine, that's okay. We should slowly get our change into periph though. Also need to file a JIRA and have a TODO)(JIRA-XXX) in the go.mod to move back

@penguinland
Copy link
Member Author

Sigh. I don't seem to be able to do this without a replace directive: periph has several different repos that all depend on each other, and even if we replace all of our imports with the forked version, we import things like periph.io/x/conn/v3, and that imports periph.io/x/host/v3, which does not have our changes, and leads to the same problems as before.

I still think a replace directive would do the right thing here: our code would work, and anyone who wants to import both our code and the original periph version would have broken functionality, but they currently have broken functionality, too, and that's not going to change any time soon. but I recognize that making an exception to the linter just for this leads to a slippery slope, and maybe we should continue to disallow all replace directives.

I think I need to give up on this PR, give up on periph for the Jetson Orin's GPIO pins entirely, and write our own version. 😖 I'm leaving the PR open in case someone disagrees, but will likely close it by tomorrow unless anyone has a better plan.

@randhid
Copy link
Member

randhid commented Jan 17, 2023

Let's just port over that functionality into jetson/board.go and close this. We'll handle jetson gpio pins ourselves then.

@Otterverse
Copy link
Member

Let's just port over that functionality into jetson/board.go and close this. We'll handle jetson gpio pins ourselves then.

@penguinland and I discussed this last week (at least in part.) Periph.io is using the old "sysfs" interface anyway. The kernel developers have giant all caps warnings about it being deprecated and how it shouldn't be used. So the "right" way to do things would be the newer (kernel 4.8+, so not THAT new) character device interface. So I'd vote for implementing that properly and maybe drop our periph.io dependency entirely.

Quick look found some other go libraries using the new cdev interface: https://github.com/temoto/gpio-cdev-go or https://github.com/warthog618/gpiod and there are probably others.

@edaniels
Copy link
Member

sgtm

@penguinland penguinland deleted the orin_gpio branch February 7, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
5 participants