Closed jwlower closed 6 years ago
Could you ros
ify that for me? It looks like your code is an arduino sketch. Here is a good example .
From that piece of code grab the closeSerialConnection, setupSerialConnection and serial_out functions verbatim and copy that into your code. Also grab the main function and delete everything but he first 2 lines (the ros stuff).
Change the name in the first function to something like 'depth_sensor'. Also make sure you have a global variable to your serial_conn (which holds the connection to the depth sensor).
After all the ros setup the depth_sensor node will essentially just poll the firmware so thats where you can use a publisher to stream out the depth. I believe the depth sensor also has the light ring so it will need a service for the light command
pseudo-code. Dont copy as-is
#include <headers>
serial_conn = nullptr
void closeSerialConnection() {...}
void setupSerialConnection() {...}
std::string serial_out () {...}
void turnOnLights() {
// serial_out("On"); // or whatever the firmware command is
}
void getDepth() {
return serial_out("DPH");
}
int main() {
ros::init();
pub depth_sensor_pub = ros::publisher(...);
service lights = ros::serviceServer(...);
while (ros::ok()) {
depth_sensor_pub.publish(getDepth())
ros::spinOnce();
}
}
Btw I never got around to fixing the comments on the motor controller code, so don't look into there for answers
Added firmware for depth sensor