13 namespace aruna {
namespace movement {
38 log->
warning(
"Start failed: No drivers found!");
44 err_t stat = d->startup_error;
61 enum comm_commands_t {
78 SET_RUNNING_STATE = 0x20,
79 GET_RUNNING_STATE = 0x21,
81 CALIBRATE_SENSORS = 0x23,
82 GET_SUPPORTED_AXIS = 0x24,
83 SET_SENSOR_OFFSET = 0x25,
84 GET_SENSOR_OFFSET = 0x26,
86 GET_MPU_STATUS = 0x28,
91 GOTO_CORDINATES = 0x32,
104 void (*set_value)(
axis_mask_t mode, int16_t speed);
105 comm_commands_t command;
110 if (movement_channel.
receive(&request)) {
117 command = NO_COMMAND;
126 command = GET_DEGREE;
128 if (command == NO_COMMAND) {
130 command = GET_VELOCITY;
133 if (command == NO_COMMAND) {
142 if (mask & flags & (uint8_t) active_axis) {
146 buffer[2] = (speed >> 8);
147 buffer[3] = speed & 0xff;
160 command = SET_DEGREE;
162 if (command == NO_COMMAND) {
164 command = SET_VELOCITY;
167 if (command == NO_COMMAND) {
171 log->
verbose(
"command: %X, axis: 0X%02X, speed: %i", command, flags, data);
182 if (mask & flags & (uint8_t) active_axis) {
183 buffer[0] = GET_DAMPING;
198 case GET_RUNNING_STATE:
199 buffer[0] = GET_RUNNING_STATE;
204 case SET_RUNNING_STATE:
221 buffer[0] = TEST_SENSORS;
226 case CALIBRATE_SENSORS:
230 case GET_SUPPORTED_AXIS:
231 buffer[0] = GET_SUPPORTED_AXIS;
235 case SET_SENSOR_OFFSET:
236 case GET_SENSOR_OFFSET:
242 buffer[0] = GET_MPU_STATUS;
252 case GOTO_CORDINATES:
282 if (!
drivers.insert(driver).second)
301 ret = d->set(axisMask, speed);
308 if ((uint8_t) axisMask & j & (uint8_t) active_axis) {
340 modes |= (uint8_t) d->get_axis();
354 if ((uint8_t) axisMask & j & (uint8_t) active_axis) {
uint8_t test_sensor()
test whenever the sensors are connected, sensor should be horizontal and facing up.
void set_velocity(axis_mask_t axisMask, int16_t mm_per_second)
Set the target velocity of the ROV.
int debug(const char *format,...)
log debug message
axis_t< int16_t > currentVelocity
void calibrate_sensors()
Calibarte the sensors, aka set 0 point.
const std::map< err_t, char * > err_to_char
int16_t get_speed(axis_mask_t single_axis)
Get the speed of an axis.
status_t get_status()
get the status of the movement unit.
int16_t get_velocity(axis_mask_t single_axis)
get the current velocity
int16_t get_degree(axis_mask_t single_axis)
get the angle of an axis (pitch, roll and yaw only)
axis_t< int16_t > currentDegree
err_t send(port_t to_port, uint8_t *data, size_t data_size, bool wait_for_ack=false)
void set_damping(axis_mask_t axisMask, damping_t damp)
set the damping type.
void * comm_handler_task(void *arg)
task to handle all the incoming comm requests.
port_t from_port
channel who is sending the data.
axis_t< damping_t > currentDamping
bool receive(transmitpackage_t *tpp)
handeler to handle incomming connections
void set_degree(axis_mask_t axisMask, int16_t degree)
set the degree of an axis (only applies to yaw, pitch and roll)
status_t stop()
Stop all motors and free all processes.
Link * driver
stores the driver.
int verbose(const char *format,...)
log verbose message
damping_t get_damping(axis_mask_t single_axis)
get the damping of a single mode.
pthread_t movement_comm_handler
std::set< Actuator * > drivers
endpoint type of a comm channel
int warning(const char *format,...)
log warning message
int error(const char *format,...)
log error message
axis_mask_t get_active_axis()
Get active modus (X,Y,Z,yawn,pitch,roll)
err_t register_driver(Actuator *driver)
register a accelerator driver for use.
void set_speed(axis_mask_t axisMask, int16_t speed)
Set the speed of the motors directly.
status_t start()
initialise movement and communicate with hardware for active modes.
const port_t port
port nr.
axis_t< int16_t > currentSpeed
uint8_t * data_received
pointer to where incoming data must be stored.