Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motor topic refactor #74

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions autonomy/src/autonomy/automodule/cmd_to_wheel_speeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import rospy
from geometry_msgs.msg import Twist
from hwctrl.msg import MotorCmd, DriveMotorCmd
from hwctrl.msg import MotorCmd

# Make these members of class later
failed = False
Expand All @@ -15,6 +15,12 @@


class CmdToWheelSpeedsNode:
"""
Most ros nodes publish robot command velocities as a Twist message
The hwctrl expects MotorCmd messages (units of RPM in this case)
This node does that conversion.
This could be factored out to the hwctrl if needed
"""
def __init__(self):
rospy.init_node("cmd_to_wheel_speeds_node", anonymous=False)

Expand All @@ -24,7 +30,9 @@ def __init__(self):

self.motor_acceleration = rospy.get_param('/motor_command_accel')

self.motor_setpoint_pub = rospy.Publisher("/glenn_base/motor_cmds", DriveMotorCmd, queue_size=2)
self.left_motor_pub = rospy.Publisher("/glenn_base/port_motor_cmd", MotorCmd, queue_size=2)
self.right_motor_pub = rospy.Publisher("/glenn_base/starboard_motor_cmd", MotorCmd, queue_size=2)

rospy.Subscriber("/glenn_base/cmd_vel", Twist, self.cmd_vel_callback, queue_size=1)

rospy.spin()
Expand All @@ -38,4 +46,6 @@ def cmd_vel_callback(self, msg):

right_cmd = MotorCmd(setpoint=right_speed, acceleration=self.motor_acceleration)
left_cmd = MotorCmd(setpoint=left_speed, acceleration=self.motor_acceleration)
self.motor_setpoint_pub.publish(right=right_cmd, left=left_cmd)

self.left_motor_pub.publish(left_cmd)
self.right_motor_pub.publish(right_cmd)
7 changes: 7 additions & 0 deletions glenn_launcher/params/hardware/hwctrl_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ hardware:
port_drive:
id: 5
name: 'PORT DRIVE'
topic: '/glenn_base/port_motor_cmd'
type: 'vesc'
can_id: 5
gear_reduction: 630 # gear_reduc*pole_pairs
Expand All @@ -104,6 +105,7 @@ hardware:
starboard_drive:
id: 6
name: 'STARBOARD DRIVE'
topic: '/glenn_base/starboard_motor_cmd'
type: 'vesc'
can_id: 6
gear_reduction: 630 # gear_reduc*pole_pairs
Expand All @@ -114,6 +116,7 @@ hardware:
id: 7
name: 'DEPOSITION DUNKERINO'
type: 'vesc'
topic: "/deposition/winch_cmd"
can_id: 7
gear_reduction: 245 # gear_reduc*pole_pairs
max_rpm: 140
Expand All @@ -122,6 +125,7 @@ hardware:
exc_belt:
id: 8
name: 'EXCAVATION BELT'
topic: "/excavation/conveyor_cmd"
type: 'vesc'
can_id: 8
gear_reduction: 245 # gear_reduc*pole_pairs
Expand All @@ -131,6 +135,7 @@ hardware:
exc_translation:
id: 9
name: 'EXCAVATION TRANSLATION'
topic: "/excavation/depth_cmd"
type: 'vesc'
can_id: 9
gear_reduction: 245 # gear_reduc*pole_pairs
Expand All @@ -140,10 +145,12 @@ hardware:
exc_port_act:
id: 10
name: 'EXCAVATION PORT ACTUATOR'
topic: "/excavation/angle_cmd"
type: 'brushed_motor'
can_id: 10
exc_starboard_act:
id: 11
name: 'EXCAVATION STARBOARD ACTUATOR'
topic: "/excavation/angle_cmd"
type: 'brushed_motor'
can_id: 11
2 changes: 1 addition & 1 deletion hwctrl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options(-std=c++14 -O2)
else()
add_compile_options(-std=c++14 -Wall -Wextra -pedantic -g)
add_compile_options(-std=c++14 -Wall) # -Wextra -pedantic -g)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
Expand Down
132 changes: 0 additions & 132 deletions hwctrl/compile_commands.json

This file was deleted.

1 change: 1 addition & 0 deletions hwctrl/compile_commands.json
7 changes: 1 addition & 6 deletions hwctrl/include/hardware/bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

class BMCMotor : CanMotor {
public:
BMCMotor(ros::NodeHandle nh, const std::string& name, uint32_t id,
uint32_t can_id,
ros::Duration update_pd = ros::Duration(MOTOR_LOOP_PERIOD),
float accel_setpoint = DEFAULT_MAX_ACCEL,
float max_accel = DEFAULT_MAX_ACCEL, float max_rpm = DEFAULT_MAX_RPM,
float gear_reduc = 1.0f, ros::Duration timeout = ros::Duration(2.0));
BMCMotor(ros::NodeHandle nh, MotorConfig const& config);
virtual ~BMCMotor() = default;

virtual void setup() override final;
Expand Down
Loading