Skip to content

Commit

Permalink
Finalized ROS2 Node, only testing left :)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoseKapps committed Mar 18, 2024
1 parent 6ae9a09 commit d2e8d07
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 274 deletions.
Empty file modified asv_setup/CMakeLists.txt
100755 → 100644
Empty file.
Empty file modified asv_setup/README.md
100755 → 100644
Empty file.
Empty file modified asv_setup/config/environments/trondheim_freshwater.yaml
100755 → 100644
Empty file.
Empty file modified asv_setup/config/environments/trondheim_saltwater.yaml
100755 → 100644
Empty file.
9 changes: 6 additions & 3 deletions asv_setup/config/robots/freya.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@

rate_of_change:
max: 0 # Maximum rate of change in newton per second for a thruster
thruster_to_pin_map: [3, 2, 1, 0] # I.e. if thruster_to_pin = [1, 3, 2, 0] then thruster 0 is pin 1 etc..
direction: [1,-1,-1, 1] # Disclose during thruster mapping
offset: [0, 0, 0, 0] # Disclose during thruster mapping

thruster_to_pin_mapping: [0, 3, 2, 1] # I.e. if thruster_to_pin = [1, 3, 2, 0] then thruster 0 is pin 1 etc..
thruster_direction: [1, -1, 1, 1] # Disclose during thruster mapping (+/- 1)
thruster_PWM_offset: [0, 0, 0, 0] # Disclose during thruster mapping, Recomended: [0, 0, 0, 0]
thruster_PWM_min: [1100, 1100, 1100, 1100] # Minimum PWM value, Recomended: [1100, 1100, 1100, 1100]
thruster_PWM_max: [1900, 1900, 1900, 1900] # Maximum PWM value, Recomended: [1900, 1900, 1900, 1900]
command:
wrench:
max: [150.0, 150.0, 150.0, 150.0, 150.0, 150.0]
Expand Down
Empty file modified asv_setup/package.xml
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// C++ Libraries
#include <algorithm>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <iostream>
#include <algorithm>

#include <fcntl.h> // Used for the O_RDWR define
#include <fcntl.h> // Used for the O_RDWR define
#include <linux/i2c-dev.h> // Used for the I2C_SLAVE define
#include <sys/ioctl.h>
#include <unistd.h> // Used for the close function
#include <unistd.h> // Used for the close function


// Declare functions we can use
namespace thruster_interface_asv_driver_lib {
void init(const std::string &pathToCSVFile, int16_t *minPWM, int16_t *maxPWM);
int16_t *drive_thrusters(float *forces);
} // namespace thruster_interface_asv_driver_lib
void init(const std::string& pathToCSVFile, int8_t* thrusterMapping, int8_t* thrusterDirection, int16_t* offsetPWM, int16_t* minPWM, int16_t* maxPWM);
int16_t* drive_thrusters(float* thrusterForces);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// C++ Libraries
#include <vector>

// ROS2 libraries
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <chrono> // For the ROS2 Timer clock
#include <rclcpp/rclcpp.hpp>
#include <std_msgs/msg/float32_multi_array.hpp>
#include <std_msgs/msg/int16_multi_array.hpp>
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <chrono> // For the ROS2 Timer clock

// Custom libraries
#include <thruster_interface_asv/thruster_interface_asv_driver_lib.hpp>

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
# Path to the YAML file
yaml_file_path = os.path.join(
get_package_share_directory("thruster_interface_asv"),
"../../../../", # Go to the workspace
"src/vortex-asv/asv_setup/config/robots/", # Go inside where yamal files are located at
"freya.yaml"
)

return LaunchDescription([
Node(
package='thruster_interface_asv',
namespace='thruster_interface_asv',
executable='thruster_interface_asv_node',
name='thruster_interface_asv_node',
output='screen',
parameters=[yaml_file_path],
),
])
2 changes: 2 additions & 0 deletions motion/thruster_interface_asv/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_gtest</test_depend>

<exec_depend>ros2launch</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
Loading

0 comments on commit d2e8d07

Please sign in to comment.