Skip to content

Commit

Permalink
Add conveyor and Dump
Browse files Browse the repository at this point in the history
Moonshot needs to move crap and take dumps.
  • Loading branch information
matthewia94 committed Apr 22, 2016
1 parent 4c0353b commit 88bb6ac
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 12 deletions.
1 change: 1 addition & 0 deletions ros_ws/src/arudino/razor-9dof-ahrs
Submodule razor-9dof-ahrs added at f20eea
5 changes: 5 additions & 0 deletions ros_ws/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ ConfigValues initConfigs()
{
ROS_ERROR("max_ang_vel is not defined on the parameter server");
}

//controller mapping
get_int_param("/lin_vel_axis", config.lin_vel_axis);
get_int_param("/ang_vel_axis", config.ang_vel_axis);
get_int_param("conveyor_speed_forward", config.conveyor_speed_forward);
get_int_param("conveyor_speed_back", config.conveyor_speed_back);
get_int_param("/teleop_btn", config.teleop_btn);
get_int_param("/standby_btn", config.standby_btn);
get_int_param("/autonomous_btn", config.autonomous_btn);
get_int_param("/speed_inc_btn", config.speed_inc_btn);
get_int_param("/speed_dec_btn", config.speed_dec_btn);
get_int_param("/actuator_up", config.actuator_up);
get_int_param("/actuator_down", config.actuator_down);
return config;
}

6 changes: 4 additions & 2 deletions ros_ws/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ double max_ang_vel;
std::string controller_type;
int lin_vel_axis;
int ang_vel_axis;
int conveyor_speed_forward;
int conveyor_speed_back;
int teleop_btn;
int standby_btn;
int autonomous_btn;
int speed_inc_btn;
int speed_dec_btn;
int turbo_btn;


int actuator_up;
int actuator_down;
};
ConfigValues initConfigs();
void get_int_param(std::string key_name, int & config_var);
Expand Down
23 changes: 23 additions & 0 deletions ros_ws/src/control/include/control/remote_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <ros/ros.h>
#include <sensor_msgs/Joy.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/Int8.h>
#include <std_msgs/Float64.h>
#include "constants.h"

class RemoteControl
Expand All @@ -27,20 +29,41 @@ class RemoteControl
*/
geometry_msgs::Twist cmd_vel;

/**
* @brief The speed at which the actuators will run
*
* The actuators will curently work using 1 as up -1 as down and 0 as hold
*/
std_msgs::Int8 actuator_speed;

std_msgs::Float64 conveyor_speed;

/**
* @brief The twist publisher
*
* This ros publisher will be responsible for publishing the twist message which will eventually be sent to the
* robot's motor controllers.
*/
ros::Publisher twist_pub;

/**
* @brief The actuator publisher
*
* This ros publisher will be responsible for publishing the actuator message which will tell the actuators to go up
* or down.
*/
ros::Publisher actuator_pub;

ros::Publisher conveyor_pub;

/**
* @brief The joy message subscriber
*
* This ros subscriber will be responsible for subscribing to the joy message published by the controller method that
* is being used.
*/
ros::Subscriber joy_sub;

/**
* @brief The ros node handle
*/
Expand Down
27 changes: 18 additions & 9 deletions ros_ws/src/control/param/controllers/360.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,26 @@
#BACK_BUTTON: 6
#START_BUTTON: 7
#POWER_BUTTON: 8
#UP_DPAD: 13
#DOWN_DPAD: 14
#RIGHT_DPAD: 12
#LEFT_DPAD: 11



controller_type: xbox360
controller_type: xbox360

lin_vel_axis: 1
ang_vel_axis: 3
teleop_btn: 0
standby_btn: 1
lin_vel_axis: 1
ang_vel_axis: 3
conveyor_speed_forward: 5
conveyor_speed_back: 2
teleop_btn: 0
standby_btn: 1

autonomous_btn: 3
speed_inc_btn: 5
speed_dec_btn: 4
turbo_btn: 2
autonomous_btn: 3
speed_inc_btn: 5
speed_dec_btn: 4
turbo_btn: 2

actuator_up: 13
actuator_down: 14
25 changes: 24 additions & 1 deletion ros_ws/src/control/src/control/remote_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RemoteControl::RemoteControl()

joy_sub = nh.subscribe<sensor_msgs::Joy>(JOY_TOPIC, 1, &RemoteControl::joyCallback, this);
twist_pub = nh.advertise<geometry_msgs::Twist>(TELEOP_TOPIC, 1);
actuator_pub = nh.advertise<std_msgs::Int8>("dump_activate", 1);
conveyor_pub = nh.advertise<std_msgs::Float64>("conveyor_vel", 1);
}

RemoteControl::RemoteControl(std::string twist_topic, std::string joy_topic)
Expand All @@ -45,7 +47,6 @@ RemoteControl::RemoteControl(std::string twist_topic, std::string joy_topic)

void RemoteControl::joyCallback(const sensor_msgs::Joy::ConstPtr& msg)
{

if ((msg->buttons[config.speed_inc_btn] == 1) && (speed_modifier < 1))
{
speed_modifier += 0.01;
Expand All @@ -56,9 +57,31 @@ void RemoteControl::joyCallback(const sensor_msgs::Joy::ConstPtr& msg)
}
cmd_vel.linear.x = msg->axes[config.lin_vel_axis] * speed_modifier;
cmd_vel.angular.z = msg->axes[config.ang_vel_axis];

if((-msg->axes[config.conveyor_speed_forward] + 1) / 2 > 0)
conveyor_speed.data = (-msg->axes[config.conveyor_speed_forward] + 1) / 2;
else if((-msg->axes[config.conveyor_speed_back] + 1) / 2 > 0)
conveyor_speed.data = -(-msg->axes[config.conveyor_speed_back] + 1) / 2;
else
conveyor_speed.data = 0;

if(msg->buttons[config.actuator_up])
{
actuator_speed.data = 1;
}
else if(msg->buttons[config.actuator_down])
{
actuator_speed.data = -1;
}
else
{
actuator_speed.data = 0;
}
}

void RemoteControl::update()
{
twist_pub.publish(cmd_vel);
actuator_pub.publish(actuator_speed);
conveyor_pub.publish(conveyor_speed);
}
14 changes: 14 additions & 0 deletions ros_ws/src/navigation/include/navigation/navigation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Created by matt on 1/5/16.
//

#ifndef PROJECT_NAVIGATION_H
#define PROJECT_NAVIGATION_H


class Navigation {

};


#endif //PROJECT_NAVIGATION_H
5 changes: 5 additions & 0 deletions ros_ws/src/navigation/src/navigation/navigation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by matt on 1/5/16.
//

#include "navigation.h"
Empty file.

0 comments on commit 88bb6ac

Please sign in to comment.