-
Couldn't load subscription status.
- Fork 18
add openarm diagnosis #46
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
Changes from all commits
f94b690
0bd2bc2
0929ef2
eed6b5f
1a113a3
e58e50b
01a1d7a
f5df832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,181 @@ | ||||||||||
| // Copyright 2025 Enactic, Inc. | ||||||||||
| // | ||||||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| // you may not use this file except in compliance with the License. | ||||||||||
| // You may obtain a copy of the License at | ||||||||||
| // | ||||||||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| // | ||||||||||
| // Unless required by applicable law or agreed to in writing, software | ||||||||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| // See the License for the specific language governing permissions and | ||||||||||
| // limitations under the License. | ||||||||||
|
|
||||||||||
| #include <linux/can.h> | ||||||||||
| #include <linux/can/raw.h> | ||||||||||
| #include <net/if.h> | ||||||||||
| #include <string.h> | ||||||||||
| #include <sys/ioctl.h> | ||||||||||
| #include <sys/socket.h> | ||||||||||
| #include <time.h> | ||||||||||
| #include <unistd.h> | ||||||||||
|
|
||||||||||
| #include <chrono> | ||||||||||
| #include <cmath> | ||||||||||
| #include <iostream> | ||||||||||
| #include <openarm/can/socket/openarm.hpp> | ||||||||||
| #include <openarm/damiao_motor/dm_motor_constants.hpp> | ||||||||||
| #include <thread> | ||||||||||
| #include <vector> | ||||||||||
|
|
||||||||||
| // Return true if the netdev is configured for CAN-FD (MTU == CANFD_MTU), false if Classical (MTU == | ||||||||||
| // CAN_MTU) | ||||||||||
| static bool iface_is_canfd(const char* ifname) { | ||||||||||
| int s = socket(PF_CAN, SOCK_RAW, CAN_RAW); | ||||||||||
| if (s < 0) { | ||||||||||
| perror("socket"); | ||||||||||
| return false; // fall back | ||||||||||
| } | ||||||||||
| struct ifreq ifr{}; | ||||||||||
| std::strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); | ||||||||||
tokirobot marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| std::strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); | |
| std::strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); | |
| ifr.ifr_name[IFNAMSIZ - 1] = '\0'; |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motor parameter validation logic is duplicated between arm motors and gripper motors. Consider extracting this into a helper function to reduce code duplication.
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gripper CAN ID (0x18) is hardcoded and doesn't match the actual receive ID from the gripper initialization. Use the actual receive ID from the gripper motor configuration instead of the magic number.
| std::cout << "[gripper] id=0x18 -> NG (no response)\n"; | |
| missing_ids.push_back(0x18); | |
| std::cout << "[gripper] id=0x" << std::hex << gr.get_recv_can_id() << " -> NG (no response)\n"; | |
| missing_ids.push_back(gr.get_recv_can_id()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] C system headers should be included before C++ headers. Move lines 15-22 after the C++ standard library headers (lines 24-30) to follow conventional include ordering.