Is the new Raspberry Pi AI Kit better than Google Coral?
128827 Views
Build Your Own AI Assistant Part 1 - Creating the Assistant
120382 Views
Control Arduino with Python using Firmata / PyFirmata
88230 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
62460 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
58121 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
53235 Views
Pico Plotter
LEGO Gets Lights & Sound with Tiny FX
Thinkman
Podman vs Docker
MicroPython Robotics
Bottango and Isaaca
Getting Started with C on the Raspberry Pi Pico
0h 20m
Running K3s on Raspberry Pi
0h 36m
From Docker to Podman
0h 28m
MicroPython Robotics Projects with the Raspberry Pi Pico
0h 24m
Bottango Basics
0h 22m
Mini-Rack 3D Design Tutorial
Learn how to Program in Python, C, Rust, and more.
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 >
You can use the arrows ← → on your keyboard to navigate between lessons.
← →