Skip to content

Commit

Permalink
Remove old ESW code and add new interface files (#562)
Browse files Browse the repository at this point in the history
* Add projects with pinouts

* Add some boilerplate for brushed motor controller

* Add PIDF

* Add units library and update usage

* Work more on controller design

* Fix types for units

* Add reader and writer interface for input to controller (NOT COMPILING RN)

* Fix compile error

* I should get burned at the town square for this metapgraomming witchery

* Clean up slightly

* Ditch massive header only units library that was C++14 and took forever to compile

* Minor fixes

* Refactor to use trailing return type and auto in function parameters

* Normalize naming

* Add position control logic

* Added copy ctor and assignment operator for Unit and added Convertible concept

* Add clang format and tidy, add more units

* Add more information to implementing controller

* Fix Ratioable concept bug

* remove useless line

* add specialization for radians. TODO: might want to make this for angles in general, or better, upgrade to quaternions

* initial implementation for EncoderReader, haven't fused with absolute encoder yet

* Update pdb ioc to include auton LED pins

* init motor library

* Add moteus git submodule

* Motor interface improvements

* Add moteus to cmake

* Update motors manager to distinguish between brushed and brushless

* Add very buggy implementation of drive_bridge

* Stop drive wheels if no message received within heartbeat

* Add multiplier functionality to drive, asserts, and comments

* Add arm bridge code

* Update arm library to adjust for changes in units

* Add LED HW Bridge implementation

* Add PDB Bridge

* Create mast gimbal bridge

* update mast gimbal bugs

* Update some bugs

* Add some CAN library thingy

* Integrate CANManager

* Add some more can code

* Add position, throttle, and velocity

* Change to rad/s

* Attempt to adjust to use position velocity and throttle for more

* Throttle, velocity

* Add some stuff

* Update CMakelists

* Remove outdated code and update CMakeLists so we can actually start debuggin hahahaha

* updated science pinout

* Try to resolve some errors

* Try to fix more errors

* Make changes for mast gimbal bridge

* Add function stubs for publishing data for drive

* updated science pinout

* Update msg and srv files

* Remove outdated firmware

* Modify some code

* Update files

* make compile, circular import is circular

* minor changes

* Make catkin build work in ci mode

* Change garbage logic to TODO ros info logs

* Add led node

* Move position, velocity, and throttle functions to MotorsManager

* Create template for cache, sa, and science bridge

* Make code build

* Properly subscribe to all servers [albeit in an ugly way]

* Simplify science bridge code using lambda function

* Change frame to variable size vector

* Update SA bridge to use UV LED

* Change it to message id

* Add CAN node

* Add FreeRTOS to science fw

* Add science task prototypes

* Update pdb code

* Update CAN Node

* Try to use actual CAN interface messages

* Move files to .cpp

* Add templated function for sending can messages. Make interface for generic. Use bit case instead of unions

* Minor changes

* update can msg

* Update pdb pinoutto have RA laser and UV bulb

* Remove from asserts

* Remove unfinished programs

* Modify and delete outdated launch files

* Remove more new code

---------

Co-authored-by: qhdwight <[email protected]>
Co-authored-by: Steven Xia <[email protected]>
Co-authored-by: Wilson <[email protected]>
Co-authored-by: jmaff <[email protected]>
Co-authored-by: wisabel0 <[email protected]>
Co-authored-by: Owen Park <[email protected]>
  • Loading branch information
7 people authored Oct 7, 2023
1 parent e36317a commit e44b080
Show file tree
Hide file tree
Showing 266 changed files with 76 additions and 215,705 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ moteus-cal*

# CSV
*.csv

# STM32 workspace
.metadata

Debug/
Release/
.metadata/
.settings/
RemoteSystemsTempFiles/

*.chm
*.settings.xml

*.xml
*.launch
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/moteus"]
path = deps/moteus
url = [email protected]:mjbots/moteus.git
59 changes: 29 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld-16)
endif ()
set(MROVER_CPP_COMPILE_OPTIONS -Wall -Wextra -Werror -pedantic)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(MROVER_CPP_COMPILE_OPTIONS -Wall -Wextra -Werror -pedantic)
endif ()

# Generate compile_commands.json for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand All @@ -24,48 +26,45 @@ set(MROVER_PACKAGES

# Message files
set(MROVER_MESSAGE_FILES
AvailableCameras.msg
Calibrated.msg
CalibrationStatus.msg
CameraCmd.msg
Carousel.msg
CAN.msg
Chassis.msg
ControllerGroupState.msg
ControllerState.msg
Course.msg
Diagnostic.msg
EnableAuton.msg
GPSWaypoint.msg
GPSPointList.msg
GPSWaypoint.msg
HeaterData.msg
ImuAndMag.msg
LimitSwitchData.msg
MastGimbal.msg
JointLock.msg
LED.msg
MoteusState.msg
MotorsStatus.msg
NavMetadata.msg
NavState.msg
NetworkBandwidth.msg
ScienceTemperature.msg
PDB.msg
Position.msg
ScienceThermistors.msg
Spectral.msg
SpectralGroup.msg
Throttle.msg
Velocity.msg
Waypoint.msg
WaypointType.msg
GPSPointList.msg
)

# Service files
set(MROVER_SERVICE_FILES
AdjustMotors.srv
CalibrateMotors.srv
AdjustMotor.srv
ChangeArmMode.srv
ChangeCameras.srv
ChangeHeaterState.srv
ChangeServoAngle.srv
EnableDevice.srv
FetchMessageFromPackage.srv
FetchMessageFromPackage.srv
FetchPackages.srv
PublishEnableAuton.srv
PublishCourse.srv
ResetCameras.srv
PublishEnableAuton.srv
)

# Generate messages list
Expand Down Expand Up @@ -106,6 +105,11 @@ macro(add_cpp_library_macro name sources includes)
rosify_cpp_target_macro(${name})
endmacro()

macro(add_cpp_interface_library_macro name includes)
add_library(${name} INTERFACE)
target_include_directories(${name} INTERFACE ${includes})
endmacro()

macro(add_cpp_node_macro name sources)
file(GLOB_RECURSE CPP_NODE_SOURCES ${sources})
add_executable(${name} ${CPP_NODE_SOURCES})
Expand Down Expand Up @@ -183,7 +187,7 @@ if (${DEVICE} MATCHES "raspi4")
# define an add and link macro
# Put items here to build
macro(add_and_link_macro)
add_cpp_node_macro(brushed_motors "src/esw/brushed_motors/*")
# add_cpp_node_macro(arm_bridge "src/esw/arm_bridge/*")
endmacro()
else ()
# -=-=-=-=-
Expand Down Expand Up @@ -233,23 +237,18 @@ else ()
target_precompile_headers(tag_detector_nodelet PRIVATE src/perception/tag_detector/pch.hpp)
target_link_libraries(tag_detector_nodelet PRIVATE opencv_core opencv_objdetect opencv_aruco opencv_imgproc lie)

add_cpp_node_macro(brushed_motors "src/esw/brushed_motors/*.cpp")
add_cpp_library_macro(lie src/util/lie/*.cpp src/util/lie)

add_cpp_library_macro(lie "src/util/lie/*.cpp" "src/util/lie")
add_cpp_interface_library_macro(moteus deps/moteus/lib/cpp/mjbots)

add_gazebo_plugin_macro(differential_drive_plugin_6w src/gazebo/differential_drive_6w.cpp src)

add_gazebo_plugin_macro(differential_drive_plugin_6w "src/gazebo/differential_drive_6w.cpp" "src")

add_gazebo_plugin_macro(kinect_plugin "src/gazebo/gazebo_ros_openni_kinect.cpp" "src/gazebo")
add_gazebo_plugin_macro(kinect_plugin src/gazebo/gazebo_ros_openni_kinect.cpp src/gazebo)
target_link_libraries(kinect_plugin PRIVATE gazebo_ros_camera_utils DepthCameraPlugin Eigen3::Eigen)
set_target_properties(kinect_plugin PROPERTIES CXX_CLANG_TIDY "")

if (ZED_FOUND)
# add_cpp_node_macro(zed_node "src/perception/zed_wrapper/*.c*")
# target_link_options(zed_node PRIVATE "LINKER:--copy-dt-needed-entries")
# target_include_directories(zed_node SYSTEM PRIVATE ${ZED_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})
# target_link_libraries(zed_node PRIVATE ${ZED_LIBRARIES} ${OpenCV_LIBRARIES} ${SPECIAL_OS_LIBS} lie tag_detector_nodelet)

add_cpp_nodelet_macro(zed_nodelet "src/perception/zed_wrapper/*.c*" , "src/perception/zed_wrapper")
add_cpp_nodelet_macro(zed_nodelet src/perception/zed_wrapper/*.c* src/perception/zed_wrapper)
target_precompile_headers(zed_nodelet PRIVATE src/perception/zed_wrapper/pch.hpp)
target_include_directories(zed_nodelet SYSTEM PRIVATE ${ZED_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})
target_link_libraries(zed_nodelet PRIVATE ${ZED_LIBRARIES} ${OpenCV_LIBRARIES} ${SPECIAL_OS_LIBS} lie)
Expand Down
1 change: 1 addition & 0 deletions deps/moteus
Submodule moteus added at d77f76
11 changes: 0 additions & 11 deletions launch/brushed.launch

This file was deleted.

16 changes: 0 additions & 16 deletions launch/brushless.launch

This file was deleted.

7 changes: 0 additions & 7 deletions launch/jetson.launch
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
<rosparam command="load" file="$(find mrover)/config/teleop.yaml"/>
<node name="jetson_teleop" pkg="mrover" type="jetson_teleop.py"/>

<!-- science board node for Auton, ES, and Science missions. -->
<node name="science" pkg="mrover" type="science.py" output="screen"/>

<!-- camera node -->
<node name="cameras" pkg="mrover" type="cameras.py"/>

<!-- Run the auton led program -->
<node name="auton_led" pkg="mrover" type="auton_led.py" output="screen"></node>

</launch>
18 changes: 0 additions & 18 deletions launch/pi.launch

This file was deleted.

2 changes: 0 additions & 2 deletions msg/AvailableCameras.msg

This file was deleted.

3 changes: 3 additions & 0 deletions msg/CAN.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
uint8 bus
uint16 message_id
uint8[] data
2 changes: 0 additions & 2 deletions msg/Calibrated.msg

This file was deleted.

3 changes: 0 additions & 3 deletions msg/Carousel.msg

This file was deleted.

1 change: 1 addition & 0 deletions msg/ControllerGroupState.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ControllerState[] controllers
3 changes: 3 additions & 0 deletions msg/ControllerState.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string name
string state # Armed, Disconnected, or Error
string error
2 changes: 0 additions & 2 deletions msg/Diagnostic.msg

This file was deleted.

2 changes: 1 addition & 1 deletion msg/HeaterData.msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bool[3] state
bool[6] state
1 change: 0 additions & 1 deletion msg/JointLock.msg

This file was deleted.

4 changes: 4 additions & 0 deletions msg/LED.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bool red
bool green
bool blue
bool is_blinking
4 changes: 0 additions & 4 deletions msg/LimitSwitchData.msg

This file was deleted.

2 changes: 0 additions & 2 deletions msg/MastGimbal.msg

This file was deleted.

1 change: 1 addition & 0 deletions msg/NavState.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bool completed # TODO - temporary
2 changes: 2 additions & 0 deletions msg/PDB.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
float32[5] temperatures # Celsius. 0-2 are for the 12V bucks, 3 is for 5V, 4 is for 3.3V.
float32[5] currents # Amperes
2 changes: 2 additions & 0 deletions msg/Position.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string[] names # names of joints
float32[] positions # position should be in radians for the joints
1 change: 0 additions & 1 deletion msg/ScienceTemperature.msg

This file was deleted.

1 change: 1 addition & 0 deletions msg/ScienceThermistors.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sensor_msgs/Temperature[6] temperatures # Celsius
2 changes: 1 addition & 1 deletion msg/Spectral.msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
int32[6] data
int32[6] data
1 change: 1 addition & 0 deletions msg/SpectralGroup.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Spectral[3] spectrals
2 changes: 2 additions & 0 deletions msg/Throttle.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string[] names # names of joints
float32[] throttles # throttle should be [-1.0, 1.0] for the joints
2 changes: 2 additions & 0 deletions msg/Velocity.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string[] names # names of joints
float32[] velocities # velocity should be in rad/s for joints
Loading

0 comments on commit e44b080

Please sign in to comment.