uvic-auvic / RedHerring

Red Herring Project Code
1 stars 6 forks source link

Depth_sensor code #118

Closed jwlower closed 6 years ago

jwlower commented 7 years ago

Added firmware for depth sensor

asinha94 commented 7 years ago

Could you rosify 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).

Main function

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();
    }

}
asinha94 commented 7 years ago

Btw I never got around to fixing the comments on the motor controller code, so don't look into there for answers