mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 19:24:09 +05:30
Merge pull request #41 from Sunlcy/indigo-devel
Fix #40 issue and add .gitignore file
This commit is contained in:
commit
641e015b4e
106
.gitignore
vendored
Normal file
106
.gitignore
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/python
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# dotenv
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
.venv
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# End of https://www.gitignore.io/api/python
|
||||
# temporary files
|
||||
*~
|
@ -43,7 +43,7 @@ class ArduinoROS():
|
||||
self.baud = int(rospy.get_param("~baud", 57600))
|
||||
self.timeout = rospy.get_param("~timeout", 0.5)
|
||||
self.base_frame = rospy.get_param("~base_frame", 'base_link')
|
||||
|
||||
self.motors_reversed = rospy.get_param("~motors_reversed", False)
|
||||
# Overall loop rate: should be faster than fastest sensor rate
|
||||
self.rate = int(rospy.get_param("~rate", 50))
|
||||
r = rospy.Rate(self.rate)
|
||||
@ -91,7 +91,7 @@ class ArduinoROS():
|
||||
rospy.Service('~analog_read', AnalogRead, self.AnalogReadHandler)
|
||||
|
||||
# Initialize the controlller
|
||||
self.controller = Arduino(self.port, self.baud, self.timeout)
|
||||
self.controller = Arduino(self.port, self.baud, self.timeout, self.motors_reversed)
|
||||
|
||||
# Make the connection
|
||||
self.controller.connect()
|
||||
|
@ -38,7 +38,7 @@ class Arduino:
|
||||
N_ANALOG_PORTS = 6
|
||||
N_DIGITAL_PORTS = 12
|
||||
|
||||
def __init__(self, port="/dev/ttyUSB0", baudrate=57600, timeout=0.5):
|
||||
def __init__(self, port="/dev/ttyUSB0", baudrate=57600, timeout=0.5, motors_reversed=False):
|
||||
|
||||
self.PID_RATE = 30 # Do not change this! It is a fixed property of the Arduino PID controller.
|
||||
self.PID_INTERVAL = 1000 / 30
|
||||
@ -49,7 +49,7 @@ class Arduino:
|
||||
self.encoder_count = 0
|
||||
self.writeTimeout = timeout
|
||||
self.interCharTimeout = timeout / 30.
|
||||
|
||||
self.motors_reversed = motors_reversed
|
||||
# Keep things thread safe
|
||||
self.mutex = thread.allocate_lock()
|
||||
|
||||
@ -270,6 +270,8 @@ class Arduino:
|
||||
raise SerialException
|
||||
return None
|
||||
else:
|
||||
if self.motors_reversed:
|
||||
values[0], values[1] = -values[0], -values[1]
|
||||
return values
|
||||
|
||||
def reset_encoders(self):
|
||||
@ -280,6 +282,8 @@ class Arduino:
|
||||
def drive(self, right, left):
|
||||
''' Speeds are given in encoder ticks per PID interval
|
||||
'''
|
||||
if self.motors_reversed:
|
||||
left, right = -left, -right
|
||||
return self.execute_ack('m %d %d' %(right, left))
|
||||
|
||||
def drive_m_per_s(self, right, left):
|
||||
@ -374,4 +378,3 @@ if __name__ == "__main__":
|
||||
myArduino.close()
|
||||
|
||||
print "Shutting down Arduino."
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user