<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ros | Blue Duck Valley Rd</title><link>https://juju.nz/michaelh/tags/ros/</link><atom:link href="https://juju.nz/michaelh/tags/ros/index.xml" rel="self" type="application/rss+xml"/><description>ros</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>© 2017-2025 Michael Hope</copyright><lastBuildDate>Sat, 23 May 2020 00:00:00 +0200</lastBuildDate><image><url>img/map[gravatar:%!s(bool=false) shape:circle]</url><title>ros</title><link>https://juju.nz/michaelh/tags/ros/</link></image><item><title>Pan/tilt mount for a cell phone</title><link>https://juju.nz/michaelh/post/2020/pudel/</link><pubDate>Sat, 23 May 2020 00:00:00 +0200</pubDate><guid>https://juju.nz/michaelh/post/2020/pudel/</guid><description>&lt;p>I think it&amp;rsquo;s important to also post about the projects that didn&amp;rsquo;t
turn out. Pudel was a project to automatically track and video a
model plane using a cell phone camera.&lt;/p>
&lt;p>&lt;img src="mount.jpg" alt="mount">&lt;/p>
&lt;p>The pan and tilt components were modeled in
&lt;a href="https://openscad.org/" target="_blank" rel="noopener">OpenSCAD&lt;/a> and 3D printed. The pan unit had a
standard
&lt;a href="https://www.matrix-vision.com/manuals/mvBlueFOX/mvBF_page_tech.html" target="_blank" rel="noopener">1/4-20 tripod mount&lt;/a> and the tilt unit had a Samsung
A40 mount that I&amp;rsquo;ve used on a few other projects.&lt;/p>
&lt;p>&lt;img src="closeup.jpg" alt="close">&lt;/p>
&lt;p>Both were driven by standard
&lt;a href="https://hitecrcd.com/products/servos/sport-servos/analog-sport-servos/hs-422/product" target="_blank" rel="noopener">HS-422&lt;/a> servos with a
&lt;a href="https://www.adafruit.com/product/3500" target="_blank" rel="noopener">Trinket M0&lt;/a>
for I/O and a 2S LiPo through a
&lt;a href="https://hobbyking.com/en_us/turnigy-3a-ubec-w-noise-reduction.html?___store=en_us" target="_blank" rel="noopener">6V BEC&lt;/a> for power.&lt;/p>
&lt;p>The I/O board ran
&lt;a href="https://circuitpython.org/" target="_blank" rel="noopener">CircuitPython&lt;/a> with custom firmware that takes
MIDI-like messages as servo commands. It implemented an
acceleration limiter and velocity limiter to limit the
&lt;a href="https://en.wikipedia.org/wiki/Jerk_%28physics%29" target="_blank" rel="noopener">jerk&lt;/a>, as the servos are capable of 60 deg/0.2 s which is much
faster than the plane would move.&lt;/p>
&lt;p>The host side was going to be similar to Kieferbot and use ROS with an
IO specific node, OpenCV based detection, and a PID controller to keep
the plane centered in the frame.&lt;/p>
&lt;p>So why did it fail?&lt;/p>
&lt;ul>
&lt;li>The servos aren&amp;rsquo;t intended for precise, slow movement and hence had
mild jerk.&lt;/li>
&lt;li>There was too much slack in the mechanics, and the phone was mildly
heavy, so mild jerk caused the phone to move about too much.&lt;/li>
&lt;li>The plane is too small to resolve on a wide angle lens, so tracking
was unlikely to work.&lt;/li>
&lt;/ul>
&lt;p>If I wanted to take it further, I can imagine some improvements:&lt;/p>
&lt;ul>
&lt;li>Take the load off the pan servo. The tilt unit sits directly on top
of the pan servo shaft and there&amp;rsquo;s not much material to sit on which
increased the shake. Perhaps add a turntable style plates that most
of the downwards force could go through.&lt;/li>
&lt;li>Decrease the arm length out to the phone. It&amp;rsquo;s 30 mm and reducing
to 20 mm would reduce the load on the tilt servo.&lt;/li>
&lt;li>Try a phone with optical stabilization.&lt;/li>
&lt;/ul></description></item><item><title>Tracking using a camera</title><link>https://juju.nz/michaelh/post/2020/tracking/</link><pubDate>Sun, 19 Apr 2020 00:00:00 +0200</pubDate><guid>https://juju.nz/michaelh/post/2020/tracking/</guid><description>&lt;p>Here&amp;rsquo;s Kieferbot being tracked through a camera:&lt;/p>
&lt;p>&lt;video controls src="tracking.mp4">&lt;/video>&lt;/p>
&lt;p>It took a few iterations but I settled on matching the colour of the
floor to create a floor mask, then
&lt;a href="https://docs.opencv.org/trunk/d4/d73/tutorial_py_contours_begin.html" target="_blank" rel="noopener">findCountours&lt;/a> to find the
contours as a tree, and then searching the children of the root
contours. As the bot is black, the children were matched against a
&amp;lsquo;black pixels&amp;rsquo; mask, and the contour with the most black pixels
picked.&lt;/p>
&lt;p>The camera is an Android phone running
&lt;a href="https://play.google.com/store/apps/details?id=com.pas.webcam&amp;amp;hl=en" target="_blank" rel="noopener">IP Webcam&lt;/a> and sharing
the back camera as MJPEG over HTTP over Wifi at 10 FPS. It could be
higher, but the laptop doing the image processing has trouble keeping
up with 30 FPS. The latency looks good - visually less than 200 ms.&lt;/p>
&lt;p>The tracking seems reliable. If the bot goes off the bottom of the
frame then other black areas are picked, but this can be detected by
checking for a jump in position.&lt;/p>
&lt;p>Next step is to integrate the camera position, phone sensors, and
wheel velocity to get a controllable position.&lt;/p></description></item></channel></rss>