Camera and Sonar Board Installation

There are two versions of Magni. The Silver version comes with a sonar short range obstacle avoidance system, and the Gold version (not yet available) adds an IR long range obstacle avoidance package. Both versions come with a Raspberry Pi Camera. The camera is needed for fiducial follow, partybot and waypoint navigation, and other apps you may write.

When reconfiguring hardware disconnect the battery cables from the batteries and wait 5 minutes so no live voltage is present on the main board

Sonar Board Cable And Camera Assembled

The picture below shows the Raspberry Pi camera in the forward orientation and the cable to the Sonar board included with Magni Silver. This is a very popular configuration for Magni.

Magni Sonar To Mcb With Camera

Camera Installation

Camera Installation The Raspberry Pi camera can be mounted and configured to work in different orientations. From the start of the Magni robot there have been 2 popular orientations. The forward camera mounting points forward but also tilts up about 20 degrees. This enables Magni to view things in front such as fiducials in the Fiducial Follow application. When the robot is to be navigating in a space with fiducial patterns on the ceiling the upward mounting is used.

Magni Camera Forward And Upward Mounting


Notice that in both orientations that the cable was routed through the slots in the metal bracket. The camera is screwed to fixed standoffs using M2 screws 3 or 4mm in length. The white side of the flat cable is towards the top of the board and below there is a blue piece of tape on the cable. The cable must be inserted as shown in order to properly connect the camera. Make sure the cable goes all the way in as it can seem to be in but not fully making contact.

The Magni software must be configured to set usage of any camera mounting other than the forward configuration. If you for example use the upward facing camera you must edit the /etc/ubiquity/robot.yaml file as root user and change the line for the raspicam orientation.

sudo nano /etc/ubiquity/robot.yaml

The line would be as shown below and a reboot of the robot is required. There must be a space between the colon and the left bracket.

raspicam: {'position':'upward'}

Take care when removing the pi to gently rock it back and forth after unscrewing it's screw that goes into a standoff on the main board. BE CAREFUL TO AVOID application of ANY PRESSURE to the very thin Micro SD card inserted in the right side of the Pi because it sticks out. It is very easy to break the SD card in this process if your fingers push on the SD card.

Next attach the cable to the Pi; the ‘blue’ part of the cable faces toward the USB ports. Make sure the cable goes all the way in as it can seem to be inserted but not fully making contact.

Raspberry Pi with Camera Cable

Next reinstall the Pi, making sure the pins are aligned correctly as in the picture below. (Misaligned pins will cause permanent failure!)

Magni Sonar Board

Testing the camera.

If you find that fiducial follow or waypoint navigation launch files have errors early on for the camera, you may want quick way to test the camera. You can first open an ssh session to the robot and then try the following command:

raspistill -o test.jpg

If you don’t get an error message, you have a good camera. An (mmal) error message indicates the camera is not being detected by the Raspberry Pi, this is usually due to a poor cable connection or less likely a bad camera.

If you have a laptop running ROS where the robot is the ROS master then you may have or want to install image_view on the laptop to see the camera output fairly easily. Briefly if image_view is on your laptop and configured use this:

rosrun image_view image_view image:=/raspicam_node/image

If you know how to use rviz on the laptop that too can be configured to show you the camera image but that is a bit more complex.

Camera Calibration

Sometimes for best performance or certainly if a different type of camera than the robot has from the factory you may want or need to do a camera calibration. The calibration is used to flatten the field. All camera lenses introduce optical distortion some people refer to as fish eye distortion. The shorter the focal length the greater the field of view but along with that comes greater fish eye distortion.

To perform this calibration please see our ‘Calibration’ section in the readme in our raspicam github repository where we explain that our camera must be running the raspicam node and publishing raw camera data. Then on a laptop setup as a ROS node where the robot is the ROS master a camera_callibrator program is run.

The link above will point to a ROS calibration process that is used for the calibration itself once our raspicam node is publishing images. One thing that can surprise people is after it has been indicated the program has enough data to do the calibration you will click the ‘Calibrate’ button. What happens then can take a great many minutes to complete and it appears that the camera_callibrator program is hung up but in fact it has to do a great many calculations so give it time.

The ROS page with calibration is the Monocular Calibration Page

Sonar Board Attachment To The Robot

Below is a picture of the Sonar board included with Magni Silver configuration. This section will show how the Sonar Board is mounted on tall standoffs and a 50-pin ribbon cable is then attached. The sonar board is included in the large box for a Magni Silver but is not attached to the robot prior to shipment. Be careful to avoid the need to often re-bend the sonars if they bump something because the pins can only be bent and re-bent a limited number of times.

Magni Sonar Board

The Magni software must be configured to enable usage of the sonar board. You must edit the robot.yaml file as root user then modify the file.

sudo nano /etc/ubiquity/robot.yaml

Make an edit so the only uncommented line with sonars: in it is as shown below. There must be a space after the colon or it will not work.

sonars: 'pi_sonar_v1'

The Sonar board is mounted to the chassis using just 4 standoffs. Only the two standoffs to the sides that will have large pads with holes on the sonar board for 3mm standoffs are to be used. This description will show the 2 standoffs on the right but two other standoffs on the left also at the 45 degree angle are used as well.

If you get your robot with a standoff screwed into the front top bar of the robot in the middle location REMOVE THAT STANDOFF because it will cause a SHORT CIRCUIT to parts in the middle of the Sonar board. The middle standoff is used ONLY for a board that sits below the Sonar board

The standoffs and the M3 screws are shown below for reference.

Magni Standoff Reference

The 4 standoffs screw into the fixed nuts on the chassis. The picture below shows the 2 standoff locations on right and the 2 on the left. Center standoff is NOT used.

There is also no need to load the large fuse on the back of the board for just the Sonar board and we recommend removing F701 if it is loaded for when you only have the Sonar board (Up to 2020 that was always the case). The fuse allows 24V to get routed to other boards that sometimes can sit below the sonar board but it is best safety to just remove that fuse.

Magni Sonar Board Standoffs

Below is shown the right side of the sonar board fully mounted using the M3 standoffs and M3 screws from the top.

Magni Sonar Board Mounted On Standoffs

The ribbon cable is then inserted into the main Magni board as shown in the picture below where it will be plugged into the Sonar board as the final step.

Magni Sonar Board Cable From Main Pc Ready

Be sure the 50 pin ribbon cable is fully inserted into both the main Magni board as well as the Sonar board. It can be held up due to being tight or having bent pins. Notice how far they should go into the jacks, about 5mm or so, as shown from the side in the picture below and also shown as first picture on this page.

Magni Sonar Board Cable From Main Pc Ready

LED1 is for the wifi but if you do not see that start to blink within around 15 seconds after a fresh power up case there may be something not connected on the 50 pin cable.

Lastly attach the cover plate with 6 M6 screws using an M4 Allen wrench. You are done, hooray!