vesc_driver.h
Go to the documentation of this file.
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 <memory>
32 #include <string>
33 
34 #include <ros/ros.h>
35 #include <std_msgs/Float64.h>
36 #include <boost/optional.hpp>
37 
40 
41 namespace vesc_driver
42 {
43 
45 {
46 public:
48  ros::NodeHandle private_nh);
49 
50 private:
51  // interface to the VESC
53  void vescPacketCallback(const std::shared_ptr<VescPacket const>& 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<double>& min_lower = boost::optional<double>(),
61  const boost::optional<double>& max_upper = boost::optional<double>());
62  double clip(double value);
63  std::string name;
64  boost::optional<double> lower;
65  boost::optional<double> upper;
66  };
73 
74  // ROS services
84 
85  // driver modes (possible states)
86  typedef enum
87  {
90  }
92 
93  // other variables
94  driver_mode_t driver_mode_;
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_
CommandLimit current_limit_
Definition: vesc_driver.h:68
void dutyCycleCallback(const std_msgs::Float64::ConstPtr &duty_cycle)
int fw_version_major_
firmware major version reported by vesc
Definition: vesc_driver.h:95
ros::Subscriber servo_sub_
Definition: vesc_driver.h:82
CommandLimit speed_limit_
Definition: vesc_driver.h:70
ros::Subscriber brake_sub_
Definition: vesc_driver.h:79
void vescPacketCallback(const std::shared_ptr< VescPacket const > &packet)
boost::optional< double > lower
Definition: vesc_driver.h:64
void servoCallback(const std_msgs::Float64::ConstPtr &servo)
CommandLimit position_limit_
Definition: vesc_driver.h:71
driver_mode_t driver_mode_
driver state machine mode (state)
Definition: vesc_driver.h:94
void positionCallback(const std_msgs::Float64::ConstPtr &position)
ros::Subscriber position_sub_
Definition: vesc_driver.h:81
void currentCallback(const std_msgs::Float64::ConstPtr &current)
CommandLimit duty_cycle_limit_
Definition: vesc_driver.h:67
int fw_version_minor_
firmware minor version reported by vesc
Definition: vesc_driver.h:96
void brakeCallback(const std_msgs::Float64::ConstPtr &brake)
CommandLimit brake_limit_
Definition: vesc_driver.h:69
ros::Publisher state_pub_
Definition: vesc_driver.h:75
ros::Subscriber current_sub_
Definition: vesc_driver.h:78
ros::Publisher servo_sensor_pub_
Definition: vesc_driver.h:76
void speedCallback(const std_msgs::Float64::ConstPtr &speed)
VescDriver(ros::NodeHandle nh, ros::NodeHandle private_nh)
Definition: vesc_driver.cpp:43
ros::Subscriber duty_cycle_sub_
Definition: vesc_driver.h:77
boost::optional< double > upper
Definition: vesc_driver.h:65
CommandLimit(const ros::NodeHandle &nh, const std::string &str, const boost::optional< double > &min_lower=boost::optional< double >(), const boost::optional< double > &max_upper=boost::optional< double >())
CommandLimit servo_limit_
Definition: vesc_driver.h:72
VescInterface vesc_
Definition: vesc_driver.h:52
void timerCallback(const ros::TimerEvent &event)
void vescErrorCallback(const std::string &error)
ros::Subscriber speed_sub_
Definition: vesc_driver.h:80


vesc_driver
Author(s): Michael T. Boulet , Joshua Whitley
autogenerated on Sun Apr 18 2021 02:48:01