/project-rover

Tracked UGV with ROS2 and Arduino

Primary LanguageC++

Rover with ROS2

Test platform for robotics

alt text

alt text alt text alt text

https://tlk-energy.de/blog/pid-regler-einstellen https://github.com/joshnewans/ros_arduino_bridge/tree/main https://www.youtube.com/watch?v=-PCuDnpgiew https://www.youtube.com/watch?v=bsB5shP3vls Synchronizing Motor Position with Encoders, PID Control and Arduino

https://articulatedrobotics.xyz/mobile-robot-full-list/

Arduino Encoder Motor Ros

https://github.com/joshnewans/ros_arduino_bridge/blob/main/ROSArduinoBridge/sensors.h https://github.com/jumejume1/dc-motor-encoder https://github.com/EwingKang/Simple-ROS-Arduino-odometry/blob/master/arduino_files/serial_odom/wheel.h https://github.com/JeelChatrola/Control-of-motor-with-ROS https://github.com/JeelChatrola/Control-of-motor-with-ROS/blob/master/Motor%2Bencoder_rosserial.ino https://forum.arduino.cc/t/pid-controller-speed-control-for-a-dc-motor-with-encoder/985306/15 https://automaticaddison.com/how-to-publish-wheel-odometry-information-over-ros/ https://www.youtube.com/watch?v=SiIDwKyg7pQ ROS Odometry example using ROSSerial Arduin

Electronics

Custom parts:

https://github.com/yohendry/arduino_L298N
https://fritzing.org/projects/hc-sr04-project
https://forum.fritzing.org/t/dc-motor-with-two-phase-encoder/3776
https://forum.fritzing.org/t/look-for-fritzing-part-12v-lithium/16352

To buy

2x Getriebemotor DC 12V Mit Encoder 130 RPM Metall Getriebe Motor GA25-370
1x 3-Axis Digital Compass HMC5883L
3x HC-SR04 Ultrasonic Sensor
1x L298N Bridge

ChatGPT ....

The reason to modify the Timer/Counter Control Register B (TCCR1B) using TCCR1B = TCCR1B & 0b11111000 | 1; in an Arduino sketch is to change the Timer1 prescaler value, which affects the speed at which the timer increments its counter.

By setting the prescaler to "1" (no prescaling), Timer1 will run at the same frequency as the microcontroller's clock. This is useful in certain applications that require high-resolution timing or fast timer operation. Here are some possible scenarios where you might want to set the Timer1 prescaler to 1:
High-resolution timing: If you need to measure time intervals with high precision or generate precise timing signals, setting the prescaler to 1 will give you the highest possible timer resolution. For example, on an Arduino Uno with a 16 MHz clock, this would result in a timer resolution of 62.5 nanoseconds.
Frequency generation: If you want to generate a specific frequency or waveform using the timer, setting the prescaler to 1 allows you to achieve higher frequencies. This is useful for applications such as generating audio tones, PWM signals, or communication protocols that require specific frequencies.
Fast interrupt generation: If you want to use the timer to trigger periodic interrupts at a high frequency, setting the prescaler to 1 allows you to generate interrupts at a faster rate. This can be useful for applications such as high-speed data acquisition, real-time control, or fast-paced animations.
Custom timer behavior: In some cases, you may want to have full control over the timer's behavior to implement custom functionality or optimize the performance of your application. By setting the prescaler to 1, you have the most flexibility in terms of timer configuration and operation.

Keep in mind that setting the Timer1 prescaler to 1 may not always be appropriate, as it may consume more power and require more CPU resources to manage the timer and its associated interrupts. Additionally, using the timer at high frequencies may limit the maximum time interval that can be measured or generated due to the timer's limited counter size (16 bits for Timer1 on an ATmega328P). It's essential to consider these factors and choose the appropriate prescaler value based on your specific application requirements.


In an Arduino sketch, the line PORTD |= (1 << LEFT_ENC_PIN_A); is used to set a specific bit in the PORTD register, corresponding to the pin number defined by LEFT_ENC_PIN_A. This line effectively sets the pin to HIGH (5V) without affecting other pins in the same port. Let's break down the expression step by step:
LEFT_ENC_PIN_A: This is a constant or variable that represents the pin number associated with the left encoder's A channel. The value should be between 0 and 7, corresponding to the digital pins D0-D7 on the Arduino Uno, which are associated with PORTD.
1 << LEFT_ENC_PIN_A: This operation performs a left bit shift on the number 1 by the number of positions specified by LEFT_ENC_PIN_A. This effectively creates a binary number with a single bit set to 1 at the position corresponding to the pin number. For example, if LEFT_ENC_PIN_A is 3, the result will be 0b00001000.
PORTD |= ...: This operation performs a bitwise OR between the current value of the PORTD register and the result of the previous step (the binary number with a single bit set to 1). This sets the specified bit in PORTD to 1 (HIGH) without changing the other bits, effectively setting the desired pin to HIGH.

In summary, PORTD |= (1 << LEFT_ENC_PIN_A); is an Arduino sketch line that sets the pin corresponding to LEFT_ENC_PIN_A in PORTD to HIGH without affecting other pins in the same port. This method of manipulating pins is faster than using the digitalWrite() function but requires more knowledge of the microcontroller's registers and bitwise operations.

Author: cmb87