title: Python bit manipulation to get usable data out of a lidar sensor
body: <p>I am trying to write a python driver for a lidar sensor that only has a <a href="https://github.com/CygLiDAR-ROS/cyglidar_d1" rel="nofollow noreferrer">package</a> for robot OS.</p>
  <p>I was able to get the communication working on a Raspberry Pi and I am getting the data that I need.</p>
  <p>I never really worked with bytearrays before and even python is pretty new to me.</p>
  <p><a href="https://i.stack.imgur.com/8q6x4.png" rel="nofollow noreferrer">The received data looks like this</a> (png), but you can take a look at the <a href="https://fd6aa090-08e4-4c9f-a327-e251ecc274f3.filesusr.com/ugd/f5911d_726a54fc4f6644bcbec0d9b00236ffda.pdf" rel="nofollow noreferrer">documentation</a> (pdf) as well.</p>
  <p>So if I'm not mistaken, I have to combine three bits into two like this:</p>
  <pre><code>[0x5D, 0xC7, 0xD0] =&gt; [0x5DC, 0x7D0]
  </code></pre>
  <p>I think the aforementioned robot OS library does this <a href="https://github.com/CygLiDAR-ROS/cyglidar_d1/blob/v0.1.3/src/cyglidar_pcl_publisher.cpp#L459" rel="nofollow noreferrer">here</a>, but my c++ is even worse than my python :)</p>
  <p>After I have the correct data I want to sort it into a 2D array but that's not a problem.</p>
  <p>Can you point me in the right direction, or just suggest how to search for a solution?</p>
  <p>Thank you for your help</p>