|
| 1 | +/* |
| 2 | + * Copyright 2022 Robert Bosch GmbH |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + */ |
| 18 | +/** |
| 19 | + * \file cloe/component/utility/steering_utils.hpp |
| 20 | + */ |
| 21 | + |
| 22 | +#pragma once |
| 23 | +#ifndef CLOE_COMPONENT_UTILITY_STEERING_UTILS_HPP_ |
| 24 | +#define CLOE_COMPONENT_UTILITY_STEERING_UTILS_HPP_ |
| 25 | + |
| 26 | +namespace cloe { |
| 27 | +namespace utility { |
| 28 | + |
| 29 | +struct Geometry { |
| 30 | + /// Distance between the front and the rear axle in [m]. |
| 31 | + double wheel_base{0.0}; |
| 32 | + |
| 33 | + /// Distance between the left wheel and the right wheel in [m]. |
| 34 | + double track_base{0.0}; |
| 35 | +}; |
| 36 | + |
| 37 | +enum class WheelId : unsigned int { FrontLeft = 0, FrontRight, RearLeft, RearRight }; |
| 38 | + |
| 39 | +/** |
| 40 | + * This function translates a steering angle from the center of the axle to the individual steering angle of a wheel. |
| 41 | + * |
| 42 | + * This function is based on the Ackermann steering geometry, see [https://en.wikipedia.org/wiki/Ackermann_steering_geometry, accessed 28.10.2022] |
| 43 | + * The calculation only works for the following assumptions, as it assumes that the centre of rotation is on the same level with the rear wheels: |
| 44 | + * - low speed |
| 45 | + * - no rear steering |
| 46 | + * Detailed explanations can be found in basic vehicle dynamics literature, e.g. chapter 4.2 of the Steering Handbook |
| 47 | + * by Harrer and Pfeffer [https://link.springer.com/book/10.1007/978-3-319-05449-0] |
| 48 | + * |
| 49 | + * The function needs a wheel_base, a track_base (both stored in Geometry), the wheel_id and the steering_angle in the center of the axle. |
| 50 | + * The wheel_id is the ID you want to calculate the angle for, i.e. either FrontLeft or FrontRight. |
| 51 | + * The function returns the value of the steering_angle of the requested wheel. |
| 52 | + */ |
| 53 | +double calculate_wheel_angle(const Geometry& geometry, WheelId wheel_id, double steering_angle); |
| 54 | + |
| 55 | +} // namespace utility |
| 56 | +} // namespace cloe |
| 57 | + |
| 58 | +#endif // CLOE_COMPONENT_UTILITY_STEERING_UTILS_HPP_ |
0 commit comments