-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into noetic-desktop
- Loading branch information
Showing
4 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
Submodule .travis
updated
7 files
+1 −1 | .travis.yml | |
+11 −0 | CHANGELOG.rst | |
+1 −1 | action.yml | |
+1 −1 | package.xml | |
+12 −0 | rosdep_snapshots/30-bionic.list | |
+12 −0 | rosdep_snapshots/30-xenial.list | |
+4 −1 | travis.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
demos/sphand_ros/sphand_driver/arduino/test_palm_v8/test_palm_v8.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
demos/sphand_ros/sphand_driver/arduino/test_wrpps_single_board/test_wrpps_single_board.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include <Wire.h> | ||
#include <VL53L0X.h> // Search and install VL53L0X on library manager of Arduino IDE | ||
// https://github.com/pololu/vl53l0x-arduino | ||
|
||
/***** GLOBAL CONSTANTS *****/ | ||
|
||
#define VCNL4040_ADDR 0x60 //7-bit unshifted I2C address of VCNL4040 | ||
|
||
//Command Registers have an upper byte and lower byte. | ||
#define PS_CONF1 0x03 | ||
//#define PS_CONF2 //High byte of PS_CONF1 | ||
#define PS_CONF3 0x04 | ||
//#define PS_MS //High byte of PS_CONF3 | ||
#define PS_DATA_L 0x08 | ||
//#define PS_DATA_M //High byte of PS_DATA_L | ||
|
||
VL53L0X tof_sen; | ||
|
||
void measure_proximity() | ||
{ | ||
startProxSensor(); | ||
delay(10); | ||
Serial.print("intensity"); | ||
Serial.print(": "); | ||
Serial.print(readFromCommandRegister(PS_DATA_L)); | ||
Serial.print(", "); | ||
stopProxSensor(); | ||
delay(1); | ||
} | ||
|
||
void initVCNL4040() | ||
{ | ||
delay(1); | ||
//Set the options for PS_CONF3 and PS_MS bytes | ||
byte conf3 = 0x00; | ||
byte ms = 0b00000001; //Set IR LED current to 75mA | ||
//byte ms = 0b00000010; //Set IR LED current to 100mA | ||
//byte ms = 0b00000110; //Set IR LED current to 180mA | ||
//byte ms = 0b00000111; //Set IR LED current to 200mA | ||
writeToCommandRegister(PS_CONF3, conf3, ms); | ||
} | ||
|
||
void startProxSensor() | ||
{ | ||
//Clear PS_SD to turn on proximity sensing | ||
//byte conf1 = 0b00000000; //Clear PS_SD bit to begin reading | ||
byte conf1 = 0b00001110; //Integrate 8T, Clear PS_SD bit to begin reading | ||
byte conf2 = 0b00001000; //Set PS to 16-bit | ||
//byte conf2 = 0b00000000; //Clear PS to 12-bit | ||
writeToCommandRegister(PS_CONF1, conf1, conf2); //Command register, low byte, high byte | ||
} | ||
|
||
void stopProxSensor() | ||
{ | ||
//Set PS_SD to turn off proximity sensing | ||
byte conf1 = 0b00000001; //Set PS_SD bit to stop reading | ||
byte conf2 = 0b00000000; | ||
writeToCommandRegister(PS_CONF1, conf1, conf2); //Command register, low byte, high byte | ||
} | ||
|
||
//Reads a two byte value from a command register | ||
unsigned int readFromCommandRegister(byte commandCode) | ||
{ | ||
Wire.beginTransmission(VCNL4040_ADDR); | ||
Wire.write(commandCode); | ||
Wire.endTransmission(false); //Send a restart command. Do not release bus. | ||
|
||
Wire.requestFrom(VCNL4040_ADDR, 2); //Command codes have two bytes stored in them | ||
|
||
unsigned int data = Wire.read(); | ||
data |= Wire.read() << 8; | ||
|
||
return (data); | ||
} | ||
|
||
//Write a two byte value to a Command Register | ||
void writeToCommandRegister(byte commandCode, byte lowVal, byte highVal) | ||
{ | ||
Wire.beginTransmission(VCNL4040_ADDR); | ||
Wire.write(commandCode); | ||
Wire.write(lowVal); //Low byte of command | ||
Wire.write(highVal); //High byte of command | ||
Wire.endTransmission(); //Release bus | ||
} | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
Wire.begin(); | ||
|
||
initVCNL4040(); //Configure sensor | ||
tof_sen.init(); | ||
tof_sen.setTimeout(500); | ||
} | ||
|
||
void loop() | ||
{ | ||
measure_proximity(); | ||
Serial.print("tof"); | ||
Serial.print(": "); | ||
Serial.print(tof_sen.readRangeSingleMillimeters()); | ||
if (tof_sen.timeoutOccurred()) | ||
{ | ||
Serial.print("TIMEOUT"); | ||
} | ||
Serial.println(); | ||
} |