Open agutier4 opened 3 years ago
@benmartell93 a few notes:
CMakeLists.txt
to pull in the Eigen libraries to build correctly with the default Eigen3 installation from apt, make sure everything still builds for you manager.launch
so now it should load the correct reference frame for rviz by default. It also now has options to enable the visualization and drag with argsHere is the test procedure I would recommend (both with and without graphics enabled)
catkin_make
& . source devel/setup.zsh
)roslaunch pongrobot_actuation manager.launch
, rviz should open with the trajectory visualization configrostopic echo /launcher/velocity_cmd
to subscribe to the velocity output command/launcher/target_pose
, make sure to set the frame_id to launcher
and edit the x&y position as desired.roslaunch pongrobot_actuation manager.launch use_drag:=true
Note: If your system does not have graphics setup, you can disable the rviz trajectory visualization by running the manager launchfile with the use_graphics:=false
argument
Example command for drag and no graphics roslaunch pongrobot_actuation manager.launch use_drag:=true use_graphics:=false
Overview
Import the prototype drag calculations from pongrobot/pongrobot#2 into the Trajectory Manger. Refactor the existing code to allow users to enable/disable the drag calculation using a config flag. This will likely involve breaking the existing visualization code into a function and creating another version that includes the drag equations.
Issue dependencies:
Depends on pongrobot/pongrobot#2 which implements the prototype solver in MATLAB.
Solution Approach:
The code for the trajectory calculation all lives in
src/TrajectoryManager.cpp
andinclude/TrajectoryManager.h
. The TrajectoryManager is an object that handles all operation in thetrajectory_manager_node
. It takes in a position command from that main game node, calculates the launcher pitch from the TF if available and then uses that fixed launch angle to calculate the initial velocity. It also calculates the yaw position needed and solves the trajectory in cylindrical coordinates. The code should be setup so drag is controlled through a config value.Step 1 - Config setup and Refactoring
The first step is setting up the TrajectoryManager to enable drag through a config. Start be adding a new config value to
launcher_config.yaml
and add a variable to the TrajectoryManager to store it in once read. Next, create a new function for the velocity calculation with dragTrajectoryManager::calculateInitialVelocityDrag()
and setupTrajectoryManager::trajectoryPoseCallback()
to switch between the two velocity calculation functions based on the configuration. Repeat the same process forTrajectoryManager::buildTrajectoryMarker()
addingTrajectoryManager::buildTrajectoryMarkerDrag()
.Step 2 - Redo Initial Velocity Calculation
Now that
TrajectoryManager::calculateInitialVelocityDrag()
, it needs to be populated with the drag calculation from the prototype. This self contained function has access to all the data it needs ( tf, target pose, launch angle) and just needs to return a velocity in m/s. It must also set thecontact_time_
member variable with the time the ball hits the cup, this is used as an endpoint for the simulation in the next step.Step 3 - Simulate the Shot for Visualization
The simulation/visualization code all lives in
TrajectoryManager::buildTrajectoryMarker[Drag]()
and basically creates a list of points which ROS uses to create a line marker. The way this is currently done is by finding the contact time (done in step 2) then diving the time it takes up into a fixed number of steps (i.e. 100) and then plugging in the time into the equations of motion to find the position and create a point from it. This is easiest when done in cylindrical coordinates and can then be converted into Cartesian coordinates from plotting.Additional Considerations
Without having looked too hard at the initial MATLAB prototype, it sounds like there is a need for a Non-Linear solver library. These might not be the right fit but its a starting place: