You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These two tools are used to configure the CAN module.
65
-
66
-
If you encounter the error `ip: command not found` while running the bash script, please install the `ip` command by running `sudo apt-get install iproute2`.
67
-
68
-
## 2 Quick Start
69
-
70
-
### 2.1 Enable CAN module
71
-
72
-
#### 2.1.1 Activate a single CAN module, **using the `can_activate.sh` script here**
73
-
74
-
##### 1) PC with only one USB-to-CAN module inserted
75
-
76
-
Simply execute the script.
77
-
78
-
```bash
79
-
bash can_activate.sh can0 1000000
80
-
```
81
-
82
-
##### 2) PC is connected to multiple USB-to-CAN modules, but only one CAN module is activated at a time
83
-
84
-
Note: This is for scenarios where both the robotic arm and the chassis are used simultaneously.
85
-
86
-
(1) Check the hardware address of the CAN module connected to the USB port.
87
-
88
-
Unplug all CAN modules, then insert only the CAN module connected to the robotic arm into the PC and execute.
89
-
90
-
```shell
91
-
sudo ethtool -i can0 | grep bus
92
-
```
93
-
94
-
And record the value of `bus-info`, for example, `1-2:1.0`.
95
-
96
-
Note: **The CAN device inserted into the USB port with the hardware address `1-2:1.0` is renamed to `can_piper`, with a baud rate of 1000000, and is activated.**
97
-
98
-
(2) Activate the CAN device
99
-
100
-
Assuming the `bus-info` value recorded from the previous operation is `1-2:1.0`, execute:
101
-
102
-
```bash
103
-
bash can_activate.sh can_piper 1000000 "1-2:1.0"
104
-
```
105
-
106
-
Note: **This means that the CAN device connected to the USB port with hardware encoding `1-2:1.0` has been renamed to `can_piper`, set to a baud rate of 1,000,000, and activated.**
107
-
108
-
(3) Check if activation was successful.
109
-
110
-
Execute `ifconfig` to check if `can_piper` appears. If it does, the CAN module has been successfully configured.
111
-
112
-
#### 2.1.2 Activate multiple CAN modules simultaneously, **using the `can_config.sh` script here**
113
-
114
-
##### 1) Unplug and plug each CAN module one by one, and record the hardware address of each module corresponding to the USB port
115
-
116
-
In the `can_config.sh` script, the `EXPECTED_CAN_COUNT` parameter represents the number of CAN modules you want to activate. For this example, let's assume it is set to 2.
117
-
118
-
(1) Then, insert one of the CAN modules into the PC alone and execute.
119
-
120
-
```shell
121
-
sudo ethtool -i can0 | grep bus
122
-
```
123
-
124
-
and record the `bus-info` value, for example, `1-2:1.0`.
125
-
126
-
(2) Next, insert the next CAN module, making sure that it **cannot** be inserted into the same USB port as the previous CAN module, and then execute.
127
-
128
-
```shell
129
-
sudo ethtool -i can1 | grep bus
130
-
```
131
-
132
-
Note: **Generally, the first inserted CAN module defaults to `can0`, and the second one to `can1`. If the CAN interfaces are not found, use `bash find_all_can_port.sh` to check the CAN names corresponding to the USB addresses.**
133
-
134
-
##### 2) Predefine the USB ports, target interface names, and their bitrates
135
-
136
-
Assuming the `bus-info` values recorded from the previous operation are `1-2:1.0` and `1-4:1.0`, the `USB_PORTS["1-9:1.0"]="can_left:1000000"` should be updated as follows:
137
-
138
-
`USB_PORTS["1-2:1.0"]="can_left:1000000"`
139
-
140
-
`USB_PORTS["1-4:1.0"]="can_right:1000000"`
141
-
142
-
Note: **The CAN device inserted into the USB port with the hardware address `1-2:1.0` is renamed to `can_left`, with a baud rate of 1000000, and is activated.**
143
-
144
-
##### 3) Check the terminal output to see if activation was successful
145
-
146
-
Execute `bash can_config.sh`.
147
-
148
-
##### 4) Check if the CAN module was successfully configured
149
-
150
-
Execute `ifconfig` to check if `can_left` and `can_right` are listed. If they appear, it means the CAN modules have been successfully configured.
151
-
152
47
## Notes
153
48
154
49
- You need to activate the CAN device and set the correct baud rate before you can read messages from or control the robot arm.
155
-
- The `C_PiperInterface` interface class accepts the name of an activated CAN interface as an argument during instantiation. This name can be obtained via `ifconfig`.
50
+
- The `C_PiperInterface` interface class accepts the name of an activated CAN interface as an argument during instantiation.
156
51
- Sometimes when executing a CAN send operation, the terminal might display `Message NOT sent`. This indicates that the CAN module has not successfully connected to the device. First, check the connection between the module and the robot arm, then power cycle the robot arm (turn it off and then on), and try sending again.
157
52
- After creating an instance, the SDK interface will check if the built-in CAN module is activated. If you are using another CAN device, you can set the second parameter to `False`, for example: `piper = C_PiperInterface("can0", False)`.
0 commit comments