Open YouthKim opened 10 months ago
It's both. Ideally, you would want to make sure the base mpc controller (run through _roslaunch sde4mbrl_px4 irissdectrl.launch or so) is fully compiled and waiting for a start_trajectory request before sending the request. Typically, you run the basic_control.py, then launch the iris_sdectrl.launch until you see that Jax has fully compiled the MPC problem. Then, in the command line that was used to start the basic_control.py, I would do the following sequentially: arm, takeoff, controller_init, controller_idle (this is to go at the start point of the trajectory), controller_on (this starts the trajectory). With this, you shouldn't have any non-defined variables. If you only want to send pose reference: do arm, takeoff, controller_init, ctrl_pos x x x xxxx. Please check the basic_control.py for details on what each command does.
In fact, I did exactly the steps you described, but still have this problem. When I run the file roslaunch sde4mbrl_px4 iris_sdectrl.launch, the status after waiting for the mpc compilation to complete is shown below, I don't know if this is normal or not
That's odd. I just checked it on my side, and everything looks fine (except the MPC cost tunning). Can you send here a trace of the message error?
Here's the error I'm getting when I run it:
I noticed that when running the sde4mbrl_px4 iris_sdectrl.launch file, the statements printed out are a little different than yours, mine doesn't show the MPC state message, could it be that my mavlink related settings aren't done properly?
Otherwise, I think it might be a good idea to check out whether your github commits are consistent with your own local code.
I just checked, and all the local repos (sde4mbrl, sde4mbrl_px4, and the cloned mavros) are up to date with Github. It seems like the ROS node never received a proper MPC_FULL_STATE message from mavros. The print statement "First MPC State message received" is misleading here as I am just printing an acknowledgment that messages are exchanged on the UDP port meant for exchanging MPC_FULL_STATE messages. In your case, that first message is a heartbeat for some reason. Hence, you don't see the state of the system. Now, the variable curr_time is automatically set every time an MPC_FULL_STATE message is received as defined here. And this should be set straight away after the ROS node is launched assuming mavros is already sending all the required messages. Now, I would say try to print out the messages here and check if you ever receive an MPC_FULL_STATE.
According to your suggestion, after my testing, I found that the MPC_FULL_STATE message was indeed not received, so the problem should be related to mavlink. I guess it may be that the mavlink under ~/catkin_ws/src/ does not work? Do I need to modify the mavlink file in the px4 firmware?
I ran the code as instructed, but the following error always occurred during the “controller init” step: [ERROR] [1705203611.465912]: BasicControl: Failed to call set_trajectory_and_params: service [/set_trajectory_and_params] responded with an error: b"error processing request: 'SDEControlROS' object has no attribute 'curr_time'" I checked the code and it seems that some variables are being used without proper initialization. I don't know if this is a problem with the code itself or a problem with my configuration process.