rm_controllers
Loading...
Searching...
No Matches
swerve.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BSD 3-Clause License
3 *
4 * Copyright (c) 2021, Qiayuan Liao
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * * Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *******************************************************************************/
33
34//
35// Created by qiayuan on 4/23/21.
36//
37
38#pragma once
39
41
42#include <rm_common/eigen_types.h>
43#include <effort_controllers/joint_position_controller.h>
44
46{
47struct Module
48{
49 Vec2<double> position_;
51 effort_controllers::JointPositionController* ctrl_pivot_;
52 effort_controllers::JointVelocityController* ctrl_wheel_;
53};
54
55class SwerveController : public ChassisBase<rm_control::RobotStateInterface, hardware_interface::EffortJointInterface>
56{
57public:
58 SwerveController() = default;
59 bool init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
60
61private:
62 void moveJoint(const ros::Time& time, const ros::Duration& period) override;
63 geometry_msgs::Twist odometry() override;
64 std::vector<Module> modules_;
65};
66
67} // namespace rm_chassis_controllers
Definition chassis_base.h:95
bool init(hardware_interface::RobotHW *robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh) override
Definition swerve.cpp:45
Definition active_suspension.h:16
Definition swerve.h:48
effort_controllers::JointPositionController * ctrl_pivot_
Definition swerve.h:51
Vec2< double > position_
Definition swerve.h:49
double pivot_offset_
Definition swerve.h:50
double wheel_radius_
Definition swerve.h:50
effort_controllers::JointVelocityController * ctrl_wheel_
Definition swerve.h:52