Skip to content

Commit

Permalink
fix for coordinate nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrayappa committed Jun 30, 2024
1 parent fa890e3 commit 52352f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
import launch
from launch import LaunchDescription
from launch_ros.actions import Node
from launch_ros.descriptions import ComposableNode
from launch.actions import SetEnvironmentVariable
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode

def generate_launch_description():

container = ComposableNodeContainer(
name='container',
namespace="",
Expand All @@ -16,7 +18,8 @@ def generate_launch_description():
plugin='drivetraincontrollerComposition::CoordinateNode',
name='coordinateNode'
),
]
],
output='screen'
)

return launch.LaunchDescription([container])

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ namespace drivetraincontrollerComposition
CoordinateNode::CoordinateNode(const rclcpp::NodeOptions & options) : Node("coordinateNode", options) {
auto callback = [this](const uwrt_mars_rover_xbox_controller::msg::XboxController::SharedPtr msg_in) -> void {
//Add scaling value
const int vConstant = 5;
int vConstant = 5;

auto msg = std::make_unique<geometry_msgs::msg::Twist>();
msg->linear.x = (*msg_in).drivetrain_joy_x * vConstant;
msg->angular.z = (*msg_in).gimble_joy_x * vConstant;
msg->linear.x = (*msg_in).drivetrain_joy_y * vConstant;
msg->angular.z = (*msg_in).drivetrain_joy_x * vConstant;
msg->linear.x = (*msg_in).gimble_joy_y*(vConstant++);
msg->linear.x = (*msg_in).gimble_joy_x*(vConstant--);

//To avoid overflow
if(vConstant > 2147483647 || vConstant < 0)
vConstant = 5;

pub_->publish(std::move(msg));
};
Expand All @@ -21,4 +27,4 @@ CoordinateNode::CoordinateNode(const rclcpp::NodeOptions & options) : Node("coor
} // namespace drivetraincontrollerComposition

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(drivetraincontrollerComposition::CoordinateNode)
RCLCPP_COMPONENTS_REGISTER_NODE(drivetraincontrollerComposition::CoordinateNode)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ UWRTXboxController::UWRTXboxController(const rclcpp::NodeOptions & options)
"joy", 10, std::bind(&UWRTXboxController::getXboxData, this, std::placeholders::_1));
xbox_node_pub = create_publisher<xbox_msg>("/xbox_info", 10);
pub_timer =
create_wall_timer(100ms, std::bind(&UWRTXboxController::publishStructuredXboxData, this));
create_wall_timer(1000ms, std::bind(&UWRTXboxController::publishStructuredXboxData, this));
}

void UWRTXboxController::getXboxData(const joy_msg::SharedPtr msg)
Expand Down

0 comments on commit 52352f7

Please sign in to comment.