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

Closes #195: Create A Driver for URM04 Sensor #232

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

niiquaye
Copy link
Contributor

@niiquaye niiquaye commented Jan 1, 2021

This is working version for the urm04 driver

@niiquaye niiquaye linked an issue Jan 1, 2021 that may be closed by this pull request
@cindyli-13
Copy link
Member

Can you include a link to the URM04 reference page?

@wmmc88
Copy link
Member

wmmc88 commented Jan 2, 2021

please have meaningful PR titles

Copy link
Contributor

@younesr1 younesr1 left a comment

Choose a reason for hiding this comment

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

hey i left some comments.make sure to take advantage of vs code's replace all functionality to implement some of the changes like prefix private members with m_

CMakeLists.txt Show resolved Hide resolved
apps/test-pwm/CMakeLists.txt Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
apps/test-urm04/src/main.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
@younesr1
Copy link
Contributor

younesr1 commented Jan 3, 2021

Orson and I found this driver that is much cleaner than the arduino code. seems to have less random waits and better defined functions. I think orson wil try and replicate this driver moving forward: https://github.com/vrxfile/ultrasonic_rs485_sensor_api/blob/master/main.cpp

@niiquaye
Copy link
Contributor Author

niiquaye commented Jan 3, 2021

Sample Code for URM04Sensor
Sample Arduino Code

This Fourth Commit follows the 'Sample Code for URM04Sensor' the code makes a lot more sense and is easier to understand.
However, The question remains if I need to clear the serial buffer every time I read and write to it.

lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
@niiquaye
Copy link
Contributor Author

niiquaye commented Jan 4, 2021

In this commit I added writing high or low to the trig_pin because apparently this is needed to trigger the reading mode and transmitting mode for the RS485 interface as seen in this documentation here. Just want to make sure that this is correct ?

apps/test-urm04/src/main.cpp Outdated Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
@niiquaye niiquaye requested a review from cindyli-13 January 10, 2021 23:14
@niiquaye niiquaye changed the title First Commit Closes #195: Create A Driver for URM04 Sensor Jan 10, 2021
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/include/URM04Sensor.h Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
@niiquaye niiquaye requested a review from cindyli-13 January 12, 2021 03:49
@niiquaye
Copy link
Contributor Author

niiquaye commented Jan 12, 2021

@cindyli-13 finished implementing the requested changes. After resolving some git issues.

lib/sensors/src/URM04Sensor.cpp Outdated Show resolved Hide resolved
URM04Sensor::URM04Sensor sensor(D2, D0, D1);
float distance_cm;
while (1) {
sensor.read_distance(distance_cm); // measurements returned in Centimeters
Copy link
Member

Choose a reason for hiding this comment

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

@younesr1 Is it ok if the ultrasonic sensor read is blocking?

@niiquaye niiquaye marked this pull request as draft January 18, 2021 01:19
	The serial was not being flushed properly as
	it was being called after function returned.
	Thus, I moved it before function returns.
@niiquaye niiquaye requested a review from cindyli-13 January 18, 2021 02:21
Copy link
Member

@cindyli-13 cindyli-13 left a comment

Choose a reason for hiding this comment

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

Lgtm! Were you able to test the sensor with the nucleo? We should also probably confirm that the blocking read call is acceptable for our purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create URM04 Ultrasonic Sensor Driver
4 participants