├── .gitignore
├── vesc
├── CMakeLists.txt
├── CHANGELOG.rst
└── package.xml
├── vesc_msgs
├── msg
│ ├── VescStateStamped.msg
│ └── VescState.msg
├── CMakeLists.txt
├── CHANGELOG.rst
└── package.xml
├── README.md
├── vesc_driver
├── vesc_driver_nodelet.xml
├── launch
│ ├── vesc_driver_node.launch
│ └── vesc_driver_nodelet.launch
├── CHANGELOG.rst
├── package.xml
├── src
│ ├── vesc_driver_node.cpp
│ ├── vesc_driver_nodelet.cpp
│ ├── vesc_packet_factory.cpp
│ ├── vesc_interface.cpp
│ ├── vesc_driver.cpp
│ └── vesc_packet.cpp
├── CMakeLists.txt
└── include
│ └── vesc_driver
│ ├── vesc_driver.h
│ ├── vesc_packet_factory.h
│ ├── vesc_interface.h
│ ├── datatypes.h
│ ├── vesc_packet.h
│ └── crc.h
├── vesc_ackermann
├── vesc_ackermann_nodelet.xml
├── launch
│ ├── vesc_to_odom_node.launch
│ ├── ackermann_to_vesc_node.launch
│ ├── vesc_to_odom_nodelet.launch
│ └── ackermann_to_vesc_nodelet.launch
├── CHANGELOG.rst
├── package.xml
├── src
│ ├── vesc_to_odom_node.cpp
│ ├── ackermann_to_vesc_node.cpp
│ ├── vesc_to_odom_nodelet.cpp
│ ├── ackermann_to_vesc_nodelet.cpp
│ ├── ackermann_to_vesc.cpp
│ └── vesc_to_odom.cpp
├── include
│ └── vesc_ackermann
│ │ ├── ackermann_to_vesc.h
│ │ └── vesc_to_odom.h
└── CMakeLists.txt
├── .github
└── workflows
│ └── ros1-ci.yaml
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 |
--------------------------------------------------------------------------------
/vesc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vesc)
3 | find_package(catkin REQUIRED)
4 | catkin_metapackage()
5 |
--------------------------------------------------------------------------------
/vesc_msgs/msg/VescStateStamped.msg:
--------------------------------------------------------------------------------
1 | # Timestamped VESC open source motor controller state (telemetry)
2 |
3 | Header header
4 | VescState state
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Veddar VESC Interface
2 |
3 | 
4 |
5 | Packages to interface with Veddar VESC motor controllers. See https://vesc-project.com/ for details
6 |
--------------------------------------------------------------------------------
/vesc_driver/vesc_driver_nodelet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Vedder VESC motor controller interface nodelet.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/vesc_msgs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vesc_msgs)
3 |
4 | find_package(catkin REQUIRED COMPONENTS
5 | std_msgs
6 | message_generation
7 | )
8 |
9 | add_message_files(
10 | DIRECTORY msg
11 | FILES
12 | VescState.msg
13 | VescStateStamped.msg
14 | )
15 | generate_messages(
16 | DEPENDENCIES
17 | std_msgs
18 | )
19 |
20 | catkin_package(
21 | CATKIN_DEPENDS std_msgs message_runtime
22 | )
23 |
--------------------------------------------------------------------------------
/vesc_ackermann/vesc_ackermann_nodelet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Nodelet for translating ackermann messages to VESC motor controller commands.
4 |
5 |
6 | Nodelet for translating VESC motor controller state to odometry messages.
7 |
8 |
9 |
--------------------------------------------------------------------------------
/vesc_ackermann/launch/vesc_to_odom_node.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/vesc/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package vesc
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.1.0 (2020-12-12)
6 | ------------------
7 | * Merge pull request `#1 `_ from f1tenth/melodic-devel
8 | Updating for Melodic
9 | * Updating package.xml to format 3 and setting C++ standard to 11.
10 | * Contributors: Joshua Whitley
11 |
12 | 1.0.0 (2020-12-02)
13 | ------------------
14 | * Updating maintainers, authors, and URLs.
15 | * added onboard car
16 | * Contributors: Joshua Whitley, billyzheng
17 |
--------------------------------------------------------------------------------
/vesc_ackermann/launch/ackermann_to_vesc_node.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/vesc_msgs/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package vesc_msgs
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.1.0 (2020-12-12)
6 | ------------------
7 | * Merge pull request `#1 `_ from f1tenth/melodic-devel
8 | Updating for Melodic
9 | * Updating package.xml to format 3 and setting C++ standard to 11.
10 | * Contributors: Joshua Whitley
11 |
12 | 1.0.0 (2020-12-02)
13 | ------------------
14 | * Adding roslint.
15 | * Updating maintainers, authors, and URLs.
16 | * added onboard car
17 | * Contributors: Joshua Whitley, billyzheng
18 |
--------------------------------------------------------------------------------
/vesc_driver/launch/vesc_driver_node.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vesc_ackermann/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package vesc_ackermann
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.1.0 (2020-12-12)
6 | ------------------
7 | * Merge pull request `#1 `_ from f1tenth/melodic-devel
8 | Updating for Melodic
9 | * Remove unused Boost dependency.
10 | * Replacing boost::shared_ptr with Standard Library equivalent.
11 | * Fixing roslint error.
12 | * Updating package.xml to format 3 and setting C++ standard to 11.
13 | * Contributors: Joshua Whitley
14 |
15 | 1.0.0 (2020-12-02)
16 | ------------------
17 | * Applying roslint to vesc_ackerman.
18 | * Adding roslint.
19 | * Adding licenses.
20 | * Updating maintainers, authors, and URLs.
21 | * added onboard car
22 | * Contributors: Joshua Whitley, billyzheng
23 |
--------------------------------------------------------------------------------
/vesc_msgs/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vesc_msgs
5 | 1.1.0
6 |
7 | ROS message definitions for the Vedder VESC open source motor controller.
8 |
9 | Johannes Betz
10 | BSD
11 | http://ros.org/wiki/vesc_msgs
12 | https://github.com/f1tenth/vesc
13 | https://github.com/f1tenth/vesc/issues
14 | Michael T. Boulet
15 | Joshua Whitley
16 |
17 | catkin
18 | message_generation
19 |
20 | std_msgs
21 |
22 | message_runtime
23 |
24 |
--------------------------------------------------------------------------------
/vesc/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vesc
5 | 1.1.0
6 |
7 | Metapackage for ROS interface to the Vedder VESC open source motor controller.
8 |
9 | Johannes Betz
10 | BSD
11 | http://www.ros.org/wiki/vesc
12 | https://github.com/f1tenth/vesc
13 | https://github.com/f1tenth/vesc/issues
14 | Michael T. Boulet
15 | Joshua Whitley
16 |
17 | catkin
18 |
19 | vesc_driver
20 | vesc_msgs
21 | vesc_ackermann
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/vesc_driver/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package vesc_driver
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.1.0 (2020-12-12)
6 | ------------------
7 | * Merge pull request `#1 `_ from f1tenth/melodic-devel
8 | Updating for Melodic
9 | * Exclude crc.h from roslint.
10 | * Replacing boost::crc with CRCPP.
11 | * Replacing boost::begin, boost::end, and boost::distance with Standard Library equivalents.
12 | * Replacing boost::bind with Standard Library equivalent.
13 | * Replaing boost::noncopyable with C++ equivalent.
14 | * Replacing boost::function with Standard Library version.
15 | * Replacing Boost smart pointers with Standard Library equivalents.
16 | * Removing unnecessary v8stdint.h.
17 | * Updating package.xml to format 3 and setting C++ standard to 11.
18 | * Contributors: Joshua Whitley
19 |
20 | 1.0.0 (2020-12-02)
21 | ------------------
22 | * Applying roslint and replacing registration macro with templated class.
23 | * Adding roslint.
24 | * Adding licenses.
25 | * Updating maintainers, authors, and URLs.
26 | * added onboard car
27 | * Contributors: Joshua Whitley, billyzheng
28 |
--------------------------------------------------------------------------------
/vesc_msgs/msg/VescState.msg:
--------------------------------------------------------------------------------
1 | # Vedder VESC open source motor controller state (telemetry)
2 |
3 | # fault codes
4 | int32 FAULT_CODE_NONE=0
5 | int32 FAULT_CODE_OVER_VOLTAGE=1
6 | int32 FAULT_CODE_UNDER_VOLTAGE=2
7 | int32 FAULT_CODE_DRV8302=3
8 | int32 FAULT_CODE_ABS_OVER_CURRENT=4
9 | int32 FAULT_CODE_OVER_TEMP_FET=5
10 | int32 FAULT_CODE_OVER_TEMP_MOTOR=6
11 |
12 | float64 voltage_input # input voltage (volt)
13 | float64 temperature_pcb # temperature of printed circuit board (degrees Celsius)
14 | float64 current_motor # motor current (ampere)
15 | float64 current_input # input current (ampere)
16 | float64 speed # motor electrical speed (revolutions per minute)
17 | float64 duty_cycle # duty cycle (0 to 1)
18 | float64 charge_drawn # electric charge drawn from input (ampere-hour)
19 | float64 charge_regen # electric charge regenerated to input (ampere-hour)
20 | float64 energy_drawn # energy drawn from input (watt-hour)
21 | float64 energy_regen # energy regenerated to input (watt-hour)
22 | float64 displacement # net tachometer (counts)
23 | float64 distance_traveled # total tachnometer (counts)
24 | int32 fault_code
25 |
--------------------------------------------------------------------------------
/vesc_driver/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vesc_driver
5 | 1.1.0
6 |
7 | ROS device driver for the Vedder VESC open source motor driver.
8 |
9 | Johannes Betz
10 | BSD
11 | http://www.ros.org/wiki/vesc_driver
12 | https://github.com/f1tenth/vesc
13 | https://github.com/f1tenth/vesc/issues
14 | Michael T. Boulet
15 | Joshua Whitley
16 |
17 | catkin
18 | roslint
19 |
20 | nodelet
21 | pluginlib
22 | roscpp
23 | serial
24 | std_msgs
25 | vesc_msgs
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/vesc_ackermann/launch/vesc_to_odom_nodelet.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.github/workflows/ros1-ci.yaml:
--------------------------------------------------------------------------------
1 | name: ROS1 CI Workflow
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 |
11 | build-ros1:
12 | runs-on: ubuntu-latest
13 | strategy:
14 | fail-fast: false
15 | container:
16 | image: ros:melodic
17 | steps:
18 | - name: Checkout Repo
19 | uses: actions/checkout@v2
20 | - name: Create Workspace
21 | run: |
22 | mkdir -p src_tmp/vesc; \
23 | mv `find -maxdepth 1 -not -name . -not -name src_tmp` src_tmp/vesc/; \
24 | mv src_tmp/ src/; \
25 | cd src; \
26 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
27 | catkin_init_workspace'
28 | - name: Install Dependencies
29 | run: |
30 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
31 | apt-get update && rosdep update; \
32 | rosdep install --from-paths src --ignore-src -y'
33 | - name: Build Workspace
34 | run: |
35 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
36 | catkin_make'
37 | - name: Run Tests
38 | run: |
39 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
40 | catkin_make run_tests; \
41 | catkin_test_results --verbose'
42 |
--------------------------------------------------------------------------------
/vesc_ackermann/launch/ackermann_to_vesc_nodelet.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/vesc_ackermann/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vesc_ackermann
5 | 1.1.0
6 |
7 | Translate between VESC messages and ROS ackermann and odometry messages.
8 |
9 | Johannes Betz
10 | BSD
11 | http://www.ros.org/wiki/vesc_ackermann
12 | https://github.com/f1tenth/vesc
13 | https://github.com/f1tenth/vesc/issues
14 | Michael T. Boulet
15 | Joshua Whitley
16 |
17 | catkin
18 |
19 | roslint
20 |
21 | ackermann_msgs
22 | geometry_msgs
23 | nav_msgs
24 | nodelet
25 | pluginlib
26 | roscpp
27 | std_msgs
28 | tf
29 | vesc_msgs
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2020 F1TENTH Foundation
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 |
7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/vesc_driver/launch/vesc_driver_nodelet.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/vesc_driver/src/vesc_driver_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 |
28 | #include "vesc_driver/vesc_driver.h"
29 |
30 | int main(int argc, char** argv)
31 | {
32 | ros::init(argc, argv, "vesc_driver_node");
33 | ros::NodeHandle nh;
34 | ros::NodeHandle private_nh("~");
35 |
36 | vesc_driver::VescDriver vesc_driver(nh, private_nh);
37 |
38 | ros::spin();
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/vesc_ackermann/src/vesc_to_odom_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 |
28 | #include "vesc_ackermann/vesc_to_odom.h"
29 |
30 | int main(int argc, char** argv)
31 | {
32 | ros::init(argc, argv, "vesc_to_odom_node");
33 | ros::NodeHandle nh;
34 | ros::NodeHandle private_nh("~");
35 |
36 | vesc_ackermann::VescToOdom vesc_to_odom(nh, private_nh);
37 |
38 | ros::spin();
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/vesc_ackermann/src/ackermann_to_vesc_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 |
28 | #include "vesc_ackermann/ackermann_to_vesc.h"
29 |
30 | int main(int argc, char** argv)
31 | {
32 | ros::init(argc, argv, "ackermann_to_vesc_node");
33 | ros::NodeHandle nh;
34 | ros::NodeHandle private_nh("~");
35 |
36 | vesc_ackermann::AckermannToVesc ackermann_to_vesc(nh, private_nh);
37 |
38 | ros::spin();
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/vesc_driver/src/vesc_driver_nodelet.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 |
32 | #include "vesc_driver/vesc_driver.h"
33 |
34 | namespace vesc_driver
35 | {
36 |
37 | class VescDriverNodelet: public nodelet::Nodelet
38 | {
39 | public:
40 | VescDriverNodelet() {}
41 |
42 | private:
43 | virtual void onInit(void);
44 |
45 | std::shared_ptr vesc_driver_;
46 | }; // class VescDriverNodelet
47 |
48 | void VescDriverNodelet::onInit()
49 | {
50 | NODELET_DEBUG("Initializing VESC driver nodelet");
51 | vesc_driver_.reset(new VescDriver(getNodeHandle(), getPrivateNodeHandle()));
52 | }
53 |
54 | } // namespace vesc_driver
55 |
56 | PLUGINLIB_EXPORT_CLASS(vesc_driver::VescDriverNodelet, nodelet::Nodelet);
57 |
--------------------------------------------------------------------------------
/vesc_ackermann/src/vesc_to_odom_nodelet.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 |
32 | #include "vesc_ackermann/vesc_to_odom.h"
33 |
34 | namespace vesc_ackermann
35 | {
36 |
37 | class VescToOdomNodelet: public nodelet::Nodelet
38 | {
39 | public:
40 | VescToOdomNodelet() {}
41 |
42 | private:
43 | virtual void onInit(void);
44 |
45 | std::shared_ptr vesc_to_odom_;
46 | }; // class VescToOdomNodelet
47 |
48 | void VescToOdomNodelet::onInit()
49 | {
50 | NODELET_DEBUG("Initializing RACECAR VESC odometry estimator nodelet");
51 | vesc_to_odom_.reset(new VescToOdom(getNodeHandle(), getPrivateNodeHandle()));
52 | }
53 |
54 | } // namespace vesc_ackermann
55 |
56 | PLUGINLIB_EXPORT_CLASS(vesc_ackermann::VescToOdomNodelet, nodelet::Nodelet);
57 |
--------------------------------------------------------------------------------
/vesc_ackermann/src/ackermann_to_vesc_nodelet.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 |
32 | #include "vesc_ackermann/ackermann_to_vesc.h"
33 |
34 | namespace vesc_ackermann
35 | {
36 |
37 | class AckermannToVescNodelet: public nodelet::Nodelet
38 | {
39 | public:
40 | AckermannToVescNodelet() {}
41 |
42 | private:
43 | virtual void onInit(void);
44 |
45 | std::shared_ptr ackermann_to_vesc_;
46 | }; // class AckermannToVescNodelet
47 |
48 | void AckermannToVescNodelet::onInit()
49 | {
50 | NODELET_DEBUG("Initializing ackermann to VESC nodelet");
51 | ackermann_to_vesc_.reset(new AckermannToVesc(getNodeHandle(), getPrivateNodeHandle()));
52 | }
53 |
54 | } // namespace vesc_ackermann
55 |
56 | PLUGINLIB_EXPORT_CLASS(vesc_ackermann::AckermannToVescNodelet, nodelet::Nodelet);
57 |
--------------------------------------------------------------------------------
/vesc_ackermann/include/vesc_ackermann/ackermann_to_vesc.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | // -*- mode:c++; fill-column: 100; -*-
27 |
28 | #ifndef VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
29 | #define VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
30 |
31 | #include
32 | #include
33 |
34 | namespace vesc_ackermann
35 | {
36 |
37 | class AckermannToVesc
38 | {
39 | public:
40 | AckermannToVesc(ros::NodeHandle nh, ros::NodeHandle private_nh);
41 |
42 | private:
43 | // ROS parameters
44 | // conversion gain and offset
45 | bool previous_mode_speed_ = true;
46 | double speed_to_erpm_gain_, speed_to_erpm_offset_;
47 | double accel_to_current_gain_, accel_to_brake_gain_;
48 | double steering_to_servo_gain_, steering_to_servo_offset_;
49 |
50 | /** @todo consider also providing an interpolated look-up table conversion */
51 |
52 | // ROS services
53 | ros::Publisher erpm_pub_;
54 | ros::Publisher servo_pub_;
55 | ros::Publisher current_pub_;
56 | ros::Publisher brake_pub_;
57 | ros::Subscriber ackermann_sub_;
58 |
59 | // ROS callbacks
60 | void ackermannCmdCallback(const ackermann_msgs::AckermannDriveStamped::ConstPtr& cmd);
61 | };
62 |
63 | } // namespace vesc_ackermann
64 |
65 | #endif // VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
66 |
--------------------------------------------------------------------------------
/vesc_ackermann/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vesc_ackermann)
3 |
4 | # Setting C++ standard to 11
5 | if (NOT "${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}")
6 | message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
8 | elseif ("${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}" STREQUAL "98")
9 | message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
10 | set(CMAKE_CXX_STANDARD 11)
11 | endif()
12 |
13 | find_package(catkin REQUIRED COMPONENTS
14 | ackermann_msgs
15 | geometry_msgs
16 | nav_msgs
17 | nodelet
18 | pluginlib
19 | roscpp
20 | roslint
21 | std_msgs
22 | tf
23 | vesc_msgs
24 | )
25 |
26 | catkin_package(
27 | INCLUDE_DIRS include
28 | CATKIN_DEPENDS
29 | ackermann_msgs
30 | geometry_msgs
31 | nav_msgs
32 | nodelet
33 | pluginlib
34 | std_msgs
35 | tf
36 | vesc_msgs
37 | )
38 |
39 | ###########
40 | ## Build ##
41 | ###########
42 |
43 | include_directories(
44 | include
45 | ${catkin_INCLUDE_DIRS}
46 | )
47 |
48 | # node executable
49 | add_executable(vesc_to_odom_node src/vesc_to_odom_node.cpp
50 | src/vesc_to_odom.cpp)
51 | add_dependencies(vesc_to_odom_node ${catkin_EXPORTED_TARGETS})
52 | target_link_libraries(vesc_to_odom_node
53 | ${catkin_LIBRARIES}
54 | )
55 |
56 | add_executable(ackermann_to_vesc_node src/ackermann_to_vesc_node.cpp
57 | src/ackermann_to_vesc.cpp)
58 | add_dependencies(ackermann_to_vesc_node ${catkin_EXPORTED_TARGETS})
59 | target_link_libraries(ackermann_to_vesc_node
60 | ${catkin_LIBRARIES}
61 | )
62 |
63 | # nodelet library
64 | add_library(vesc_ackermann_nodelet src/ackermann_to_vesc_nodelet.cpp
65 | src/ackermann_to_vesc.cpp
66 | src/vesc_to_odom_nodelet.cpp
67 | src/vesc_to_odom.cpp)
68 | add_dependencies(vesc_ackermann_nodelet ${catkin_EXPORTED_TARGETS})
69 | target_link_libraries(vesc_ackermann_nodelet
70 | ${catkin_LIBRARIES}
71 | )
72 |
73 | set(ROSLINT_CPP_OPTS "--filter=-build/c++11")
74 | roslint_cpp()
75 |
76 | #############
77 | ## Install ##
78 | #############
79 |
80 | install(TARGETS vesc_to_odom_node ackermann_to_vesc_node
81 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
82 | )
83 |
84 | install(TARGETS vesc_ackermann_nodelet
85 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
86 | )
87 |
88 | install(DIRECTORY include/${PROJECT_NAME}/
89 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
90 | install(FILES vesc_ackermann_nodelet.xml
91 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
92 | install(DIRECTORY launch/
93 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
94 |
95 | #############
96 | ## Testing ##
97 | #############
98 |
99 | if(CATKIN_ENABLE_TESTING)
100 | roslint_add_test()
101 | endif()
102 |
--------------------------------------------------------------------------------
/vesc_driver/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vesc_driver)
3 |
4 | # Set minimum C++ standard to C++11
5 | if (NOT "${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}")
6 | message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
8 | elseif ("${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}" STREQUAL "98")
9 | message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
10 | set(CMAKE_CXX_STANDARD 11)
11 | endif()
12 |
13 | find_package(Boost REQUIRED)
14 |
15 | find_package(catkin REQUIRED COMPONENTS
16 | nodelet
17 | pluginlib
18 | roscpp
19 | roslint
20 | serial
21 | std_msgs
22 | vesc_msgs
23 | )
24 |
25 | catkin_package(
26 | INCLUDE_DIRS include
27 | CATKIN_DEPENDS
28 | nodelet
29 | pluginlib
30 | std_msgs
31 | vesc_msgs serial
32 | )
33 |
34 | ###########
35 | ## Build ##
36 | ###########
37 |
38 | include_directories(
39 | include
40 | ${Boost_INCLUDE_DIRS}
41 | ${catkin_INCLUDE_DIRS}
42 | )
43 |
44 | # node executable
45 | add_executable(vesc_driver_node src/vesc_driver_node.cpp
46 | src/vesc_driver.cpp
47 | src/vesc_interface.cpp
48 | src/vesc_packet.cpp
49 | src/vesc_packet_factory.cpp)
50 | add_dependencies(vesc_driver_node ${catkin_EXPORTED_TARGETS})
51 | target_link_libraries(vesc_driver_node
52 | ${catkin_LIBRARIES}
53 | )
54 |
55 | # nodelet library
56 | add_library(vesc_driver_nodelet src/vesc_driver_nodelet.cpp
57 | src/vesc_driver.cpp
58 | src/vesc_interface.cpp
59 | src/vesc_packet.cpp
60 | src/vesc_packet_factory.cpp)
61 | add_dependencies(vesc_driver_nodelet ${catkin_EXPORTED_TARGETS})
62 | target_link_libraries(vesc_driver_nodelet
63 | ${catkin_LIBRARIES}
64 | )
65 |
66 | file(GLOB_RECURSE ${PROJECT_NAME}_CPP_FILES
67 | RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
68 | . *.cpp *.h)
69 | list(REMOVE_ITEM ${PROJECT_NAME}_CPP_FILES
70 | include/${PROJECT_NAME}/crc.h)
71 |
72 | set(ROSLINT_CPP_OPTS "--filter=-build/c++11")
73 | roslint_cpp(${${PROJECT_NAME}_CPP_FILES})
74 |
75 | #############
76 | ## Install ##
77 | #############
78 |
79 | install(TARGETS vesc_driver_node
80 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
81 | )
82 |
83 | install(TARGETS vesc_driver_nodelet
84 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
85 | )
86 |
87 | install(DIRECTORY include/${PROJECT_NAME}/
88 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
89 | install(FILES vesc_driver_nodelet.xml
90 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
91 | install(DIRECTORY launch/
92 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
93 |
94 | #############
95 | ## Testing ##
96 | #############
97 |
98 | if(CATKIN_ENABLE_TESTING)
99 | roslint_add_test()
100 | endif()
101 |
--------------------------------------------------------------------------------
/vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | // -*- mode:c++; fill-column: 100; -*-
27 |
28 | #ifndef VESC_ACKERMANN_VESC_TO_ODOM_H_
29 | #define VESC_ACKERMANN_VESC_TO_ODOM_H_
30 |
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | namespace vesc_ackermann
40 | {
41 |
42 | class VescToOdom
43 | {
44 | public:
45 | VescToOdom(ros::NodeHandle nh, ros::NodeHandle private_nh);
46 |
47 | private:
48 | // ROS parameters
49 | std::string odom_frame_;
50 | std::string base_frame_;
51 | /** State message does not report servo position, so use the command instead */
52 | bool use_servo_cmd_;
53 | // conversion gain and offset
54 | double speed_to_erpm_gain_, speed_to_erpm_offset_;
55 | double steering_to_servo_gain_, steering_to_servo_offset_;
56 | double wheelbase_;
57 | bool publish_tf_;
58 |
59 | // odometry state
60 | double x_, y_, yaw_;
61 | std_msgs::Float64::ConstPtr last_servo_cmd_; ///< Last servo position commanded value
62 | vesc_msgs::VescStateStamped::ConstPtr last_state_; ///< Last received state message
63 |
64 | // ROS services
65 | ros::Publisher odom_pub_;
66 | ros::Subscriber vesc_state_sub_;
67 | ros::Subscriber servo_sub_;
68 | std::shared_ptr tf_pub_;
69 |
70 | // ROS callbacks
71 | void vescStateCallback(const vesc_msgs::VescStateStamped::ConstPtr& state);
72 | void servoCmdCallback(const std_msgs::Float64::ConstPtr& servo);
73 | };
74 |
75 | } // namespace vesc_ackermann
76 |
77 | #endif // VESC_ACKERMANN_VESC_TO_ODOM_H_
78 |
--------------------------------------------------------------------------------
/vesc_driver/include/vesc_driver/vesc_driver.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | // -*- mode:c++; fill-column: 100; -*-
27 |
28 | #ifndef VESC_DRIVER_VESC_DRIVER_H_
29 | #define VESC_DRIVER_VESC_DRIVER_H_
30 |
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 | #include
37 |
38 | #include "vesc_driver/vesc_interface.h"
39 | #include "vesc_driver/vesc_packet.h"
40 |
41 | namespace vesc_driver
42 | {
43 |
44 | class VescDriver
45 | {
46 | public:
47 | VescDriver(ros::NodeHandle nh,
48 | ros::NodeHandle private_nh);
49 |
50 | private:
51 | // interface to the VESC
52 | VescInterface vesc_;
53 | void vescPacketCallback(const std::shared_ptr& packet);
54 | void vescErrorCallback(const std::string& error);
55 |
56 | // limits on VESC commands
57 | struct CommandLimit
58 | {
59 | CommandLimit(const ros::NodeHandle& nh, const std::string& str,
60 | const boost::optional& min_lower = boost::optional(),
61 | const boost::optional& max_upper = boost::optional());
62 | double clip(double value);
63 | std::string name;
64 | boost::optional lower;
65 | boost::optional upper;
66 | };
67 | CommandLimit duty_cycle_limit_;
68 | CommandLimit current_limit_;
69 | CommandLimit brake_limit_;
70 | CommandLimit speed_limit_;
71 | CommandLimit position_limit_;
72 | CommandLimit servo_limit_;
73 |
74 | // ROS services
75 | ros::Publisher state_pub_;
76 | ros::Publisher servo_sensor_pub_;
77 | ros::Subscriber duty_cycle_sub_;
78 | ros::Subscriber current_sub_;
79 | ros::Subscriber brake_sub_;
80 | ros::Subscriber speed_sub_;
81 | ros::Subscriber position_sub_;
82 | ros::Subscriber servo_sub_;
83 | ros::Timer timer_;
84 |
85 | // driver modes (possible states)
86 | typedef enum
87 | {
88 | MODE_INITIALIZING,
89 | MODE_OPERATING
90 | }
91 | driver_mode_t;
92 |
93 | // other variables
94 | driver_mode_t driver_mode_; ///< driver state machine mode (state)
95 | int fw_version_major_; ///< firmware major version reported by vesc
96 | int fw_version_minor_; ///< firmware minor version reported by vesc
97 |
98 | // ROS callbacks
99 | void timerCallback(const ros::TimerEvent& event);
100 | void dutyCycleCallback(const std_msgs::Float64::ConstPtr& duty_cycle);
101 | void currentCallback(const std_msgs::Float64::ConstPtr& current);
102 | void brakeCallback(const std_msgs::Float64::ConstPtr& brake);
103 | void speedCallback(const std_msgs::Float64::ConstPtr& speed);
104 | void positionCallback(const std_msgs::Float64::ConstPtr& position);
105 | void servoCallback(const std_msgs::Float64::ConstPtr& servo);
106 | };
107 |
108 | } // namespace vesc_driver
109 |
110 | #endif // VESC_DRIVER_VESC_DRIVER_H_
111 |
--------------------------------------------------------------------------------
/vesc_driver/include/vesc_driver/vesc_packet_factory.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020 F1TENTH Foundation
2 | //
3 | // Redistribution and use in source and binary forms, with or without modification, are permitted
4 | // provided that the following conditions are met:
5 | //
6 | // 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7 | // and the following disclaimer.
8 | //
9 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list
10 | // of conditions and the following disclaimer in the documentation and/or other materials
11 | // provided with the distribution.
12 | //
13 | // 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 | // to endorse or promote products derived from this software without specific prior
15 | // written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
24 | // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | // -*- mode:c++; fill-column: 100; -*-
27 |
28 | #ifndef VESC_DRIVER_VESC_PACKET_FACTORY_H_
29 | #define VESC_DRIVER_VESC_PACKET_FACTORY_H_
30 |
31 | #include
32 | #include
33 | #include