Skip to content

Commit e0513e1

Browse files
committed
add_post_servo_params
1 parent 564f5c8 commit e0513e1

8 files changed

Lines changed: 281 additions & 0 deletions

File tree

_data/wiki/wiki.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
url: "/posts/erpm-gain-calibration/"
5757

5858
- title: "How to find Servo parameter"
59+
url: "/posts/servo-parameter/"
5960

6061
- title: "base_link 기준 sensor TF 설정하기"
6162
url: "/posts/base-link-sensor-tf/"
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: How to Find VESC Servo Parameters
3+
author: hyeongjoon-yang
4+
date: 2026-02-03 21:00:00 +0900
5+
categories: [build, beginner]
6+
tags: [gain, servo, vesc]
7+
image:
8+
path: /assets/img/posts/servo-parameter/servo-output.png
9+
lang: en
10+
lang_ref: servo-parameter
11+
math: true
12+
---
13+
14+
In autonomous driving, precise steering control directly affects path following performance. If the conversion between steering commands and actual wheel angles is inaccurate, the vehicle cannot follow the intended path and may result in path deviation or accidents. This post covers the concept and characteristics of Servo Parameters and how to calibrate them through experiments.
15+
16+
## What is Servo Parameter?
17+
18+
In the VESC ROS package, steering commands are input as steering angles in radians and converted to values between 0 and 1 that the servo understands. This conversion relationship can be represented by gain and offset as follows:
19+
20+
```
21+
servo_value = steering_angle_to_servo_gain × steering_angle + steering_angle_to_servo_offset
22+
```
23+
24+
- **steering_angle**: Steering angle input by the user (radians)
25+
- **servo_value**: Command delivered to the servo (0 ~ 1)
26+
- **steering_angle_to_servo_gain**: Proportional constant for converting steering angle to servo value
27+
- **steering_angle_to_servo_offset**: Servo value at straight-ahead position (steering angle 0)
28+
29+
## Theoretical Measurement of Servo Parameters
30+
31+
For ERPM gain, hardware specifications such as gear ratio, pole pairs, and wheel radius are multiplied linearly, so it can be calculated mathematically.
32+
33+
On the other hand, Servo Parameters are difficult to measure theoretically. To understand why, you need to know the structure of RC car steering systems.
34+
35+
### What is Ackermann Steering Geometry?
36+
37+
When a vehicle turns, the two front wheels are positioned at different distances from the center of rotation. The inner wheel is closer to the center of rotation, and the outer wheel is farther away.
38+
39+
Wheels can only roll purely in a direction perpendicular to their axis. If both front wheels turn at the same steering angle, the extensions of the two wheel axes become parallel, resulting in different turning radii for each wheel and slip occurring.
40+
41+
To prevent this, the inner wheel must turn more and the outer wheel less so that the extensions of both wheel axes meet at the same center of rotation. This geometric condition is called **Ackermann Steering Geometry**.
42+
43+
![Ackermann Steering Geometry](/assets/img/posts/servo-parameter/ackermann-geometry.png)
44+
_Ackermann Steering Geometry_
45+
46+
### Nonlinearity of Bellcrank System
47+
48+
In RC cars, Ackermann Steering Geometry is approximately implemented through bellcrank systems, tie rods, and knuckle arms. Due to this complex kinematic structure, the relationship between servo angle and actual wheel steering angle is **nonlinear**.
49+
50+
| ![Traxxas Bellcrank](/assets/img/posts/servo-parameter/traxxas-bellcrank.png) | ![Traxxas Ackermann](/assets/img/posts/servo-parameter/traxxas-ackermann.png) |
51+
|:---:|:---:|
52+
| Traxxas Fiesta Steering System (Bellcrank) | Traxxas Fiesta Ackermann Steering Geometry |
53+
54+
In other words, the `steering_angle_to_servo_gain` we set is actually a linear approximation that works well around the center (straight ahead) but may have errors near maximum steering angles. Therefore, it's common to calibrate Servo Parameters experimentally for the range you frequently use rather than through theoretical calculations.
55+
56+
## Characteristics of Servo Parameters
57+
58+
### Servo Range Based on Hardware
59+
60+
While the servo receives commands between 0 and 1, depending on hardware specifications, steering commands (radians) may use the entire range or only a portion of it.
61+
62+
### Nonlinearity and Calibration Range
63+
64+
Due to the bellcrank linkage structure, the relationship between servo value and actual wheel steering angle is nonlinear. Therefore, it doesn't map accurately to the required turning radius at all steering angles. For this reason, it's recommended to map servo gain within the steering angle range you frequently use.
65+
66+
For example, if most steering in F1tenth driving occurs within ±0.25 radians (approximately ±14 degrees), it's effective to match accuracy within that range. Extreme steering angles are only used in low-speed emergency situations, so slight errors are acceptable.
67+
68+
### Importance of Servo Horn Initial Position
69+
70+
When applying servo gain and offset, care must be taken to ensure that maximum steering commands don't constrain only one direction (left or right). In other words, even with maximum steering commands, servo commands must always be between 0 and 1.
71+
72+
For this purpose, it's important to position the servo horn initial position well at the center of the operating range. When the servo horn is properly installed, the offset is measured close to 0.5.
73+
74+
## Finding Servo Parameters Experimentally
75+
76+
### Finding Offset (Straight Alignment)
77+
78+
The offset is the servo value when the steering angle is 0. You just need to find the servo value when the wheels point exactly straight ahead.
79+
80+
### Measurement Procedure
81+
82+
1. To minimize the effects of tire friction or floor texture, use the joystick to give left and right steering commands before measurement so the servo motor is well positioned at center.
83+
2. Start slowly to avoid tire slipping and drive straight.
84+
3. Observe the direction the vehicle is traveling to check if it goes straight without drifting left or right.
85+
4. If it doesn't go straight, adjust the offset value slightly and repeat.
86+
5. Set the value when the vehicle goes exactly straight as `steering_angle_to_servo_offset`.
87+
88+
> If the servo horn is properly installed, the offset will be near 0.5. If it deviates significantly from 0.5, it's recommended to remove and reinstall the servo horn to center it.
89+
{: .prompt-tip }
90+
91+
### Finding Gain
92+
93+
Gain is the ratio of servo value change to steering angle change. Measure the turning radius through accumulated odometry in rviz and tune the gain using the Ackermann formula.
94+
95+
### Ackermann Turning Radius Formula
96+
97+
In Ackermann steering geometry, the relationship between steering angle and turning radius is as follows. The wheelbase is the distance between the front and rear axles, which can be measured directly with a ruler or referenced from manufacturer information.
98+
99+
$$
100+
turning\_radius = \frac{wheelbase}{\tan(steering\_angle)}
101+
$$
102+
103+
Calculate the expected turning radius from the commanded steering angle and adjust the gain by comparing it with the actual measured turning radius.
104+
105+
![Rviz Turning Radius Measurement](/assets/img/posts/servo-parameter/rviz-turning-radius.png)
106+
_Measuring turning radius using Rviz_
107+
108+
### Measurement Procedure
109+
110+
1. Start with odometry visualization available in rviz.
111+
2. Drive in a circle at low speed without slip while giving a constant steering angle command (e.g., 0.2 rad).
112+
3. When the accumulated odometry trajectory in rviz forms a circle, use the Measure function to measure the circle's diameter and obtain the turning radius (R).
113+
4. Compare the expected turning radius calculated from the commanded steering angle with the actual turning radius and adjust the gain.
114+
115+
### Calculation Example (Based on Traxxas Fiesta)
116+
117+
| Item | Value |
118+
|------|-------|
119+
| Wheelbase | 0.33m |
120+
| Commanded steering angle | 0.2 rad |
121+
| Expected turning radius | 0.33 / tan(0.2) ≈ 1.62m |
122+
| Actually measured turning radius | 1.8m |
123+
124+
In this case, since the actual (1.8m) is larger than expected (1.62m), it means the actual steering angle is smaller than commanded. Therefore, the absolute value of gain should be increased.
125+
126+
### Correction Method
127+
128+
| Situation | Action |
129+
|-----------|--------|
130+
| Actual turning radius > Expected turning radius | Increase the absolute value of gain |
131+
| Actual turning radius < Expected turning radius | Decrease the absolute value of gain |
132+
133+
### Precautions
134+
135+
- Test multiple points within the frequently used steering angle range (e.g., ±0.25 rad) to find a gain that works well overall.
136+
- When measuring, drive at sufficiently low speed to avoid slip to obtain an accurate turning radius.
137+
138+
## Conclusion
139+
140+
Servo Parameters must be measured experimentally, but since the values don't change unless the hardware is modified, you only need to measure them accurately once. It's recommended to take time for precise calibration. These parameters map the user's intended steering angle to be accurately transmitted to the vehicle, so be careful not to manipulate them arbitrarily after calibration.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: VESC Servo Parameter 찾는 방법
3+
author: hyeongjoon-yang
4+
date: 2026-02-03 21:00:00 +0900
5+
categories: [build, beginner]
6+
tags: [gain, servo, vesc]
7+
image:
8+
path: /assets/img/posts/servo-parameter/servo-output.png
9+
lang: ko
10+
lang_ref: servo-parameter
11+
math: true
12+
---
13+
14+
자율 주행에서 정확한 조향 제어는 경로 추종 성능에 직접적인 영향을 미칩니다. 조향 명령과 실제 바퀴 각도 사이의 변환이 정확하지 않으면, 차량은 의도한 경로를 따라가지 못하고 경로 이탈이나 사고로 이어질 수 있습니다. 본 포스트에서는 Servo Parameter의 개념과 특성, 그리고 실험을 통한 캘리브레이션 방법을 정리합니다.
15+
16+
## Servo Parameter란?
17+
18+
VESC ROS 패키지에서 조향 명령은 라디안 단위의 조향각으로 입력되며, 이를 서보가 이해하는 0에서 1 사이의 값으로 변환하여 전달합니다. 이 변환 관계는 다음과 같이 gain과 offset으로 나타낼 수 있습니다.
19+
20+
```
21+
servo_value = steering_angle_to_servo_gain × steering_angle + steering_angle_to_servo_offset
22+
```
23+
24+
- **steering_angle**: 사용자가 입력하는 조향각 (라디안)
25+
- **servo_value**: 서보에 전달되는 명령 (0 ~ 1)
26+
- **steering_angle_to_servo_gain**: 조향각을 서보 값으로 변환하는 비례상수
27+
- **steering_angle_to_servo_offset**: 직진 상태(조향각 0)에서의 서보 값
28+
29+
## Servo Parameter의 이론적 측정
30+
31+
ERPM gain의 경우, 기어비, 극 쌍수, 바퀴 반지름 등의 하드웨어 스펙이 선형적으로 곱해지기 때문에 수학적으로 깔끔하게 계산할 수 있습니다.
32+
33+
반면, Servo Parameter는 이론적으로 측정하기 어렵습니다. 그 이유를 이해하기 위해서는 RC카의 조향 시스템 구조를 알아야 합니다.
34+
35+
### Ackermann Steering Geometry란?
36+
37+
차량이 회전할 때, 앞바퀴 두 개는 회전 중심으로부터 서로 다른 거리에 위치합니다. 내측 바퀴는 회전 중심에 가깝고, 외측 바퀴는 멀습니다.
38+
39+
바퀴는 축에 수직인 방향으로만 순수하게 굴러갈 수 있습니다. 만약 두 앞바퀴가 같은 조향각으로 꺾이면, 두 바퀴 축의 연장선이 서로 평행해지고, 각 바퀴의 회전 반경이 달라지며 옆으로 끌려가는 슬립이 발생합니다.
40+
41+
이를 방지하기 위해, 두 바퀴 축의 연장선이 동일한 회전 중심에서 만나도록 내측 바퀴는 더 크게, 외측 바퀴는 더 작게 꺾어야 합니다. 이러한 기하학적 조건을 **Ackermann Steering Geometry**라고 합니다.
42+
43+
![Ackermann Steering Geometry](/assets/img/posts/servo-parameter/ackermann-geometry.png)
44+
_Ackermann Steering Geometry_
45+
46+
### Bellcrank 시스템의 비선형성
47+
48+
RC카에서는 bellcrank 시스템과 타이로드, 너클 암 등의 링키지를 통해 Ackermann Steering Geometry를 근사적으로 구현합니다. 이 복잡한 기구학적 구조로 인해, 서보 각도와 실제 바퀴 조향각 사이의 관계는 **비선형**입니다.
49+
50+
| ![Traxxas Bellcrank](/assets/img/posts/servo-parameter/traxxas-bellcrank.png) | ![Traxxas Ackermann](/assets/img/posts/servo-parameter/traxxas-ackermann.png) |
51+
|:---:|:---:|
52+
| Traxxas Fiesta의 조향 시스템 (Bellcrank) | Traxxas Fiesta의 Ackermann Steering Geometry |
53+
54+
즉, 우리가 설정하는 `steering_angle_to_servo_gain`은 사실 선형 근사이며, 중앙(직진) 부근에서는 잘 맞지만 최대 조향각 부근에서는 오차가 발생할 수 있습니다. 따라서 Servo Parameter는 이론적 계산보다 실험을 통해 자주 사용하는 범위에 맞게 캘리브레이션하는 것이 일반적입니다.
55+
56+
## Servo Parameter의 특성
57+
58+
### 하드웨어에 따른 서보 범위
59+
60+
서보는 0에서 1 사이의 명령을 받지만, 하드웨어 사양에 따라 조향 명령(라디안)만으로 이 범위를 전부 사용할 수도 있고 일부만 사용할 수도 있습니다.
61+
62+
### 비선형성과 캘리브레이션 범위
63+
64+
벨크랭크 링키지 구조로 인해 서보 값과 실제 바퀴 조향각 사이의 관계는 비선형성을 띱니다. 따라서 모든 조향각에서 요구되는 회전반경에 정확하게 매핑되지 않습니다. 이러한 이유로, 자주 사용하는 조향각 범위 내에서 servo gain 매핑을 하는 것을 추천합니다.
65+
66+
예를 들어, F1tenth 주행에서 ±0.25 라디안(약 ±14도) 범위 내에서 대부분의 조향이 이루어진다면, 해당 범위에서 정확도를 맞추는 것이 효과적입니다. 극단적인 조향각은 저속 긴급 상황에서나 사용되므로, 약간의 오차는 감수할 수 있습니다.
67+
68+
### 서보 혼 초기 위치의 중요성
69+
70+
servo gain과 offset이 적용된 상태에서 하드웨어의 한계까지 조향 명령을 주었을 때, 좌측이나 우측 한 방향으로만 제약되지 않도록 주의해야 합니다. 즉, 최대 조향 명령을 주어도 서보 명령은 항상 0에서 1 사이에 존재해야 합니다.
71+
72+
이를 위해 서보 혼 초기 위치를 가동범위 중앙에 잘 위치시키는 것이 중요합니다. 서보 혼이 잘 장착된 경우, offset은 0.5에 근접하게 측정됩니다.
73+
74+
## 실험으로 Servo Parameter 찾기
75+
76+
### Offset 찾기 (직진 맞추기)
77+
78+
offset은 조향각 0일 때의 서보 값입니다. 바퀴가 정확히 직진 방향을 가리킬 때의 서보 값을 찾으면 됩니다.
79+
80+
### 측정 순서
81+
82+
1. 타이어의 마찰이나 바닥 결에 대한 영향을 최소화하기 위해, 측정 전 조이스틱을 이용해 좌우로 조향 명령을 주어 서보모터가 중앙에 잘 위치하도록 합니다.
83+
2. 타이어가 미끄러지지 않도록 서서히 출발하여 직진 주행합니다.
84+
3. 차량이 진행하는 방향을 관찰하여, 좌우로 치우치지 않고 직진하는지 확인합니다.
85+
4. 직진하지 않는다면 offset 값을 조금씩 조정하며 반복합니다.
86+
5. 차량이 정확히 직진할 때의 값을 `steering_angle_to_servo_offset`으로 설정합니다.
87+
88+
> 서보 혼이 잘 장착되어 있다면 offset은 0.5 근처가 됩니다. 만약 0.5에서 크게 벗어난다면, 서보 혼을 분리 후 재장착하여 중앙에 맞추는 것을 권장합니다.
89+
{: .prompt-tip }
90+
91+
### Gain 찾기
92+
93+
gain은 조향각 변화에 따른 서보 값 변화의 비율입니다. rviz에서 누적된 odometry를 통해 회전반경을 측정하고, Ackermann 공식을 이용하여 gain을 튜닝합니다.
94+
95+
### Ackermann 회전반경 공식
96+
97+
Ackermann steering geometry에서 조향각과 회전반경의 관계는 다음과 같습니다. wheelbase는 앞 차축과 뒷 차축 사이의 거리로, 자를 통해 직접 측정하거나, 제조사에 적혀있는 정보를 참고하면 됩니다.
98+
99+
$$
100+
turning\_radius = \frac{wheelbase}{\tan(steering\_angle)}
101+
$$
102+
103+
명령한 조향각으로 예상 회전반경을 계산하고, 실제 측정된 회전반경과 비교하여 gain을 조정합니다.
104+
105+
![Rviz 회전 반경 측정](/assets/img/posts/servo-parameter/rviz-turning-radius.png)
106+
_Rviz를 통해 회전 반경을 측정하는 모습_
107+
108+
### 측정 순서
109+
110+
1. rviz에서 odometry를 시각화할 수 있는 상태에서 시작합니다.
111+
2. 일정한 조향각 명령(예: 0.2 rad)을 준 채로 slip 없이 저속으로 원을 그리며 주행합니다.
112+
3. rviz에서 누적된 odometry 궤적이 원을 그리면, Measure 기능을 활용하여 원의 지름을 측정하고 회전반경(R)을 구합니다.
113+
4. 명령한 조향각으로 계산한 예상 회전반경과 실제 회전반경을 비교하여 gain을 조정합니다.
114+
115+
### 계산 예시 (Traxxas Fiesta 기준)
116+
117+
| 항목 ||
118+
|------|-----|
119+
| 휠베이스 | 0.33m |
120+
| 명령한 조향각 | 0.2 rad |
121+
| 예상 회전반경 | 0.33 / tan(0.2) ≈ 1.62m |
122+
| 실제 측정된 회전반경 | 1.8m |
123+
124+
이 경우, 예상(1.62m)보다 실제(1.8m)가 크므로 실제 조향각이 명령보다 작다는 의미입니다. 따라서 gain의 절댓값을 늘려야 합니다.
125+
126+
### 보정 방법
127+
128+
| 상황 | 조치 |
129+
|------|------|
130+
| 실제 회전반경 > 예상 회전반경 | gain의 절댓값을 늘린다 |
131+
| 실제 회전반경 < 예상 회전반경 | gain의 절댓값을 줄인다 |
132+
133+
### 주의사항
134+
135+
- 자주 사용하는 조향각 범위(예: ±0.25 rad) 내에서 여러 지점을 테스트하여 전반적으로 잘 맞는 gain을 찾습니다.
136+
- 측정 시 slip이 발생하지 않도록 충분히 저속으로 주행해야 정확한 회전반경을 얻을 수 있습니다.
137+
138+
## 마무리
139+
140+
Servo Parameter는 실험을 통해 측정해야 하지만, 하드웨어가 변경되지 않는 한 값이 변하지 않기 때문에 한 번만 정확하게 측정하면 됩니다. 시간을 들여 정밀하게 캘리브레이션하는 것을 권장합니다. 이 파라미터는 사용자가 의도한 조향각이 차량에 정확히 전달되도록 매핑하는 역할을 하므로, 캘리브레이션 이후 임의로 조작하지 않도록 주의해야 합니다.
48.7 KB
Loading
176 KB
Loading
42.9 KB
Loading
3.42 MB
Loading
42.9 KB
Loading

0 commit comments

Comments
 (0)