Skip to content

MRoboSub/mrobosub_arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mrobosub_arduino

An Arduino sketch project for Michigan Robotic Submarine.

Current Modules

  • DepthSensorSketch.hpp - For getting readings from a Bar30 Depth/Pressure Sensor - namespace DepthSensorSketch
  • ServoSketch.hpp - For controlling two DSSERVO 35kg servo - namespace ServoSketch
  • ESCMotorSketch.hpp - For controlling eight BlueRobotics ESC motors - namespace ESCMotorSketch

Pins Used

Publishers

  • /depth/raw_depth - type std_msgs::Float32 - the depth sensor reading, in meters - DepthSensorSketch.hpp

Subscribers

  • /left_servo/angle - type std_msgs::Int32 - the angle to set the left servo to, between 25 and 155 degrees - ServoSketch.hpp
  • /right_servo/angle - type std_msgs::Int32 - the angle to set the right servo to, between 25 and 155 degrees - ServoSketch.hpp
  • /motors/pwm - type std_msgs::Int16MultiArray - an array of pwms to set the eight motors to - ESCMotorSketch.hpp

Testing

Docker is a prerequisite.

First, build the image and fire up the Docker container:

$ docker-compose up -d

Attach two terminals to the container (VSCode Docker extension might be helpful)

In one terminal, start roscore:

/root/catkin_ws/src/$ roscore

Find which serial port your Arduino is connected to. Replace [PORT] in the following steps with it.

In the second terminal, compile and upload the sketch:

/root/catkin_ws/src/$ cd main
/root/catkin_ws/src/main$ arduino-cli compile --fqbn arduino:avr:mega
/root/catkin_ws/src/main$ arduino-cli upload --fqbn arduino:avr:mega -p [PORT]

Now, start the rosserial client application to connect the Arduino to the rest of ROS:

/root/catkin_ws/src/main$ rosrun rosserial_python serial_node.py [PORT]

An alternate option with a ~reset_arduino service endpoint:

/root/catkin_ws/src/main$ rosrun rosserial_arduino serial_node.py _port:=[PORT]

The terminal should now begin displaying logs and connecting to the Arduino. Publishers, subscribers, and topics from the Arduino should now be registered and read as normal.

i.e., reading from the depth sensor's /depth/raw_depth topic:

/root/catkin_ws/src/$ rostopic echo /depth/raw_depth

This tutorial has largely been paraphrased from the ROS Wiki rosserial_arduino Tutorial.

Development Setup

Docker is a prerequisite for working properly with dependencies.

Start the Docker container:

$ docker-compose up -d

Attach to the Docker container. The source is in main.

Tools Used

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6