Posts

Showing posts from July, 2024

July 30, 2024

Today, I began by figuring out how to fix the errors I receive when I run the lookup_transform() method. For the past few days, I kept on receiving errors that said that there was a discrepancy between the requested data time and the latest data time and that it would need to do an extrapolation into the future. To solve this, I created a list that would keep track of all of the timestamps when each list was published. Then, when I call the lookup_transform() method, I would pass the second to last timestamp into the method. This way, both of the frames that were published would have timestamps that were after the time in the method. Now, my node that subscribes to the published frames can properly publish the transforms between frames. Then, I went back to the initial part of my project about following one robot with another. I wanted to use the rqt_graph function to create a graph of the published error and then see how my controller would move it back to normal. However, when I use ...

July 25, 2024

Today, I began by working on making a ROS2 node that would publish the IMU data in an sensor_msgs/Imu message. However, the executable that runs the IMU is not a ROS2 node, so it is difficult to just subscribe to the output. I found online that I could use the subprocess module, which allowed me to run the IMU executable at the same time as I run the IMU node that I made. Then, I read each line of the output, split the string into a list, and then filled in the fields of the IMU message.  Then, I had some troubles using the lookup_transform() method. Even after confirming that the frames were published on rviz2, creating the frame tree pdf, and many debugging methods, I am unable to generate a transform between the IMU north frame and the tag frame.

July 24, 2024

Today, I focused on implementing the IMU onto my robot. I began by wiring my IMU onto my Libre board. Since many of the GPIO pins were used from the motors and the encoders, I had to connect the SCL and SDA to two other pins (27 and 28), and then enable I2C to use the pins.  I faced many errors while setting up the IMU on the board. I first faced errors while merging the new I2C bus since every time I would reboot, the new bus (/dev/i2c-1) would not appear. I finally figured out that the "sudo ldto merge" command needed to include the I2C bus at the end. Then, I faced errors when running the IMU. Initially, when I ran the command, an error popped up saying that none of the sensors were detected from the IMU. I went through many debugging processes: first, I used the multimeter to ensure that the IMU was receiving ample power; then, I read through the register mapping on the IMU documentation to interpret the I2C scan output. I finally found out that it was in fact the initial...

July 23, 2024

Today, I began the day by reading a bit more about IMUs. I looked at a couple programs on GitHub that publish the raw IMU data. I also found a ROS2 message type called sensor_msgs/Imu.msg, which publishes the IMU data. I think that with the raw IMU data, I can create a node that publishes the Imu message, which I can then use for mapping. Then, I figured out how to use Rviz2. Last time, I was unable to use RDP on Remmina, but today, when I reinstalled it, I was able to use it. I connected to my robot's IP, and then ran rviz2. I was able to vizualize the position of the AprilTag relative to robot. I also wanted to try having two AprilTags in frame and seeing their positions on rviz, but my camera was unable to detect the new AprilTag, which I am guessing is due to its bigger size. After being able to do this, I will need to calculate the transform between adjacent tags in order to map them. I also had some trouble putting my code into BitBucket today. When I cloned my src folder, on...

July 17, 2024

Today, I mainly worked on implementing a derivative controller to my ROSBot. Yesterday, my robot could track the AprilTag relatively well, other than when the tag went out of the field of view of the camera. Using a derivative controller as well would help with this issue.  I first watched Professor Tron's lectures on derivative controllers to get an idea of the theory behind derivative controllers. However, real life is a bit different from theory, so instead of taking the derivative of the error function like in theory, I made some code that would calculate the difference between the current error and the previous timestamp's error, and then divide that all by the interval of time between the two error values. Then, I multiplied this value by K_d, and then added it onto my proportional error value.  When trying my new controller with an AprilTag, it was definitely much smoother than just using a proportional controller. Below is a short video showing my testing. After, I pla...

July 16, 2024

Today, I worked on getting the angular and distance error during AprilTag detection. At first, I was going to try out the tf2 library to be able to get the translation matrix, which I could use to find the distance from the camera to the AprilTag. However, Tom gave me a suggestion to use the apriltag_ros node from GitHub since the message published by this node gave me the coordinates of the AprilTag center relative to the center of the camera. This method would be more straightforward than using tf2 and matrices, so I downloaded the code from GitHub onto my robots. Then, I created a node that would calculate the distance and angular error of the AprilTag relative to the center of the camera. The x-axis and y-axis are parallel to the plane of the camera, while the z-axis is perpendicular to the plane. So from a top-down view looking at the camera and the AprilTag, the angular error is arctan(x/z), while the distance error is sqrt(x^2 + z^2). Then, I could put these values into a Twist ...

July 12, 2024

Today, I began by fixing the launch files that I made yesterday. The launch files I made yesterday were different names, so calling them each time for each robot was a bit of a hassle. This time, I made every launch file the same for each robot, and then using the platform module and the platform.node() function, I could concatenate the robot host name to the front of all the topics and nodes. Then, I worked on a node that would publish the angular error between the center of the AprilTag and the robot's camera. To do so, I created a triangle with the x-displacement and y-displacement between the center of the AprilTag and the center of the camera, and then used that triangle to find the angle between them. Then, I published this angular error as a float64 message, and then with another program that converted the node's float64 message to a Twist message, I could move the robot's motors so that the robot would turn to follow the AprilTag. Finally, I read a bit of documentat...

July 11, 2024

Today, I worked on making launch files for several nodes so that I can control each robot individually. To do so, I changed the remapping of many topics so that they had the prefix "r1" or "r2", which represents robot 1 and robot 2, respectively. The first launch files I created were for the motor_command nodes. I named the files "r1_mtrcmd_launch.py" and "r2_mtrcmd_launch.py" for each of the robots. In the file, I remapped the topic names so that they also had the prefix "/r1" or "/r2".  Then, I tried making launch files for the key_op nodes. However, when I launched them, I received a termios error, which meant that I couldn't press keys as inputs. I tried a number of ways to fix it, but nothing worked. Nevertheless, I created a launch file for the scripted_op nodes, and it worked. Finally, I created launch files for the camera. I began by making a launch file for the camera0 node, which was mainly just remapping and cha...

July 10, 2024

Today, I began by testing the "key_op.py" code again on both ROSBots. When I ran it and listed all of the topics using "ros2 topic list," I noticed that each robot was receiving the same topics. If I wanted to somehow control the two robots individually, I would need to find a way to differentiate between the topics.  I spent most of my day looking at articles, tutorials, and lectures about launch files and remapping. I will need to study these subjects in order to implement individual control between the robots. I also spent some time looking at proportional controller control theory. I will implement this to make my robot follow and move where the AprilTag moves. I have a couple questions about the launch files and remapping. Right now, I only have camera_launch.py and apriltag_launch.py. Does that mean I should make a new launch file for the motor nodes? Also, for differentiating between the topics, does th at maybe mean that in the launch file, I add a namespace...

July 9, 2024

Now that my new ROSBot has been set up, I needed to add some functionality to it. I began by copying all of the movement files that I created, such as motor_command.py, key_op.py, and script_op.py, onto my new ROSBot. Then, I worked on downloading the AprilTag repository onto the ROSBot. However, when running " rastic_cl ws clone me416_apriltag," it said that there was an error fetching some archives. I then ran "sudo apt update" to make sure that everything was up to date, but when I ran that, there was errors about certificate verification failures and updates to repositories could not be applied. I tried fixing the certification issue, but Professor Tron noticed that it was a problem with date on the Libre computer. After setting it to the current date, I was able to install and set up the AprilTag code on the ROSBot.  Then, I tried controlling both robots at the same time from a single computer. I had two VSCode windows opened, each SSH connected to a ROSBot. I ...

July 8, 2024

Today, I began by working on the AprilTag calibration error from before. From Professor Tron, I learned that I couldn't commit my calibration data, but rather I would need to save it and copy it into a folder. Specifically, I unzipped a .tar.gz file, moved the contents with all of the calibration data into a new folder in "/home/ubuntu/.ros", and changed the name of the .yaml file to "usb_2.0_camera:_usb_camera.yaml" so that it corresponded with the camera's name.  Then, I had some issues with the "camera_launch.py" and "apriltag_launch.py" files. When I ran both files, nothing was happening. Supposedly, the camera node would be publishing a topic that the AprilTag node would be subscribed to, but Professor Tron noticed that the camera node published a different topic that the AprilTag node was subscribed to. After fixing that, the camera was able to detect the AprilTag. At the end of the day, I received a new Libre computer from Professo...

July 5, 2024

Today, I started my day by continuing to try to boot up my second ROSBot. However, just like the other day, nothing was working. I connected an HDMI cable to the Libre computer to be able to visualize what was going on. Tom and I  began by swapping the SD card of the second ROSBot with the SD card of the working ROSBot; however, the Libre failed to boot, with the error message: "end Kernel panic - not syncing: Attempted to kill init!". We then tried to replace the jumper to its original position on the Libre computer, but the same error message occured. Finally, Tom flashed a USB stick and plugged it into the Libre computer, and this time, the montior would not even turn on.   After not being able to make much progress with the booting up of the second ROSBot, I decided to work with the working ROSBot and test out some AprilTag code with the ROSBot camera. First, I needed to calibrate my camera, so to do so, I followed a tutorial for monocular calibration. The calibration...

July 3, 2024

Today, before the parts arrived, I was attempting to connect to the ROSBot and my personal laptop at the same time. Since I did not have my second robot yet, my laptop would act like a makeshift robot and print motion statements instead of turning motors. However, I could not figure out how to do so, since I was unable to SSH into both devices from my desktop computer. After, the parts arrived, so I began assembling my second ROSBot. The assembly process went relatively smoothly, although there were some difficulties. For instance, the Wiki instructions indicated to use M5 locknuts to secure the ball caster to the chassis, but after searching the whole lab, and even RASTIC, I couldn't find any, so I just decided to use normal M5 screws. I also had some trouble soldering since I have not done it for a while, so that process took a while and ended up not looking so pretty. However, after using the multimeter to run connectivity tests, I decided that despite my subpar soldering skills...

July 2, 2024

Today, I started by finishing up HW1 from Professor Tron's ME416 course, which was mainly finishing my code for the "motor_command.py" file. I tested it with the "zigzag_op.py" file, and it worked: my robot followed a path of forward arches! Then, I went on to HW2, which unlike HW1, was much smoother. I learned how to control my robot with my keyboard, which was in the "key_op.py" file, and with a sequence of directions, which was in the "scripted_op.py" file.  I also finished HW3 today. I used linear algebra to solve a kinematic model of a robot, which I then implemented into the "twist_to_speeds()" function. Then, I set up a makeshift environment to calibrate my robot. I tuned the k and d values in order to make sure my robot would travel roughly 1 ft and turn roughly 90 degrees. After tuning, I was able to have my robot go in a square, and it ended up at the original position quite precisely! After completing all of the homeworks...

July 1, 2024

Today, with the help of Marc and Tom, I was first able to SSH, first with Ethernet and then with Wifi, onto the ROSBot Libre Computer. Then, I followed the instructions on the BU Robotics Wiki to test the robot motors with several scripts, such as "./motor_utility.py forward --side left". After, I began working on Homework 1 from Professor Tron's ME416 course. I had some trouble with the questions, but after following the lecture videos and lecture notes from the ME416 course, I was able to get through the first question and most of the second. Tomorrow, I will finish up HW1 and begin HW2, and if the parts for the other ROSBot arrive, I will assemble the robot. Throughout the day, I also had some questions. I was a bit confused about messages in ROS2. Are they like objects because they have attributes? Is there a function where I can explicitly list out the attributes? I was also a bit confused about self. Should I start everything with "self." in the "__in...