-
Notifications
You must be signed in to change notification settings - Fork 112
Ported the ROS2 fox drivers to ROS1 Noetic #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
f075df8
dee9a72
fc021e2
c2ac089
5d140e7
1817c25
c04814e
e13d321
b2ae047
ed42c65
5f37bb2
42ae666
6f1ea6b
de3c916
c78c44f
bf6e4d0
92bb299
0d0bf86
424ef1d
6f22df8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| *.swp | ||
| .vscode/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| # Veddar VESC Interface | ||
| # ROS1 VESC Package | ||
|
|
||
|  | ||
|
|
||
| Packages to interface with Veddar VESC motor controllers. See https://vesc-project.com/ for details | ||
|
|
||
| The ```noetic``` branch contains the ROS2 branch back ported to ROS1 such that it is compatible with VESC (tested on the VESC EDU) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
|
|
||
| # erpm (electrical rpm) = speed_to_erpm_gain * speed (meters / second) + speed_to_erpm_offset | ||
| speed_to_erpm_gain: 5420 #4614 | ||
| speed_to_erpm_offset: 0.0 | ||
|
|
||
| # Set gains for converting acceleration to current and brake control values | ||
| accel_to_current_gain: 100 | ||
| accel_to_brake_gain: -80 | ||
|
|
||
| tachometer_ticks_to_meters_gain: 0.00225 | ||
| # servo smoother - limits rotation speed and smooths anything above limit | ||
| max_servo_speed: 3.2 # radians/second | ||
| servo_smoother_rate: 75.0 # messages/sec | ||
|
|
||
| # servo smoother - limits acceleration and smooths anything above limit | ||
| max_acceleration: 2.5 # meters/second^2 | ||
| throttle_smoother_rate: 75.0 # messages/sec | ||
|
|
||
| # servo value (0 to 1) = steering_angle_to_servo_gain * steering angle (radians) + steering_angle_to_servo_offset | ||
| steering_angle_to_servo_gain: -1.2135 | ||
| steering_angle_to_servo_offset: 0.55 #0.5304 | ||
|
|
||
| # publish odom to base link tf | ||
| vesc_to_odom/publish_tf: false | ||
|
|
||
| # car wheelbase is about 25cm | ||
| wheelbase: .256 | ||
|
|
||
| vesc_driver: | ||
| port: /dev/sensors/vesc | ||
| duty_cycle_min: 0.0 | ||
| duty_cycle_max: 0.0 | ||
| current_min: 0.0 | ||
| current_max: 100.0 | ||
| brake_min: -20000.0 | ||
| brake_max: 200000.0 | ||
| speed_min: -23250 | ||
| speed_max: 23250 | ||
| position_min: 0.0 | ||
| position_max: 0.0 | ||
| servo_min: 0.15 | ||
| servo_max: 0.85 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,28 @@ | |
| <buildtool_depend>catkin</buildtool_depend> | ||
|
|
||
| <build_depend>roslint</build_depend> | ||
| <build_depend>nodelet</build_depend> | ||
| <build_depend>pluginlib</build_depend> | ||
| <build_depend>roscpp</build_depend> | ||
| <build_depend>nav_msgs</build_depend> | ||
| <build_depend>std_msgs</build_depend> | ||
| <build_depend>geometry_msgs</build_depend> | ||
| <build_depend>tf</build_depend> | ||
| <build_depend>ackermann_msgs</build_depend> | ||
| <build_depend>vesc_msgs</build_depend> | ||
|
|
||
| <depend>ackermann_msgs</depend> | ||
| <depend>geometry_msgs</depend> | ||
| <depend>nav_msgs</depend> | ||
| <depend>nodelet</depend> | ||
| <depend>pluginlib</depend> | ||
| <depend>roscpp</depend> | ||
| <depend>std_msgs</depend> | ||
| <depend>tf</depend> | ||
| <depend>vesc_msgs</depend> | ||
| <exec_depend>nodelet</exec_depend> | ||
| <exec_depend>pluginlib</exec_depend> | ||
| <exec_depend>roscpp</exec_depend> | ||
| <exec_depend>nav_msgs</exec_depend> | ||
| <exec_depend>std_msgs</exec_depend> | ||
| <exec_depend>geometry_msgs</exec_depend> | ||
| <exec_depend>tf</exec_depend> | ||
| <exec_depend>ackermann_msgs</exec_depend> | ||
| <exec_depend>vesc_msgs</exec_depend> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you split all of these out?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix and push the updates! |
||
|
|
||
| <export> | ||
| <nodelet plugin="${prefix}/vesc_ackermann_nodelet.xml"/> | ||
| </export> | ||
|
|
||
| </package> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,28 +37,22 @@ namespace vesc_ackermann | |
| { | ||
|
|
||
| template <typename T> | ||
| inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value); | ||
| inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value); | ||
|
|
||
| AckermannToVesc::AckermannToVesc(ros::NodeHandle nh, ros::NodeHandle private_nh) | ||
| { | ||
| // get conversion parameters | ||
| if (!getRequiredParam(nh, "speed_to_erpm_gain", &speed_to_erpm_gain_)) | ||
| if (!getRequiredParam(nh, "speed_to_erpm_gain", speed_to_erpm_gain_)) | ||
| return; | ||
| if (!getRequiredParam(nh, "speed_to_erpm_offset", &speed_to_erpm_offset_)) | ||
| if (!getRequiredParam(nh, "speed_to_erpm_offset", speed_to_erpm_offset_)) | ||
| return; | ||
| if (!getRequiredParam(nh, "accel_to_current_gain", &accel_to_current_gain_)) | ||
| if (!getRequiredParam(nh, "steering_angle_to_servo_gain", steering_to_servo_gain_)) | ||
| return; | ||
| if (!getRequiredParam(nh, "accel_to_brake_gain", &accel_to_brake_gain_)) | ||
| return; | ||
| if (!getRequiredParam(nh, "steering_angle_to_servo_gain", &steering_to_servo_gain_)) | ||
| return; | ||
| if (!getRequiredParam(nh, "steering_angle_to_servo_offset", &steering_to_servo_offset_)) | ||
| if (!getRequiredParam(nh, "steering_angle_to_servo_offset", steering_to_servo_offset_)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Several of these changes are breaking changes (removing existing parameters and renaming others). This means a new major version would have to be released. Not that I won't do it, just giving you a heads-up.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will take a closer look and run some fixes for the noetic branch! |
||
| return; | ||
|
|
||
| // create publishers to vesc electric-RPM (speed) and servo commands | ||
| erpm_pub_ = nh.advertise<std_msgs::Float64>("commands/motor/speed", 10); | ||
| current_pub_ = nh.advertise<std_msgs::Float64>("commands/motor/current", 10); | ||
| brake_pub_ = nh.advertise<std_msgs::Float64>("commands/motor/brake", 10); | ||
| servo_pub_ = nh.advertise<std_msgs::Float64>("commands/servo/position", 10); | ||
|
|
||
| // subscribe to ackermann topic | ||
|
|
@@ -72,63 +66,22 @@ void AckermannToVesc::ackermannCmdCallback(const AckermannMsgPtr& cmd) | |
| std_msgs::Float64::Ptr erpm_msg(new std_msgs::Float64); | ||
| erpm_msg->data = speed_to_erpm_gain_ * cmd->drive.speed + speed_to_erpm_offset_; | ||
|
|
||
| // calc vesc current/brake (acceleration) | ||
| bool is_positive_accel = true; | ||
| std_msgs::Float64::Ptr current_msg(new std_msgs::Float64); | ||
| std_msgs::Float64::Ptr brake_msg(new std_msgs::Float64); | ||
| current_msg->data = 0; | ||
| brake_msg->data = 0; | ||
| if (cmd->drive.acceleration < 0) | ||
| { | ||
| brake_msg->data = accel_to_brake_gain_ * cmd->drive.acceleration; | ||
| is_positive_accel = false; | ||
| } | ||
| else | ||
| { | ||
| current_msg->data = accel_to_current_gain_ * cmd->drive.acceleration; | ||
| } | ||
|
|
||
| // calc steering angle (servo) | ||
| std_msgs::Float64::Ptr servo_msg(new std_msgs::Float64); | ||
| servo_msg->data = steering_to_servo_gain_ * cmd->drive.steering_angle + steering_to_servo_offset_; | ||
|
|
||
| // publish | ||
| if (ros::ok()) | ||
| { | ||
| // The below code attempts to stick to the previous mode until a new message forces a mode switch. | ||
| if (erpm_msg->data != 0 || previous_mode_speed_) | ||
| { | ||
| erpm_pub_.publish(erpm_msg); | ||
| } | ||
| else | ||
| { | ||
| if (is_positive_accel) | ||
| { | ||
| current_pub_.publish(current_msg); | ||
| } | ||
| else | ||
| { | ||
| brake_pub_.publish(brake_msg); | ||
| } | ||
| } | ||
| erpm_pub_.publish(erpm_msg); | ||
| servo_pub_.publish(servo_msg); | ||
| } | ||
|
|
||
| // The lines below are to determine which mode we are in so we can hold until new messages force a switch. | ||
| if (erpm_msg->data != 0) | ||
| { | ||
| previous_mode_speed_ = true; | ||
| } | ||
| else if (current_msg->data != 0 || brake_msg->data != 0) | ||
| { | ||
| previous_mode_speed_ = false; | ||
| } | ||
| } | ||
|
|
||
| template <typename T> | ||
| inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value) | ||
| inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value) | ||
| { | ||
| if (nh.getParam(name, *value)) | ||
| if (nh.getParam(name, value)) | ||
| return true; | ||
|
|
||
| ROS_FATAL("AckermannToVesc: Parameter %s is required.", name.c_str()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.