Skip to content

Commit

Permalink
Remove things
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjong committed Jul 1, 2024
1 parent fab7150 commit ca2c08e
Show file tree
Hide file tree
Showing 236 changed files with 82 additions and 4,533 deletions.
6 changes: 0 additions & 6 deletions ros_ws/src/main_launch/launch/main_launch.yaml

This file was deleted.

Empty file.
18 changes: 0 additions & 18 deletions ros_ws/src/main_launch/package.xml

This file was deleted.

Empty file.
4 changes: 0 additions & 4 deletions ros_ws/src/main_launch/setup.cfg

This file was deleted.

33 changes: 0 additions & 33 deletions ros_ws/src/main_launch/setup.py

This file was deleted.

25 changes: 0 additions & 25 deletions ros_ws/src/main_launch/test/test_copyright.py

This file was deleted.

25 changes: 0 additions & 25 deletions ros_ws/src/main_launch/test/test_flake8.py

This file was deleted.

23 changes: 0 additions & 23 deletions ros_ws/src/main_launch/test/test_pep257.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Test
on: push

jobs:
build:
runs-on: [ubuntu-22.04]
strategy:
fail-fast: false
matrix:
config:
- {rosdistro: 'humble', container: 'osrf/ros:humble-desktop'}
container: ${{ matrix.config.container }}
steps:
- uses: actions/checkout@v4
- name: Install binary dependencies with rosdep
run: |
apt update
rosdep update
source /opt/ros/${{ matrix.config.rosdistro }}/setup.bash
rosdep install --from-paths . --ignore-src -y
shell: bash
- name: Build with colcon
run: |
source /opt/ros/${{ matrix.config.rosdistro }}/setup.bash
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
shell: bash
- name: Run tests
run: |
source /opt/ros/${{ matrix.config.rosdistro }}/setup.bash
colcon test --event-handlers=console_cohesion+
colcon test-result --all --verbose
shell: bash
File renamed without changes.
106 changes: 50 additions & 56 deletions ros_ws/src/robot/autonomy/controls/px4_interface/src/px4_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include <tf2/LinearMath/Quaternion.h>
#include <tf2/LinearMath/Matrix3x3.h>

namespace px4_interface
{
namespace px4_interface {

class PX4Interface : public robot_interface::RobotInterface
{

class PX4Interface : public robot_interface::RobotInterface {
private:
rclcpp::Client<mavros_msgs::srv::SetMode>::SharedPtr set_mode_client;
rclcpp::Client<mavros_msgs::srv::CommandBool>::SharedPtr arming_client;
Expand All @@ -28,46 +27,45 @@ namespace px4_interface

bool got_pixhawk_yaw;
float pixhawk_yaw;

public:
PX4Interface()
{

PX4Interface(){
}

virtual void initialize(std::shared_ptr<rclcpp::Node> node)
{
virtual void initialize(std::shared_ptr<rclcpp::Node> node){
this->node = node;
got_state = false;

set_mode_client = node->create_client<mavros_msgs::srv::SetMode>("mavros/set_mode");
arming_client = node->create_client<mavros_msgs::srv::CommandBool>("mavros/cmd/arming");

attitude_target_pub = node->create_publisher<mavros_msgs::msg::AttitudeTarget>("mavros/setpoint_raw/attitude", 1);

state_sub = node->create_subscription<mavros_msgs::msg::State>("mavros/state", 1,
std::bind(&PX4Interface::state_callback, this,
std::placeholders::_1));
std::bind(&PX4Interface::state_callback, this,
std::placeholders::_1));
pixhawk_pose_sub = node->create_subscription<geometry_msgs::msg::PoseStamped>("mavros/local_position/pose", 1,
std::bind(&PX4Interface::pixhawk_pose_callback,
this, std::placeholders::_1));
}
std::bind(&PX4Interface::pixhawk_pose_callback,
this, std::placeholders::_1));

virtual ~PX4Interface()
{
}

virtual ~PX4Interface(){

}

void roll_pitch_yawrate_thrust_callback(mav_msgs::msg::RollPitchYawrateThrust msg) override
{
if (!got_pixhawk_yaw)
return;

void roll_pitch_yawrate_thrust_callback(mav_msgs::msg::RollPitchYawrateThrust msg) override {
if(!got_pixhawk_yaw)
return;

mavros_msgs::msg::AttitudeTarget att;
att.header.stamp = node->get_clock()->now(); //.to_msg();
att.header.stamp = node->get_clock()->now();//.to_msg();
att.type_mask = mavros_msgs::msg::AttitudeTarget::IGNORE_ROLL_RATE | mavros_msgs::msg::AttitudeTarget::IGNORE_PITCH_RATE;
tf2::Matrix3x3 m;
m.setRPY(msg.roll,
msg.pitch,
pixhawk_yaw);
msg.pitch,
pixhawk_yaw);
tf2::Quaternion q;
m.getRotation(q);
att.body_rate.z = msg.yaw_rate;
Expand All @@ -81,80 +79,76 @@ namespace px4_interface
attitude_target_pub->publish(att);
}

bool request_control() override
{
bool request_control() override {
bool success = false;

auto request = std::make_shared<mavros_msgs::srv::SetMode::Request>();
request->custom_mode = "OFFBOARD";

auto result = set_mode_client->async_send_request(request);
if (rclcpp::spin_until_future_complete(node, result) == rclcpp::FutureReturnCode::SUCCESS)
success = true;
success = true;

return success;
}

bool arm() override
{

bool arm() override {
bool success = false;

auto request = std::make_shared<mavros_msgs::srv::CommandBool::Request>();
request->value = true;

auto result = arming_client->async_send_request(request);
if (rclcpp::spin_until_future_complete(node, result) == rclcpp::FutureReturnCode::SUCCESS)
success = true;
success = true;

return success;
}

bool disarm() override
{

bool disarm() override {
bool success = false;

auto request = std::make_shared<mavros_msgs::srv::CommandBool::Request>();
request->value = false;

auto result = arming_client->async_send_request(request);
if (rclcpp::spin_until_future_complete(node, result) == rclcpp::FutureReturnCode::SUCCESS)
success = true;
success = true;

return success;
}

bool is_armed() override
{

bool is_armed() override {
return got_state && current_state.armed;
}

bool has_control() override
{

bool has_control() override {
return got_state && current_state.mode == "OFFBOARD";
}

void state_callback(const mavros_msgs::msg::State::SharedPtr msg)
{

void state_callback(const mavros_msgs::msg::State::SharedPtr msg){
got_state = true;
current_state = *msg;
}

void pixhawk_pose_callback(const geometry_msgs::msg::PoseStamped::SharedPtr pose)
{
void pixhawk_pose_callback(const geometry_msgs::msg::PoseStamped::SharedPtr pose){
tf2::Quaternion q(pose->pose.orientation.x,
pose->pose.orientation.y,
pose->pose.orientation.z,
pose->pose.orientation.w);
pose->pose.orientation.y,
pose->pose.orientation.z,
pose->pose.orientation.w);
double roll, pitch, yaw;
tf2::Matrix3x3(q).getRPY(roll, pitch, yaw);

got_pixhawk_yaw = true;
pixhawk_yaw = yaw;
}

};

}


#include <pluginlib/class_list_macros.hpp>

PLUGINLIB_EXPORT_CLASS(px4_interface::PX4Interface, robot_interface::RobotInterface)
2 changes: 0 additions & 2 deletions ros_ws/src/robot/autonomy/controls/px4_msgs/.gitignore

This file was deleted.

Loading

0 comments on commit ca2c08e

Please sign in to comment.