Skip to content
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

Ported the ROS2 fox drivers to ROS1 Noetic #37

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.swp
.vscode/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Veddar VESC Interface
# ROS1 VESC Package

![ROS1 CI Workflow](https://github.com/f1tenth/vesc/workflows/ROS1%20CI%20Workflow/badge.svg)

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)
42 changes: 42 additions & 0 deletions vesc.yaml
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
16 changes: 0 additions & 16 deletions vesc/CHANGELOG.rst

This file was deleted.

23 changes: 12 additions & 11 deletions vesc/package.xml
JWhitleyWork marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<package>
<name>vesc</name>
<version>1.1.0</version>
<version>0.0.1</version>
<description>
Metapackage for ROS interface to the Vedder VESC open source motor controller.
</description>
<maintainer email="[email protected]">Johannes Betz</maintainer>

<maintainer email="[email protected]">Michael T. Boulet</maintainer>
<author email="[email protected]">Michael T. Boulet</author>
<license>BSD</license>

<url type="website">http://www.ros.org/wiki/vesc</url>
<url type="repository">https://github.com/f1tenth/vesc</url>
<url type="bugtracker">https://github.com/f1tenth/vesc/issues</url>
<author email="[email protected]">Michael T. Boulet</author>
<author email="[email protected]">Joshua Whitley</author>
<url type="repository">https://github.mit.edu/racecar/vesc</url>
<url type="bugtracker">https://github.mit.edu/racecar/vesc/issues</url>

<buildtool_depend>catkin</buildtool_depend>

<exec_depend>vesc_driver</exec_depend>
<exec_depend>vesc_msgs</exec_depend>
<exec_depend>vesc_ackermann</exec_depend>
<run_depend>vesc_driver</run_depend>
<run_depend>vesc_msgs</run_depend>
<run_depend>vesc_ackermann</run_depend>

<export>
<metapackage/>
</export>

</package>
22 changes: 0 additions & 22 deletions vesc_ackermann/CHANGELOG.rst

This file was deleted.

31 changes: 9 additions & 22 deletions vesc_ackermann/CMakeLists.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an older version too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
cmake_minimum_required(VERSION 2.8.3)
project(vesc_ackermann)

# Setting C++ standard to 11
if (NOT "${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}")
message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif ("${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}" STREQUAL "98")
message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
set(CMAKE_CXX_STANDARD 11)
endif()

find_package(catkin REQUIRED COMPONENTS
ackermann_msgs
geometry_msgs
nav_msgs
nodelet
pluginlib
roscpp
roslint
nav_msgs
std_msgs
geometry_msgs
tf
ackermann_msgs
vesc_msgs
)

catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS
ackermann_msgs
geometry_msgs
nav_msgs
nodelet
pluginlib
roscpp
nav_msgs#!/usr/bin/env python
std_msgs
geometry_msgs
tf
ackermann_msgs
vesc_msgs
)

Expand All @@ -42,6 +33,7 @@ catkin_package(

include_directories(
include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)

Expand Down Expand Up @@ -70,9 +62,6 @@ target_link_libraries(vesc_ackermann_nodelet
${catkin_LIBRARIES}
)

set(ROSLINT_CPP_OPTS "--filter=-build/c++11")
roslint_cpp()

#############
## Install ##
#############
Expand All @@ -96,6 +85,4 @@ install(DIRECTORY launch/
## Testing ##
#############

if(CATKIN_ENABLE_TESTING)
roslint_add_test()
endif()
# TODO
34 changes: 3 additions & 31 deletions vesc_ackermann/include/vesc_ackermann/ackermann_to_vesc.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
// Copyright 2020 F1TENTH Foundation
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
// and the following disclaimer.
//
// 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.
//
// 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.
//
// 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.

// -*- mode:c++; fill-column: 100; -*-

#ifndef VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
Expand All @@ -37,29 +12,26 @@ namespace vesc_ackermann
class AckermannToVesc
{
public:

AckermannToVesc(ros::NodeHandle nh, ros::NodeHandle private_nh);

private:
// ROS parameters
// conversion gain and offset
bool previous_mode_speed_ = true;
double speed_to_erpm_gain_, speed_to_erpm_offset_;
double accel_to_current_gain_, accel_to_brake_gain_;
double steering_to_servo_gain_, steering_to_servo_offset_;

/** @todo consider also providing an interpolated look-up table conversion */

// ROS services
ros::Publisher erpm_pub_;
ros::Publisher servo_pub_;
ros::Publisher current_pub_;
ros::Publisher brake_pub_;
ros::Subscriber ackermann_sub_;

// ROS callbacks
void ackermannCmdCallback(const ackermann_msgs::AckermannDriveStamped::ConstPtr& cmd);
};

} // namespace vesc_ackermann
} // namespace vesc_ackermann

#endif // VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
#endif // VESC_ACKERMANN_ACKERMANN_TO_VESC_H_
40 changes: 7 additions & 33 deletions vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
// Copyright 2020 F1TENTH Foundation
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
// and the following disclaimer.
//
// 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.
//
// 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.
//
// 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.

// -*- mode:c++; fill-column: 100; -*-

#ifndef VESC_ACKERMANN_VESC_TO_ODOM_H_
#define VESC_ACKERMANN_VESC_TO_ODOM_H_

#include <memory>
#include <string>

#include <ros/ros.h>
#include <vesc_msgs/VescStateStamped.h>
#include <std_msgs/Float64.h>
#include <boost/shared_ptr.hpp>
#include <tf/transform_broadcaster.h>

namespace vesc_ackermann
Expand All @@ -42,6 +15,7 @@ namespace vesc_ackermann
class VescToOdom
{
public:

VescToOdom(ros::NodeHandle nh, ros::NodeHandle private_nh);

private:
Expand All @@ -58,20 +32,20 @@ class VescToOdom

// odometry state
double x_, y_, yaw_;
std_msgs::Float64::ConstPtr last_servo_cmd_; ///< Last servo position commanded value
vesc_msgs::VescStateStamped::ConstPtr last_state_; ///< Last received state message
std_msgs::Float64::ConstPtr last_servo_cmd_; ///< Last servo position commanded value
vesc_msgs::VescStateStamped::ConstPtr last_state_; ///< Last received state message

// ROS services
ros::Publisher odom_pub_;
ros::Subscriber vesc_state_sub_;
ros::Subscriber servo_sub_;
std::shared_ptr<tf::TransformBroadcaster> tf_pub_;
boost::shared_ptr<tf::TransformBroadcaster> tf_pub_;

// ROS callbacks
void vescStateCallback(const vesc_msgs::VescStateStamped::ConstPtr& state);
void servoCmdCallback(const std_msgs::Float64::ConstPtr& servo);
};

} // namespace vesc_ackermann
} // namespace vesc_ackermann

#endif // VESC_ACKERMANN_VESC_TO_ODOM_H_
#endif // VESC_ACKERMANN_VESC_TO_ODOM_H_
Loading