Sunday, March 28, 2021

todo list

 I think I have figured out how to make topics in ROS. I think they are created implicitly when you define messages in nodes or elsewhere. But I'll have to verify that.


Let's outline our todo list:

First I want to create a publisher node on the pi that can publish an array of 4 velocities (one for each wheel).

Then I want to make a subscriber node on the arduino that can receive it. Then I want the arduino to be able to break that information down into commands for the motor controller. So if I get an array of [-1.0, +2.0, -1.0, +2.0] I want to translate that from cm/s to a pwm value and a direction. The PWM value is from 0 to 255, and I don't actually know how fast the robot can go as of right now. It is underpowered, I am not using 12V but more like 9.5. My batteries are 8*1.2 so my best voltage is 9.6. So I have no idea how fast it will go under all of the weight.

To translate all of that stuff I might want a library as my code is getting increasingly ugly. There are some L298n libararies out there, but I am unsure about them.

Then once the arduino can run based on pi input, I will need to make another node that reads values from the encoders. Then I will create a new message type that can send an array of four integers to the pi. I got in touch with the company that sells the robot and they said that there are 11 pulses per turn in the motors. I find this very puzzling since the encoder library I'm using gave me 1200. 

So basically I will create a publisher that will send an array to another node on the pi. This node on the pi will then do the math and calculate stuff like speed and position.


This is where the fun begins! 

Then I can use that to create a PID control node that will correct the robot speed based on the odometry data!

Friday, March 19, 2021

ROS node communication

Alright, its been a while since my last update. I have started a new job and moved to a different city, so I have not been able to work on the robot that much lately. I'm also hitting a difficult part of the process. I can now start thinking about the different nodes in the robot operating system and the computation that each of them will do.

 

Last time I left off trying to figure out serial communication. The way that it is done between the raspberry pi and the arduino is to make the arduino into a node on the ROS. In ROS the computation is distributed across nodes, which allows us to compartmentalize certain functions of the robot. In my case the Arduino is responsible to spinning the motors and reading the encoders. It would also be smart to connect my ultrasonic distance sensor to it, but I don't want to rewire it. 

So the arduino for now is just going to send the data from the magnetic encoders on the wheels. Each encoder has about 200 ticks per revolution. That is a relatively small number and I can send it using what is called a message in ROS. 

You see, the nodes in ROS communicate via messages, that have a certain format. Similar to conversations between people the messages pertain to a topic. For example the topic could be velocity and the message is 2 m/s. 

So I will use a standard message type int16 to send numbers in range of -200 to 200. Then another node on the raspberry pi will receive it and translate it to stuff like distance travelled. If I have the time stamped on these messages I will also be able to figure out how fast the robot is going assuming the wheels don't slip.

NEW Project Autonomous underwater vehicle!

  I have been more and more interested in Autonomous Underwater Vehicles and ocean exploration. I live on the coast with direct access to th...