Build Your Own AI Assistant Part 1 - Creating the Assistant
116316 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
111570 Views
Control Arduino with Python using Firmata / PyFirmata
86865 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
56603 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
52712 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
51798 Views
Weather Station Display
Pi 10 Inch Mini-rack
Installing and Using DeepSeek-R1:1.5 on a Raspberry Pi with Docker
Gamepad & BurgerBot
Level Up your CAD Skills
Operation Pico
Mini-Rack 3D Design Tutorial
0h 20m
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
72% Percent Complete
By Kevin McAleer, 4 Minutes
Type the following code:
bg.box(bounds=[-2, 7, 2, 11])
This will draw a box with the following coordinates:
The box will be drawn in the top right corner of the drawing area.
The box will be sligthy swiggly, because the BrachioGraph is not perfectly calibrated, and because thats part of the charm of a BrachioGraph drawing. The box should be around 4cm by 4cm.
The BrachioGraph library has a few test patterns and images we can try out. Here are a few examples:
bg.test_pattern()
Note that the grid that is drawn will be wobbley and imperfect. This is because the BrachioGraph needs to be tighted up to remove some of the slack. To do this you can attach the small screws that came with the Servos to the inner and outer arms of the BrachioGraph. This will help to remove some of the slack in the arms and make the drawing more accurate.
Now that we have a basic understanding of how to draw with the BrachioGraph, we can start to draw our first image. We will start with a simple image of the BrachioGraph library creator.
The BrachioGraph doesn’t know how to draw pictures directly; they need to be converted into a series of points that the BrachioGraph can draw. We’ll learn how to do that shortly, but first lets try to plot our first image.
bg.plot_file("images/demo.json")
Let’s start by creating a file to store your custom BrachioGraph configuration. In the same directory as brachiograph.py, create a new file named custom.py.
brachiograph.py
custom.py
In custom.py, import the BrachioGraph class and create an instance with the specific pulse-width values you used earlier. Here’s an example:
BrachioGraph
from brachiograph import BrachioGraph bg = BrachioGraph( servo_1_parked_pw=1570, servo_2_parked_pw=1450, )
Save this file. From now on, you can initialize your BrachioGraph in the Python shell using this custom definition. Try it out:
from custom import bg
Next, we’ll work on improving the machine’s performance. Due to the limited power of the motors and the inherent flex in the arms and plastic gears, you might notice some slack in the system. This often causes the arms to fall short of their target positions. When approached from the opposite direction, the error appears on the other side of the target. This phenomenon is known as hysteresis.
To counteract hysteresis, we can command the motors to slightly overshoot their targets. Update your BrachioGraph definition in custom.py to include hysteresis correction:
from brachiograph import BrachioGraph bg = BrachioGraph( servo_1_parked_pw=1570, servo_2_parked_pw=1450, hysteresis_correction_1=10, hysteresis_correction_2=10, )
Restart the Python shell, import your custom-defined BrachioGraph again:
Test the improved performance by running the test pattern in both directions:
bg.test_pattern(both=True)
You should see better results now. Experiment with hysteresis correction values between 7 and 20 to find the optimal settings. Remember to restart the Python shell and re-import the definition each time you make changes.
The default BrachioGraph definition assumes a 10 µs change in pulse-width corresponds to a 1-degree change in the motor’s position. However, in practice, this might not be entirely accurate, causing distortions in your drawings.
To correct this, first ensure that when you call bg.park(), the inner arm is exactly at -90Ëš. Then, execute:
bg.park()
bg.set_angles(angle_1=0)
Check if the inner arm is precisely at 0Ëš. If not, adjust angle_1 until it is. Determine the actual pulse-width value needed to reach 0Ëš and subtract it from the -90Ëš pulse-width value. This gives you the pulse-width difference required for a 90Ëš movement. Divide this difference by 90 to find the pulse-width change per degree.
angle_1
Perform a similar calibration for the outer arm. Once you have these values, update your custom.py file as follows:
from brachiograph import BrachioGraph bg = BrachioGraph( servo_1_parked_pw=1570, servo_2_parked_pw=1450, hysteresis_correction_1=10, hysteresis_correction_2=10, servo_1_degree_ms=-9.8, servo_2_degree_ms=10.1, )
Notice that the value for servo_1_degree_ms might be negative. This is because one of the servos could be mounted upside-down. If the sign is incorrect, the arm will move in the opposite direction.
servo_1_degree_ms
With these adjustments, your BrachioGraph should now function more accurately, providing more precise and consistent drawings.
< Previous Next >